Rebuilding Grub2 grub.cfg from Ubuntu Live CD
// January 1st, 2010 // Linux
After installing Windows 7 the other day I lost my Grub install. Not a problem, in the past I’ve used my Super Grub Disc to repair it.
This didn’t work for me though (may be my disc is a bit date, or maybe it doesn’t support grub 2 just yet). Instead I booted up using my Ubuntu 9.10 Live CD. I could easily re-install grub using the “grub-install” command.
- Open up a terminal
sudo fdisk -l(Find the partition you want)sudo mount /dev/sda5 /mnt(Mount the partition)sudo grub-install --root-directory=/mnt /dev/sda
I’ve used the drive /dev/sda and partition /dev/sda5 in my example.
This all went ok, but I was left with a screwed up grub menu (I messed it up myself). There’s a “update-grub” command you can do from within Ubuntu, but I couldn’t actually boot in. I only had the Live CD. Hence updating it proved to be quite difficult, and there’s nothing on the Live CD to help. I eventually found a solution, these are the commands I had to run in order to regenerate it.
mkdir /mnt &&
mount /dev/sda5 /mnt &&
mount -o bind /dev /mnt/dev &&
mount -o bind /proc /mnt/proc &&
chroot /mnt bash &&
sudo update-grub &&
reboot;
Without binding the /dev and /proc it would throw an error.
All credit goes to seeker5528’s post for the above solution.