2011-09-27

Reinstall Grub after Windows 7 erased it from the MBR

You just reinstalled Windows on your dual boot computer and it removed Grub, now you can't access to your Linux (Ubuntu in my case)... Here is how to fix that :

Boot on a Linux live CD/DVD or USB Stick

Let's assume my harddisk will be called /dev/sda

Make yourself root :
sudo -s


List your patition to identify the one which contains your Linux system
fdisk -l /dev/sda


Create a folder and mount your Linux on it
mkdir /mnt/mylinux
mount /dev/sda1 /mnt/mylinux (where 1 is the partition number of your linux system I identified before)

Check if you recognize your system :
ls -l /mnt/mylinux

Now we have to bind sys, dev and proc
mount -o bind /dev /mnt/mylinux/dev
mount -o bind /sys /mnt/mylinux/sys
mount -o bind /proc /mnt/mylinux/proc

Chroot to your system by typing
chroot /mnt/mylinux /bin/sh


Reinstall Grub properly
grub-mkconfig > /boot/grub/grub.cfg (menu.lst is you are using old Grub)
grub-install /dev/sda


Done !


Unmount everything and reboot :)
exit
cd /
umount /mnt/mylinux/dev
umount /mnt/mylinux/sys
umount /mnt/mylinux/proc
umount /mnt/mylinux/
sync
reboot

No comments:

Post a Comment

Popular posts