Feb 5, 2010
So, I recently had to fix an ubuntu install after Windows had been reinstalled onto the drive.. end result: of course Windows tromped over the MBR and wiped out grub, making the computer automatically boot into windows. The fix is to get booted into Ubuntu and reinstall grub. If you're a debian user, the best way I found to do this is:
- Download the Ubuntu liveCD for whatever version of ubuntu you are trying to fix. Don't forget to download the 64bit version if you're trying to fix a 64bit install of Ubuntu.
- Do a google search for the usb-creator package for a not quite cutting edge version of ubuntu. While it would be awesome if this package were in debian, I'm sure the demand for it is pretty low, since it seems to be an Ubuntu creation. I am running Debian Squeeze/testing, and had good results using the usb-creator from Jaunty, which can be found here. (It'd be nice if you could just dd the iso to the usb drive and have it work, but alas I tried that, and it does not boot.)
- Download and install usb-creator via dpkg -i
- Insert a USB disk that you don't mind getting wiped, run usb-creator, select your liveCD iso file and usb disk, click format, and then Create disk.
- Wait forever.
- Pop the USB stick into the busted machine, and boot from the usb drive into the first menu with the install options.
- Move the cursor over the first option for "Try Ubuntu Live CD without changes" and press <TAB> to edit the menu command. Replace the boot=whatever parameter with root=/dev/sdXY, where sdXY is whatever partition your Ubuntu install is on.
- Press <ENTER> and boot up into your Ubuntu install.
- Open up a terminal, run sudo bash to get to a root shell.
- Run update-grub to update your grub configuration file.
- Run grub-install /dev/sdX, where sdx is whatever drive you boot off.. probably sda. (NOT sda1)
Once that finishes successfully, you should be able to reboot the machine and grub will start up, allowing you to select what install you which to use. There might be an easier way to do this, but since I'm not a regular Ubuntu user, this is what I found through web searchs and trial and error. If someone has an easier way, please do fire me an email and I'll update this post.