Custom Search

Saturday, September 12, 2009

Howto Restore Linux After Windows Installation

Howto Restore Linux After Windows Installation

1)Make directory.step1 and step2 are not necessary if you boot from linux cd in 'rescue' mode.
mkdir /mnt/sysimage

2) Mount root (/) partiton.Suppose our root partition is 'sda5'.
mount /dev/sda5 /mnt/sysimage
or
Boot from linux cd in 'rescue' mode. Then mount root (/) partition to '/mnt/sysimage'.

3)In rescue mode changing root to mounted partition.This is for accessing binaries(grub-install,grub) in the '/bin' and '/sbin' directories in the root (/) partition (mounted partition).

sh-3.2#  chroot /mnt/sysimage

sh-3.2#  ls
sh-3.2#  vim /boot/grub/grub.conf
sh-3.2#  vim /boot/grub/menu.lst

4) Installing grub to hard disk.

sh-3.2#  greb-install /dev/sda

sda --> First hard disk (represent a whole hard disk)
If it finished with message 'Installation finished, no error reported' go to next step.

5) To go to grub shell.
sh-3.2#  grub 

6)
grub> root (hd0,4)

* remember to use space between 'root' command and (hd0,4).
* Here we specifing the partition where '/boot' directory exist. If linux completly installed in a single partition (Eg:sda5) then use 'root (hd0,4)'. if we installed root (/) in 'sda5' and created a seperated partition 'sda8' for '/boot', then you have to specify the partition where '/boot' present, that is use 'root (hd0,7) here.

(hd0,4) --> sda5
(hd0,7) --> sda7

7)
grub> setup (hd0)

you will you get a success message.

8) Exit from grub shell
grub> quit

9) Checking 'grub.conf'.

sh-3.2#  vim /boot/grub/grub.conf

A)
* 'grub.conf' file of system with root (/) and '/boot' installed in seperated partition. Here root (/) installed in 'sda5 or (hd0,4)' and '/boot' installed in 'sda7 or (hda0,8).
----------
default=0
timeout=5
splashimage=(hd0,7)/grub/splash.xpm.gz    # --- Equal to sda7/grub/splash.xpm.gz means /boot/grub/splash.xpm.gz
hiddenmenu
title Fedora 10 (2.6.27.5-117.fc10.i686)
        root (hd0,7)  # --- Partition where '/boot' exist for search 'Kernal' and 'initrd' images. 
        kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=c5b6e260-4732-45e9-b9a5-9f9b27991049 rhgb quiet
        initrd /initrd-2.6.27.5-117.fc10.i686.img
title Windows XP
        rootnoverify (hd0,0)
        chainloader +1
-----------
 * Here 'root=UUID=c5b6e260-4732-45e9-b9a5-9f9b27991049' (UUID of partition /dev/sda5)  or 'root=/dev/sda5'.Partition where root (/) file system exist.
 * Type 'vim /etc/fstab' to see 'UUID' of partitions. 

B)
* If linux completly installed in a single partition (Eg:sda5) then 'grub.conf' become look like
----------
default=0
timeout=5
splashimage=(hd0,5)/grub/splash.xpm.gz    # --- Equal to sda5/grub/splash.xpm.gz means /boot/grub/splash.xpm.gz
hiddenmenu
title Fedora 10 (2.6.27.5-117.fc10.i686)
        root (hd0,5)  # --- Partition where '/boot' exist for search 'Kernal' and 'initrd' images. 
        kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=/dev/sda5 rhgb quiet
        initrd /initrd-2.6.27.5-117.fc10.i686.img
title Windows XP
        rootnoverify (hd0,0)
        chainloader +1
-----------
* 'root=/dev/sda5' Partition where root (/) file system exist.


10) Checking 'menu.lst'.

sh-3.2#  vim /boot/grub/menu.lst
do step9

11) reboot your system If above steps are ok.Thanks

*********************************************************

No comments:

Post a Comment