Pages

Thursday, January 13, 2011

Restoring GRUB2

PROBLEM: Restoring the Grub2

INFORMATION: This post is for the dual-boot people who find their booting screen has been missing some operating system after fresh installation of fresh Ubuntu(grub2)/Windows 7.

NOTE: The steps given for restoring grub2 are for Ubuntu version later than 9.10 .

STEPS:

Restoring Grub2(Ubuntu 9.10 or later)

1)  Boot with bootable pen-drive or cd of Ubuntu.

2) Type this in terminal

sudo fdisk -l

Output:
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf4caf4ca


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20482843+  42  SFS
/dev/sda2            2551        9730    57666845   42  SFS


Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x329e329d


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sdb2              14        1810    14432040    7  HPFS/NTFS
Partition 2 does not end on cylinder boundary.
/dev/sdb3            1913        9729    62785769+   5  Extended
Partition 3 does not end on cylinder boundary.
/dev/sdb4            1810        1913      824040   82  Linux swap / Solaris
Partition 4 does not end on cylinder boundary.
/dev/sdb5            1913        4023    16949488+  83  Linux
/dev/sdb6            5929        9167    26006368+   7  HPFS/NTFS
/dev/sdb7            9167        9729     4520848+   7  HPFS/NTFS
/dev/sdb8            4023        5929    15307776   83  Linux



The above output shows presence of 2 hard-disks . One /dev/sda and other one being /dev/sdb.
I have 2 linux partition present(Ubuntu 11.10-(/dev/sdb8) & Ubuntu 11.04:(/dev/sdb5))

3) Check your partition on which your Ubuntu is installed. I am using /dev/sdb5

4) Make a directory in /media using the command:


sudo mkdir /media/sdb5

5) Now mount your partiotion into above created directory

sudo mount /dev/sdb5 /media/sdb5

6) To install your grub on your drive use grub-install as follows. Note: /dev/sdb is used as it is the boot partition (look at the fdisk output)

sudo grub-install --root-directory=/media/sdb5 /dev/sdb

7) If you miss “grub.cfg” file,use following to recreate:

mount --bind /proc /mnt/proc
 mount --bind /dev /mnt/dev 
mount --bind /sys /mnt/sys 
chroot /mnt update-grub 
umount /mnt/sys 
umount /mnt/dev 
umount /mnt/proc

No comments:

Post a Comment