Home » Questions » Computers [ Ask a new question ]

Ubuntu 9.10: grub2 installed on the wrong partition, no booting... (MacBook)

Ubuntu 9.10: grub2 installed on the wrong partition, no booting... (MacBook)

I recently installed Ubuntu 9.10 on my macbook, hoping to create a dual boot system... I use rEFIt to boot.

Asked by: Guest | Views: 290
Total answers/comments: 1
Guest [Entry]

"There's a good Grub 2 Guide on Ubuntu Forums; this is what I used during my recent Grub2 adventure. Here's another good Grub2 guide, and Ubuntu's Grub2 wiki page.

You ""uninstall"" Grub from a partition by overwriting the boot code it wrote into the boot sector of that partition. Ideally, you'd have a backup of what was there before Grub was installed to it. I don't believe Grub creates this backup for you, so if you want something particular there (other than Grub), you'll need another tool to provide it.

If you want, you can completely uninstall the Grub package, then reinstall (I doubt this is necessary). To do this from a LiveCD system you'll need to chroot into the system you're trying to fix.

# chroot (assumes you've mounted the partition to fix to /mnt)
sudo mount --bind /dev /mnt/dev
sudo chroot /mnt

# backup!
cp /etc/default/grub /etc/default/grub.old
cp -R /etc/grub.d /etc/grub.d.old
cp -R /boot/grub /boot/grub.old

# purge
apt-get purge grub2 grub-pc

# reinstall
apt-get install grub2 grub-pc

# grub install -- make sure /dev/sda is the right drive!!
grub-install /dev/sda4
update-grub

If everything went well, you can exit your chroot, unmount your filesystems (/mnt/dev first), and reboot.
If all you need to do is install Grub to the correct partition, all you really need to do is boot into a LiveCD/LiveUSB, mount your system partition, check that your system's /boot/grub is correctly set, and run grub-setup. If you need to reconfigure the Grub menu or perform other steps, use a chroot procedure as described earlier.

Let's assume you've booted the LiveCD and mounted your system drive to /mnt. Check that /mnt/boot/grub exists, and contains the proper files (a bunch of *.mod files, a few .img files, and grub.cfg). If so, run this (not from chroot):

# install grub to partition boot sector on sda4
# this assumes the partition table you show is on /dev/sda
# make sure path & device are correct !!!
sudo grub-setup -d /mnt/boot/grub /dev/sda4

(Source: Re-install GRUB 2 from a Live CD without chroot)"