Restore GRUB bootloader after Windows installation on multi-boot system

Friday, May 4, 2012 posted by CSch

Windows operating systems have the habit of installing their own bootloader on every installation – this wouldn’t be a problem, if they would recognize all present operating systems. But unfortunately, they only recognize other Windows systems.

Apart from installing EasyBCD and other tools on your Windows partition to set things right, you can also just reinstall the lost GRUB boot manager with the help of a live CD (I used Ubuntu 11.10 for that). Insert the CD and boot from it. Open a terminal. If you have no idea what the name of your partitions is, use

fdisk -l

to get an overview. My output looks like this:

christian-main christian # 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: 0x000587d5
.
Device Boot Start End Blocks Id System
/dev/sda1 63 629147647 314573792+ 83 Linux
/dev/sda2 * 629147648 775948287 73400320 7 HPFS/NTFS/exFAT
/dev/sda3 775948288 968380415 96216064 7 HPFS/NTFS/exFAT
/dev/sda4 968382196 976768064 4192934+ 5 Extended
/dev/sda5 968382198 976768064 4192933+ 82 Linux swap / Solaris
christian-main christian #

My first partition, /dev/sda1, has Linux installed and is the partition I want to have GRUB on – what I need is its identifier, sda1. Replace every following instance of that identifier with the one of your partition’s identifier. Become root by typing

sudo -i

Afterwards mount your partition and install grub (replace sda1):

mount /dev/sda1 /mnt
grub-install –root-directory=/mnt/ /dev/sda

If there is no grub.cfg in /boot/grub, create one using

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

Afterwards you can restart your system, remove the Live CD and boot into GRUB.

Be Sociable, Share!


6 Responses to “Restore GRUB bootloader after Windows installation on multi-boot system”

  1. Ryan says:

    Thanks for this.Everything I’ve found online is telling people how to eliminate GRUB.I’m moving away from windows,deleted Win7 and it left behind the windows bootloader that I do not want.I’ve been searching for a day looking for an answer but it’s all pro windows bootloader out there.I’ll give this a shot and see how it goes.Thanks for the info!

  2. Miguel says:

    Thank you for the guide! I am very grateful for it! There are some changes in Ubuntu 12 that require a slightly different command (I used Xubuntu 12.04 Live CD). The command “grub-install –root-directory=/mnt/ /dev/sda” didn’t work for me: first, that command isn’t understood by the terminal; second, it creates a folder called grub in / of my linux partition (the grub folder should be in /boot/). I used “grub-install –boot-directory=/mnt/boot/ /dev/sda” to put the grub folder where it belonged. Other than that, the guide was wonderful.

    Hopefully this comment saves someone in the future a few minutes of time. Best, M.

    • kevnuke says:

      Another small more about that version of Ubuntu, for Linux Mint 12 which I believe is Ubuntu based, correct me if I’m wrong. You have to become root BEFORE attempting to fdisk -l or it will simply return nothing. At least on my live DVD anyway.

  3. Hadi Tjandrasa says:

    I have just upgraded my XP Pro to Windows 8 Pro with Scientific Linux on the same SATA drive. Windows wiped out the grub (dual boot menu).

    Here is what I did to restore the grub:
    Boot from a Live CD.
    % “df” to see where Linux is installed (/boot mounted) – mine was on sda7.
    % “sudo grub” to run grub
    grub> find /grub/stage1 — You will get an printout/output
    Output: (hd0,6) — This is my 1st SATA drive at sda7 partition
    grub> root (hd0,6)
    Output: Filesystem type is ext2fs, partition type 0×83
    grub> setup (hd0)
    You should get “checking ……’ printouts
    ….. succeeded
    Done.
    grub> quit

    Reboot

  4. rvperez says:

    it appear

    grub>

    i dont know to do

    somebody could help me?
    thanks

  5. Knuckl3head says:

    Thanks for this guide, though for me at this time it would be easier to remove Windows 7 (Technically 6.1.7600) Bootloader using Windows, but no chance of that at all.

Leave a Reply