Tuesday, December 8, 2009

Fix / Restore Fedora 15 GRUB Boot Loader

Unfortunately, maintaining a multi-boot configuration like this can be a pain, especially if you later install an operating system which overwrites the GRUB boot loader you had in place (such as a version of Windows). If your boot loader is overwritten, you could be left with no choice but to boot the most recently installed OS.

In this tutorial, I will show you how to restore an overwritten copy of the GRUB boot loader by using a Linux live CD. In this example, my master GRUB installation is on a Fedora 15 installation, and I’m using a Fedora 15 Live CD to boot the system.

Start the Live CD up as normal. Don’t choose to install the OS if prompted, you want to come to a full live desktop to run the specific commands we need.

1. Identify your Partitions


Open a Terminal program and use the following command:

[alexm@localhost ~]$ su
[root@localhost /]# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4b474b47

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 91394047 45593600 7 HPFS/NTFS/exFAT
/dev/sda3 91394048 402077695 155341824 83 Linux
/dev/sda4 402077696 976771071 287346688 f W95 Ext'd (LBA)
/dev/sda5 402079744 976771071 287345664 7 HPFS/NTFS/exFAT
[root@localhost /]#

If you can work out where your Linux is from this, note down the information under ‘Device’.
In this tutorial, Fedora 15 is installed in /dev/sda3

2. Run grub-install

[root@localhost ]# sudo -i

[root@localhost ~]# mount /dev/sda3 /mnt

[root@localhost ~]# grub-install --root-directory=/mnt/ /dev/sda
Installation finished. No error reported.
This is the contents of the device map /mnt//boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

# this device map was generated by anaconda
(hd0) /dev/sda
[root@localhost mnt]#

1 comment:

  1. If in case you can't access your Windows 7 system, restore the bootloader and perform the restoration of grub again.

    To restore the Windows bootloader, get the dvd. when you get to the second screen (after you choose your language) go to repair your computer.
    go to command prompt and type the following commands:

    1.C:\>bootrec /fixmbr

    2.c:\>bootrec /FixBoot

    Reboot

    ReplyDelete