MAC OS X, Linux, Windows and other IT Tips and Tricks

06 Feb 10 Recover Grub for Linux after Windows re-install

After I installed Linux Mint 8 with ext4 filesystem on /, I happned to have to reinstall Windows which whipped
out my grub Boot loader of Linux Mint 8 from MBR. So after I googled around I finally found a site that explains
how to recover a grub2 from an installed Linux. In my case Linux Mint 8 is using ext4 as root directory.
The following instructions were taken, and slightly modified to my situation, from:
Many thanks to him. On some systems like Suse the mounting of /proc and /dev may not be needed,
but in my experience it is needed in many cases. Only a chroot to the target system is not enough.
That was the clue that was missing in my many attempts to recover grub in MBR.

This method worked with me on a MAC Book pro where I had ReFIT as boot manager,
MAC OS X, Windows XP, Linux Mint 8 and Ubuntu 9.10 all in the same box which used MBR only.

The main principles are the following:

– boot another Linux, using either a LIVE CD/USB or another means(it must be able to handle ext4 if the target system is ext4)
– mount the Linux root partition in question (the one that needs its grub to be recovered)
– do some preparations before chroot (mount the live /dev and /proc inside the chroot)
– chroot to the mounted system
– issue the grub-install /dev/sda
– unmount everything methodically
– reboot

Here are the details:
# Boot a live system which can handle ext4 (if your Linux Mint is using ext4)
# Best is to boot the Linux Mint Original Install/Live CD/DVD
# Start a terminal

# Login as root
sudo su -

# make a list of partitions on the local hard disk
fdisk -l

This will show your partition table.Here is my table to understand it better :

/dev/sda1 29 8369 66999082+ 83 Linux
/dev/sda2 * 8370 13995 45190845 7 HPFS/NTFS
/dev/sda3 13996 14593 4803435 5 Extended
/dev/sda5 13996 14593 4803403+ 82 Linux swap / Solaris

# Assuming that we want to recover the grub of the Linux installed on /dev/sda1, here are the commands:
# Note: I’m using an extra subdirectory in /mnt instead of /mnt because many LIVE CD system are already using the /mnt.
# Mount the target system
mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1

# Prepare some needed components
mount --bind /dev /mnt/sda1/dev
mount --bind /proc /mnt/sda1/proc

# change environment to the target system
chroot /mnt/sda1

# re-Install grub in MBR
grub-install /dev/sda

# If you get some errors then you can run the following command
grub-install --recheck /dev/sda

Now you can exit the chroot, umount the system and reboot your box :

umount /mnt/sda1/dev
umount /mnt/sda1/proc
umount /mnt/sda1

Reader's Comments


    hello, thanks for this info you are the best, it’s help me to recovery my grub2 for linux mint 8.keep, up and the best regard.Mr KhaliD

    Reply to this comment

    also i wont to add a comend when you reinstall frub2 they just keep existing setting so they not boot windows tyo do that you mast do “update-grub” without cote to detect new operating system.thanks again.

    Reply to this comment

    Used this for Mint 10 and worked flawless. I think because I already had Windows in the bootlist before I reinstalled it, I didnt have to do what KhaliD is suggesting.

    Reply to this comment

    Thinking about it, I have several partitions with linux (ubuntu, mint 9, mint 10, etc.) installed. fdisk -l wont show me which one is what OS. Do you know how to find out what OS is installed on each partition?

    Reply to this comment

    thank you so much.. this works flawlessly with Mint 11 (Katya).

    Reply to this comment

    Thanks you are a blessing this worked wonderfully,but I just want to add If you don’t see the windows MBR just open the terminal and type this codes

    Sudo grub-update

    for Grub to find the windows boot loader..

    Reply to this comment


  1. problem installing debian 7.2

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: