Laptop boots to grub command line after installing to external hard drive
I recently installed ubuntu to a 1TB external hard drive. I made sure to partition correctly and I chose the correct grub location, but it still somehow installed grub onto the base hard drive. There is now an ubuntu option in the boot order and I had to manually move it down one to boot. I would love the ubuntu boot order to stay there but only boot to grub when the external hard drive is plugged in. If that isn't possible I'm fine with manually selecting to boot it in the f12 menu. I just want it to be somewhat hidden and easy to access. If the ubuntu option is at the top of the boot order it boots to the grub command line with no option to boot to windows. I can choose windows bootloader and ubuntu when the external hard drive was plugged in but when it isn't it stays at the command line.
Solution 1:
Ubuntu's Ubiquity only installs to ESP on first drive, usually your internal drive.
You need an ESP - efi system partition on external drive, reinstall grub to external drive and make that default with Windows as second in UEFI boot order.
Use gparted to create ESP, FAT32 100 to 500MB with esp, boot flags. Then use Boot-Repair to reinstall grub using advanced mode.
https://help.ubuntu.com/community/Boot-Repair
Advanced mode screens, choose install & external drive's ESP.
https://sourceforge.net/p/boot-repair/home/Home/
Please add to this bug which shows several work arounds when installing to external drive.
Posted work around to manually unmount & mount correct ESP during install #55 or( #23 & #26)
https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1396379
Others suggest disconnecting all other drives physically or logically in UEFI settings, so install drive is first drive. Or removing boot flag/esp flag from first drive, so only ESP is install drive. (I have not had that work, but others have.) Or if you have ESP on second or external drive, you can just reinstall grub, either manually or using Boot-Repair's advanced mode & full reinstall of grub to correct drive.
Remove esp flag from Windows before install to second or external drive - Tim Richardson, also shown in bug report.
How do I install Ubuntu to a USB key? (without using Startup Disk Creator)
Check current order & hex number of each entry:
sudo efibootmgr -v
Change boot order with efibootmgr, some require all 4 hex char others 1 is ok.
sudo efibootmgr -o 0,1,2
see also
man efibootmgr
Change boot order using efibootmgr