1

The short version: Every Ubuntu installation I do has the bootloader going to my Windows hard drive, despite me specifically selecting the separate hard drive during installation and now I'm stuck with an option in my UEFI boot menu (launched by holding F8 at boot) called "ubuntu". This boot option is apparently located on my Windows hard drive. I can however boot into Windows just fine by selecting the Windows Boot Manager option.

Here's the context as it might help understand how I got into this situation:

I recently got a new gaming PC with a 1TB SSD running Windows and a 2TB Hard drive. I used to be exclusively an Ubuntu user so I had to go and install Ubuntu on my second 2TB hard drive. I started with Xubuntu, adding 3 partitions to my empty 2TB hard drive. One for boot, one for root and one for home. I also selected the empty 2TB hard drive for the bootloader.

This didn't work because of a bug with "rsyslog" filling my usb during installation, but with the help of the internet I tried again after disabling it, formatting the same 3 partitions and using them for the same purposes. Boot, Root and Home with the 2TB hard drive as the bootloader.

Then I needed to boot the kernel with "pci=noaer" set because of some PCIE-bus errors preventing me from booting or making it super slow.

This worked but I realized on this bigger screen that I don't like Xubuntu much so I decided to switch to standard Ubuntu to see how Gnome runs on this machine. I followed the exact same steps that I've stated above, and installed Ubuntu.

So now we've reached where I'm currently at: I have an Ubuntu installation on my 2TB hard drive, with the bootloader apparently (according to the boot menu of my PC) installed to the other hard drive that holds my Windows installation. The Ubuntu installation has loads of weird quirks, like asking for my password 3 times every time I login or use the terminal.

What's gone wrong here, and how can I properly remove Ubuntu bootloader from the Windows drive, so that it no longer shows in my boot menu, so that I can wipe the second drive and attempt to get Ubuntu finally installed.

Here's a screenshot of the drives in disk management under windows: r

Kupo
  • 141
  • I'm stuck with an option in my boot menu (not the grub one) called "ubuntu" mmh I think you are referring to the BIOS/UEFI settings. That's not on your hard drive. Or did I misanderstand you? – schrodingerscatcuriosity Aug 23 '19 at 22:53
  • Not the settings themselves, I'm not sure the exact name of the menu, but I think it is UEFI. It lists everything I can boot from. To launch it I hold F8 at boot. I'll correct terminology in the main post as needed, sorry! – Kupo Aug 23 '19 at 22:56
  • 1
    Yes, that's a BIOS/UEFI setting, it's the "software" of your motherboard, not dependant of the hard drives you may have. When you installed Ubuntu, it registered the OS in it's entries of bootable options. Take a look at this or this to remove the entry. Be cautious about it, if in doubt google ubuntu remove uefi entry and find the answer that suits you. – schrodingerscatcuriosity Aug 23 '19 at 23:11
  • I just removed grub from the EFI part of the Windows drive, and then booted into a live-usb Ubuntu and used "efibootmgr" to remove ubuntu from the UEFI settings menu. I rebooted back into that menu to double check it had gone, and yeah, it worked!! ...However, I've just formatted that second drive, set up 3 partitions again, re-installed Ubuntu, DEFINITELY selected to install the bootloader to drive 2 (the empty one, that doesn't have Windows) and it's back again, apparently installed to the first drive with Windows. If I click "ubuntu" it loads, if I click the drive I get grub recovery! Ugh – Kupo Aug 24 '19 at 01:18
  • Is there a way I can move grub over to the second hard drive, the one where the Ubuntu I'm typing this from is installed, and then use efibootmgr to remove the duplicate entry? – Kupo Aug 24 '19 at 01:20
  • Disable CSM (legacy boot) in your UEFI settings, you want to boot in UEFI-mode only. UEFI displays the "drive" as boot-option when legacy-boot is enabled and a boot-loader in an MBR exist. – mook765 Aug 24 '19 at 07:21

2 Answers2

0

See launchpad bug # 1396379 and bug # 1174357 for workarounds to the problem of the installer ignoring user input for bootloader location. Add yourself to the bug's "Does this affect me?". Basically the suggestion to install from the "try Ubuntu" desktop, start a terminal, and in a timely manner during the install, unmount the /boot/efi from the Windows disk and remount the EFI from the second disk.

Where you have already written to the first disk's EFI, just copy all the files from the first EFI to the second EFI. The Windows bootloaders are not needed, but a good backup. The ubuntu setup has a ...EFI/ubuntu.grub.cfg which refers to the ubuntu root on the second disk, so will work. The second disk's EFI also should have a device bootloader in ...EFI/Boot/bootx64.efi which should be either shimx64.efi or grubx64.efi depending upon if you installed with secure boot on). Check the size to see which bootx64.efi is. If it is shimx64.efi, there needs to be a copy of grubx64.efi in the same directory (EFI/Boot).

With the second disk booting successfully by selecting the device, you may remove the unwanted "ubuntu" entry in the EFI menu with efibootmgr. Simply delete the EFI/ubuntu... directory and files if you want, but they are a backup to the second disk's EFI.


Copying the first disk's EFI files to the second disk's EFI.

Assuming you set-up or made an EFI partition on the second disk, and formatted it with a FAT filesystem, you should have an empty filesystem on the second EFI, regardless of what you specified to the installer as the bootloader location. Lets assume the EFI partition is the first on the second disk so we will refer to it as /dev/sdb1 below -- adjust if you use a different disk letter or partition number. All the UEFI bootloaders are just files, and may be copied with normal file copy tools. You should be able to boot the ubuntu on the second disk, using the first disk's EFI bootloaders. The running system will have mounted the first disk's EFI partition at /boot/efi -- this is the source of the files to copy. For mounting the second disk's EFI, use /mnt, or if /mnt is already used for anything else, make a directory in /mnt and use that for the mount.

sudo mkdir /mnt/secondefi

Mount the second disk's EFI:

sudo mount -tvfat /dev/sdb1 /mnt/secondefi

Copy all the files from the first EFI partition to the second one

sudo cp -r /boot/efi/* /mnt/secondefi

The second disk now has a fully populated EFI partition. The EFI/ubuntu/grub.cfg file always had the UUID of the Ubuntu root partition on the second disk, (causing grub to fail if this second disk is not present), so no change is necessary.

To complete the setup of the second disk, edit the /etc/fstab entry for the /boot/efi entry to use the UUID of the second disk's EFI. Pick out the second disk's EFI UUID (Not the PARTUUID) from the output:

sudo blkid

Cleanup of the installer bootloader creation. The installer will have done several things incorrectly:

1) Created an firmware entry for ubuntu pointing to the fist disk's EFI. No entry is needed when booting the (properly set-up second disk). You may delete this entry with efibootmgr, or leave it if you are leaving the bootloaders in the first disk's EFI alone.

2) The EFI/ubuntu directory on the first disk's EFI may be deleted. If you do this, you should also delete the firmware entry.

3) The first disk's EFI default/devce botloader, EFI/Boot/bootx64.efi, has been replaced with grubx64.efi (or shimx64.efi). This bootloader should normally not be used, but might be invoked as a fallback in some cases. The original Windows bootloader EFI/Microsoft/Boot/bootmgfw.efi may simply be copied back to EFI/Boot/bootx64.efi, or the backup file ...bkp copied back to bootx64.efi.

ubfan1
  • 17,838
  • I really, really, really appreciate this answer. I had no idea it was a bug and I was worried I'd borked my new machine. Where can I get more detailed info on what to copy? I can probably figure it out from that, and will try as a last resort, but more info would be helpful. Thank you by the way! – Kupo Aug 24 '19 at 01:55
  • 1
    Some more info: https://askubuntu.com/questions/1167910/unable-to-properly-boot-linux-from-external-ssd/1167940#1167940 and link to bug: Posted work around to manually unmount & mount correct ESP during install https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1396379 Generally you must partition in advance. Disconnecting, either logically or physically, the internal drive, so only external seen also works. Some now find Boot-Repair correctly reinstall grub, as it is Ubiquity installer that is the bug, but drive must be gpt with ESP. https://help.ubuntu.com/community/Boot-Info – oldfred Aug 24 '19 at 03:35
  • I just deleted boot on both drives somehow but copied over Ubuntu, because the second drive still wasn't letting me boot from it, even after adding the UUID... I've double checked and I can still boot into Windows, and into my Asus settings, will what I've done effect windows at all and if so, can I fix it? I did Bork the Ubuntu installation though, so I'm re-installing that now and I'll try again asap – Kupo Aug 24 '19 at 06:41
  • The only UUID to change would be in /etc/fstab on the /boot/efi mount, which is totally irrelevant to booting, just to allow the possibility of a grub or shim update. The initial install to disk 1's EFI used the correct UUID for the Ubuntu root on disk2 in EFI/ubuntu/grub.cfg. – ubfan1 Aug 24 '19 at 15:15
  • Okay, finally I've made progress!! Now both of the drives EFI partitions have the same files, I've noticed on my acer UEFI settings menu however I have the main drive listed ("sda" with Windows), the second drive listed ("sdb" with Ubuntu, won't boot), the duplicate Ubuntu I had originally that points to the Windows "sda" drive but now I have a SECOND duplicate Ubuntu that points to the Ubuntu "sdb" drive and DOES boot. I'd like to just have the sda and sdb drives with no Ubuntu duplicates. I don't understand what I'm doing so I'll wait for a reply, but what can I do to achieve that from here? – Kupo Aug 24 '19 at 22:08
  • Search this site for remove a UEFI entry and you'll find the answer. use efibootmgr, or maybe even just the UEFI settings boot order. – ubfan1 Aug 24 '19 at 23:05
  • but if I remove the duplicates, I'll be left with the original second drive entry that boots me into a grub recover screen – Kupo Aug 24 '19 at 23:24
  • Check the second disk's grub.cfg in the EFI partition for using the UUID of the Ubuntu root. When running, the EFI is mounted at /boot/efi, so look at /boot/efi/EFI/ubuntu/grub.cfg and confirm the UUID on the first line is the root's (sudo blkid to list the UUIDs). – ubfan1 Aug 25 '19 at 00:16
0

run: "MSConfig" ==>> [Boot] ==>> click on "Grub Boot Loader".[Delete]. [Save].