GRUB Logo

Ubuntu Install – GRUB on the USB

It seems like only yesterday that I was installing Red Hat from floppy disks. Fortunately things have moved on a bit and now I generally install Ubuntu from a USB stick. The other day though I ran into a new problem. At the end of the process the installer asks if you’d like to install GRUB, I answered yes and unfortunately it proceeded to place GRUB on the USB install media.

I guessed what the problem was straight away, the installer had allocated /dev/hda to the USB stick and so the first hard drive, which was the target for the install, was /dev/hdb. I’m not sure why this arrangement was selected for the drives. I suspect the BIOS presented the USB stick as a hard drive through some clever emulation and because it was set to boot first from the stick Linux assigned it /dev/hda.

I’ve installed from USB a few times now and never seen this before so I tried messing with the BIOS options a bit but I couldn’t find a way to make the system boot from USB and assign it anything other than /dev/hda. Enough waffle though lets move on to the solutions…

The Fix I Used for GRUB on the USB

Insert the USB stick and boot as normal for an install and proceed through the process as usual. At some point it’ll load additional resources, after that point the USB isn’t actually required any more and can be safely removed – I remove the stick just before setting the clock. The next step after setting the clock is partitioning the drives but since the USB has been removed it’s no longer the first drive. At the end of the process GRUB will install on the first drive which is now you main hard drive.

Pick the Drive to Prevent GRUB on the USB

While I use the pull-the-stick-out fix that isn’t a very technical solution. The “correct” solution is to wait until the installer asks the question “Install the GRUB boot loader to the master boot record?” (the wording my be slightly different). At this point select what seems to be the counter-intuitive answer of no. You will be prompted to enter where you want to install GRUB, enter /dev/hdb. This will install GRUB on your main hard drive so that when you boot without the USB stick the machine will load correctly.

Move GRUB After Installation to fix GRUB on the USB

This is probably the most technically difficult fix but it does mean there’s no need to re-start the install process if you’ve accidentally install GRUB on the USB stick.

Insert the USB stick and boot the machine (it won’t boot without it). After booting log in to the machine and issue the command:

sudo grub-install /dev/hdb

Substitute your drive name where necessary obviously. GRUB will then be installed to the master boot record (MBR) of the correct drive. Shut down the machine, remove the USB and reboot.

Posted in Linux and tagged , .

Leave a Reply

Your email address will not be published. Required fields are marked *