Thursday, May 26, 2011

reinstalling GRUB2

GRUB --- is Truly Grand !
And forgiving too.....

I have a triple boot system - fedora 11, ubuntu (Maverick Meerkat) and windows Vista.
The last one is purely due to my love for Microsoft Flight Simulator !

My fedora install is more than a year old, my ubuntu install is also a few months old and both are robust and fine. But as is expected...I have had to reinstall Vista three times during the last one month or so. Twice due to the trojans and once just becoz the OS decided that some file is missing and quit on me with the blue screen of death.

This post is about my experience with reinstalling windoz and getting GRUB back on the MBR so that I can boot up all the OSs.

As we all know, if one reinstalls windoz after installing linux, then the MBR is overwritten and GRUB is removed during the windoz installation without any prompt. This will lead to a situation wherein, one can boot only into windoz and the linux OS though existing can't be booted into. So the only solution is to get GRUB back on the MBR. But how to do that ?

Follow these easy steps :-
  • Boot up using a ubuntu live CD.
  • Fire up a terminal.
  • Check the partition info to ascertain where is the linux distro located:-
sudo fdisk -l
( For this post we will assume the ubuntu install is in /dev/sda6)
  • Next mount it
sudo mount -t auto /dev/sda6 /mnt
  • Reinstall GRUB2 using the following command
sudo grub-install --root-directory=/mnt /dev/sda
( The first loc i.e /mnt will ensure the grub2 required files are put in the
respective locations and the second argument /dev/sda specifies the
MBR of sda is to be replaced.)
  • Reboot your system

Congrats you have your familiar GRUB2 menu back and you can now boot back into both linux and windoz !

For a nice tute on GRUB2 check out this link.

Sunday, May 15, 2011

My journey with ubuntu

I have been using ubuntu 10.10 for a few months now..... And I seem to have forgotten the fedora altogether.
Everything works like a breeze and I have started getting a feeling akin to using the windoz......just kiddin.
BTW I am running my ubuntu install off a 8 GB hp thumb drive and though it is slowing down with every day (due to my never ending quest for more and more applcns) still is quite amazing and decent. So let me recount my experience !

Firstly, the install is simple and I did it with a Linux For You Mag DVD. I chose to install in a thumb drive and have chosen ext4 as the file system. I think I did a mistake here and I should have kept atleast 1 GB of FAT32 partition space to maintain portability of files across windoz and linux platforms.

Secondly, I did a whole lot of enhancement to my basic install. I did most of my install from the command line using apt-get . However, I have used Ubuntu Software Centre and Synaptic Package Manager too from time to time. I have maintained a sort of journal for the installed softwares alongwith the commands I have used to install them. Here is the list :-

//for mp3 integration with nautilus file browser.
// when we mouse over a mp3 file , it will play the music. No need to use movie player, vlc, etc.
sudo apt-get install mpg123

// for reading pdf docus.
acroread // installed using software centre.

// photoshop like image editing software.
sudo apt-get install gimp

// additional gstreamer plugins to ensure all codecs are usable on the linux distro.
sudo apt-get install gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg gstreamer0.10-plugins-ugly

// also installed vlc from the command line.
sudo apt-get install vlc

######## FFmpeg install : A nice tool to do transcoding between various codecs.#############
Medibuntu is a third-party repository that contains packages that are unable to be included in the official Ubuntu repositories. To install FFmpeg from Medibuntu open Terminal (Applications -> Accessories -> Terminal) and run the following:

sudo wget`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get -q update && sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring && sudo apt-get -q update

Now install FFmpeg:
sudo apt-get install ffmpeg libavcodec-extra-52

try out a screencast with ffmpeg :-
findout the absolute x and y coord using xwininfo command.
Next try this
ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 30 -s 656x464 -i :0.0+203,85 -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 output.mkv


// Google earth install is slightly different.
sudo apt-get install googleearth package // then makepackage and get the deb file and use dpkg.
sudo apt-get install lsb-core // reqd by googleearth if the icon shows up but the program donot start even after clickin on it.

// for viewing youtube vids.
sudo apt-get install adobe-flashplugin
// for downloading youtube vids using keepvid website download and install the jre using ubuntu software centre:-
java runtime environment
I have additionally install NetVideoHunter plugin for firefox and it is very nice.

// for voip and video conf
sudo apt-get install skype

Next I shall tell how I have taken a backup of my full pen drive install as a file using the dd command and how I restored it on a new 8 GB pen drive and made it a full clone of my hp thumb drive. I did the following steps to copy my flash drive installation onto a new usb drive :-

Link :-
Step 1 :- first I created the same filesystem as the existing usb drive's fs which is ext4.
mkfs.ext4 /dev/sdc1
Step 2 :- next I copied the contents to the new usb drive using the dd command :-
dd if=/dev/sdb1 of=/dev/sdc1
Step 3 :- Finally, I made the usb bootable by using grub-install :-
mount -t auto /dev/sdc1 /mnt
cd /mnt
chroot .
mount /proc
mount /dev
grub-install /dev/sdc
Just note that I have used the device name and not a partition name in the final step with grub-install i.e sdc and not sdc1.

Thanks for the help in the linuxwiki and a bit of common sense.
It feels gr8 to have the usb backed up ....I spent too much time customizing the installation and it looks gr8 too.

Also it would be nice to share my experience of creating an offline repo of all the softwares installed on my thumb drive, with others. By creating an offline repo, I have now got a way to first do a basic install of ubuntu on any stand alone PC, and also get all the additional softwares which I have installed on my thumb drive over the internet, without bothering to connect the standalone PC on the net.

######## Building a local repository ########

you may have to install build-essential and dpkg-dev to use the dpkg-scanpackages command in step 3.
sudo apt-get install build-essential
sudo apt-get install dpkg-dev

# 1. make a dir accessible (atleast by root)

sudo mkdir /var/my-local-repo

# 2. copy all the deb files to this directory.

# 3. cd to the /var/my-local-repo directory and run the following command to create the
Packages.gz file that is needed to for Synaptic to “see” your repository:

sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

# Please note that every time you add any more .deb files to this folder, you have to create a new Packages.gz file using the above command before the new file(s) will show up in
Synaptic (or Aptitude).

# Be sure to install the build-essential package (sudo apt-get install build-essential) before
running the above command.

# 4. Edit the /etc/apt/sources.list file and insert this on a new line (preferably the first):

deb file:/var/my-local-repo/ /

# the forward slash at end is not a typo and also note the single space between the last two

# 5. Reload the package index like this:

sudo apt-get update

# 6. Now open System->Administration->synaptic package manager and do the following :-
Settings->Repositories-> Deselect every repo other than the file:/var/my-local-repo under
the Ubuntu Software and Other Software tabs.

Click the reload button.

# 7. To install your favourite software from the local repo just do :-

sudo apt-get install

######## Building a local repository ########

I shall also share my experience on creating a cool desktop effect with my ubuntu install, fully loaded with - compiz, conky, cairo dock and a video wallpaper.

####### Kool Desktop effects ########

Install compiz, compiz-fusion-plugins-main,compizconfig-backend-gconf,compiz-plugins, compiz-gnome, compiz-core and compiz-fusion-plugins-extra using the Synaptic Package Manager.
sudo apt-get install compizconfig-settings-manager
Next enable System->Preferences->Appearence->Extra
After completing above step , you can customize compiz by going to System > Preferences > CompizConfig Settings Manager.

// this software gives a apple-Mac like dock panel at the bottom edge of the screen.
sudo apt-get install cairo-dock

// this software will run a transparent window on the desktop which will show the hardware / software status realtime. It can be configured to show news, weather, and sticky notes, etc. The script is placed in home folder and called .conkyrc . To start conky you may use conky& from a terminal or configure it to start auto after login completes.

sudo apt-get install conky

// The link :-
// to display any video as a desktop wallpaper we need to install xwinwrap and mplayer software
// the steps are :-
sudo apt-get install build-essential libx11-dev x11proto-xext-dev libxrender-dev libxext-dev cvs
cvs -d co xwinwrap
cd xwinwrap
sudo cp xwinwrap /usr/bin
sudo apt-get install mplayer

Now enjoy your movie wallpaper -
nishith@nishith-Aspire-4720:~/xwinwrap$ xwinwrap -ni -fs -s -st -sp -b -nf -- mplayer -wid WID '/media/clean/moviesFtp/CSI Miami S03E19 Sex & Taxes.avi' -loop 0

####### Kool Desktop effects ########

Since I am quite keen on cyber security issues, I tried and added ettercap, nmap, wireshark and metasploit with postgresql support , on my thumb drive.

######### Network Security ##########
sudo apt-get install ettercap
sudo apt-get secure-delete // for deleting data.
truecrypt // Installed using the truecrypt zip archive which has the installer.
sudo apt-get install zenmap // GUI for nmap. Nmap is included.
installing nessus.
download the nessus.*.deb file from the internet
install - dpkg -i nessus.*.deb

the nessus executables are in the folder /opt/nessus/sbin/
add a user to nessus using : cd /opt/nessus/sbin and then ./nessus-adduser
request for a registration on the nessus site
######### Network Security ##########

Cool isn't it !?!