Ubuntu Server installed from USB puts GRUB on the USB drive instead of the hard disk

grubinstallationUbuntuusb

I've just tried installing Ubuntu Server onto my new PC. The PC doesn't have a CD ROM drive, just USB, so I used a USB installation of Ubuntu Server.

When I install it, it allocates dev/sda as being my USB pen, and dev/sdb as my hard drive.

I set up my partitions on the hard drive including boot and swap partitions, yet at the end of the installation, Ubuntu installs GRUB on my USB pen, so the system won't boot unless I boot from my USB pen.

How can install GRUB to the hard drive so I can remove my USB pen completely?

Best Answer

You can manually install GRUB onto a device if it was installed to the wrong place by issuing

sudo grub-install /dev/sdX

after booting and logging into your Ubuntu installation if that is even possible (as it seems from your question).

However if it's not possible to boot the OS you can use "Rescue a broken system" at the USB drive's startup menu to install GRUB. Just follow the instructions to set up keyboard and timezone and then mount your root partition. Then when asked choose to Execute a shell in /dev/sdXY. If you have created a separate partition which shall be mounted at /boot you have to mount it manually using that shell (else the installation of GRUB won't work as expected because it will not find your kernel image):

mount /boot

And then install GRUB using:

grub-install /dev/sdX

Then exit the shell (Ctrl+D) and choose reboot from the menu. Now everything should work as expected.

side note:
The Ubuntu Desktop Edition provides an advanced configuration option (which lets you set where GRUB is installed to) right before installing the OS. But I couldn't find an equivalent option in the Server Edition's installation process and it seems to always install GRUB to the first disk device. Or maybe I also just overlooked it.

Related Question