This is how I recover Grub2 after Windows successfully overwrites my mbr. I also use this method to fix my grub config after a failed install. This usually only happens when I use /dev/sdx names over UUID's. On some motherboards simply rearranging your HDD boot order will offset the entire /dev/sdx order as well. Making your Grub entries useless, not really a big issue since you can correct the entries directly from the grub menu. Anyway lets move onwards.
Boot up your livecd/usb of choice, preferably one that is up to date. And proceed to mount your needed directories.
First mount your root partition:
$ mount /dev/xxxx /mnt
Mount your boot partition if needed:
$ mount /dev/xxxx /mnt/boot
Now we need to bind a few essential directories otherwise we wont be able to properly install grub during our chroot session:
$ mount -t proc none /mnt/proc
$ mount -o bind /dev /mnt/dev
$ mount -o bind /sys /mnt/sys
Chroot into your root partition directory:
$ chroot /mnt
This command will install Grub2 to the mbr of the chosen device. Remember to choose the base device eg. “/dev/sdx” and not a partition eg. “/dev/sdx1”. Choosing the latter will simply install Grub2 on to that particular partition which will not help us boot at all, unless that partition is specifically configured for booting.
$ grub2-install /dev/xxx
You should be able to update your grub entries as well from here. I strongly recommend configuring Grub2 to use UUID's, which I believe is the default Grub2 setting.
$ grub2-update
Now you should be able to simply reboot and enjoy choosing which operating system to boot with Grub2.
No comments:
Post a Comment