0

I've tried other solutions I found online (including here), and none of them worked, and looks like no 1 has an answer for what is seemingly supposed to be a simple thing to do.

If you have the answer please guide me completely with specific commands because I will not be able to do it alone, I am not that high level in Linux/Ubuntu.

I have 2 SSDs:

  • First is a 250GB SSD with only Windows 10 installed on it.
  • Second is a 500GB SSD originally installed with Windows 10. Then I shrank 200GB of it for Ubuntu (20.04).

I specified the boot drive during installation to be sdb, which is the 500GB, but it still installed GRUB inside sda1(/boot/efi) partition, alongside Windows Boot Manager of sda.

Using GPT

I tried the grub-install method (grub-install /dev/sdb) - it showed some output in terminal, but after the restart, the situation is the same: the boot partition remains in sda with GRUB in it.

How can I move GRUB to the correct partition on sdb? Either alongside Windows Boot Manager of sdb (as it is now with sda), or maybe on a different partition on sdb.

I do not want to physically unplug the 250GB and then install Ubuntu, I want to solve it in a way that won't make me open the PC case every time I want to format my PC

Foobarer
  • 367
  • 1
  • 8
  • 16
  • Is install UEFI, so then do you have an ESP - efi system partiiton on sdb. Ubuntu's Ubiquity will only install grub to first drive. Just reinstall grub use Boot-Repair, but have to change fstab to UUID of ESP on sdb. Or if new install see this for several work arounds: https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1396379 and more details: https://askubuntu.com/questions/1296065/dual-booting-w10-ubuntu-with-2-separate-ssds-in-uefi-mode/1296153#1296153 & https://askubuntu.com/questions/16988/how-do-i-install-ubuntu-to-a-usb-key-without-using-startup-disk-creator/1056079#1056079 – oldfred Apr 17 '22 at 21:26
  • @user68186 no because I do not want to unplug drives – Foobarer Apr 17 '22 at 21:31
  • Does your bios support booting from sdb? If not, you can't move grub there. – user10489 Apr 17 '22 at 22:00
  • I can boot from either of the SSD's Windows Boot Managers (But not sure if it's the same) – Foobarer Apr 17 '22 at 22:07
  • Is't this a matter of reinstalling grub, but select the other drive to install to? – vanadium Apr 18 '22 at 08:29
  • @vanadium It may be possible to reinstall grub in a newly created EFI System Partition (ESP) in the correct drive. But one will have to create the partition first. After reinstalling grub one should also delete the parts of grub in the old ESP in the drive with Windows. – user68186 Apr 18 '22 at 15:19
  • @user68186 this is only for pre-installation, I already installed – Foobarer Apr 18 '22 at 16:17

1 Answers1

0

Your problem was caused by a longstanding bug in Ubiquity. In brief, Ubiquity (the Ubuntu Desktop installer) ignores the specification of the disk to which GRUB should install when you install in EFI mode. That information won't really help you fix the problem, but it's worth knowing. There are a couple of ways of changing your boot disk as you want....

The Easy Solution

The Boot Repair tool should be able to do this semi-automatically. It's been a while since I've used Boot Repair, so I can't provide step-by-step instructions, but it should be able to install GRUB 2 on your /dev/sdb. I'm not 100% sure that it will change what's mounted at /boot/efi in Ubuntu, though. It may also fail if your /dev/sdb doesn't have an ESP or if the tool runs into any other unexpected pitfalls.

The Hard Solution

To solve the problem manually, you should first verify that your /dev/sdb has an EFI System Partition (ESP). This is easily done with various partitioning tools; for instance, with gdisk, you'd list the partitions and look for a partition with a type code of EF00:

$ sudo gdisk -l /dev/sdb
GPT fdisk (gdisk) version 1.0.9

Partition table scan: MBR: protective BSD: not present APM: not present GPT: present

Found valid GPT with protective MBR; using GPT. Disk /dev/sdb: 15628053168 sectors, 7.3 TiB Model: TOSHIBA HDWF180 Sector size (logical/physical): 512/4096 bytes Disk identifier (GUID): A29BEED8-295E-48F3-A7E5-2C1C669A0226 Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 15628053134 Partitions will be aligned on 2048-sector boundaries Total free space is 2014 sectors (1007.0 KiB)

Number Start (sector) End (sector) Size Code Name 1 2048 1128447 550.0 MiB EF00 Unused ESP 2 1128448 3225599 1024.0 MiB 8300 Unused /boot 3 3225600 15628053134 7.3 TiB 8E00 Linux LVM

This example is taken from one of my computers, and it shows an ESP on /dev/sdb1 with the name Unused ESP. Yours likely would not have that name. If you see an ESP, you should double-check that it has a FAT filesystem with the blkid utility:

$ sudo blkid /dev/sdb1
/dev/sdb1: PARTLABEL="Unused ESP" PARTUUID="94c47102a617-4224-9f29-5779220d4b7f"

This example shows that the partition has no filesystem -- they're normally explicitly identified, as in this example on the same computer:

$ sudo blkid /dev/nvme0n1p1
/dev/nvme0n1p1: LABEL_FATBOOT="NVME_SSD" LABEL="NVME_SSD" UUID="6CB1-160F" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="5f63fbfe-1a11-4ed8-80ff-13f1df6f04c0"

Note the TYPE="vfat" description in this case; this ESP (I haven't shown the gdisk output on the NVMe device, but it's got an EF00 type code) is ready for use -- in fact, it's how this particular computer boots.

In any event, if your /dev/sdb has an ESP and if it uses FAT, then it's ready to go. If not, then you'll have to set up an ESP on the drive. That's a whole other issue, so I won't go into it here. Since you say the computer originally booted Windows 10, chances are it has an ESP, but I can't be certain of that, so you should check this detail.

Because your Ubuntu installation is using the ESP from /dev/sda now, you need to change that, and not just for the GRUB installation. You need to edit /etc/fstab: Find the line that defines /boot/efi and alter it to refer to the ESP on /dev/sdb, rather than the one on /dev/sda. For instance, your current /etc/fstab might have a line like the following:

# /boot/efi was on /dev/sda1 during installation
UUID=6CB1-160F            /boot/efi            vfat    umask=0077  0  1

Note that in this example, the ESP is identified as having UUID=6CB1-160F, which is the same UUID code that sudo blkid /dev/nvme0n1p1 showed earlier. (Technically it's not a UUID, but that's another matter....) In your case, I'd expect the UUID to match what blkid shows as being on your /dev/sda1. Use the output of the blkid command on the ESP on /dev/sdb to find the UUID of that partition. For instance, suppose the new ESP's UUID is 66F7-FD24. You'd edit the line in your /etc/fstab to read:

UUID=66F7-FD24            /boot/efi            vfat    umask=0077  0  1

Save the changes, type sudo umount /boot/efi, and then sudo mount -a. Your /dev/sdb ESP should now be mounted at /boot/efi, which you can verify with df /boot/efi:

$ df /boot/efi
Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/sdb1         562080 14124    547956   3% /boot/efi

Your Linux installation has now mounted the ESP from /dev/sdb on /boot/efi; however, GRUB is still not installed there. Fortunately, that part is easy:

$ sudo grub-install

Under EFI, it's my understanding that grub-install ignores the device specification; instead, it installs GRUB to /boot/efi and sets up an EFI BootOrder variable to match. (A caveat: I use my own rEFInd on most of my computers, not GRUB 2, so I'm less familiar with the grub-install details, and I may be missing something. The documentation isn't exactly crystal-clear on this detail.)

You may want to use efibootmgr to verify the change. Type sudo efibootmgr and check that the first item in BootOrder is not the same as the BootCurrent line; but both of them should be ubuntu items. For instance, here's some output:

$ sudo efibootmgr
BootCurrent: 0000
Timeout: 1 seconds
BootOrder: 0004,0000,0006,0007,0008,0001,0002,0003
Boot0000* ubuntu
Boot0001* UEFI:CD/DVD Drive
Boot0002* UEFI:Removable Device
Boot0003* UEFI:Network Device
Boot0004* ubuntu
Boot0006* UEFI OS
Boot0007* Hard Drive
Boot0008* CD/DVD Drive

In this example, the computer is currently booted through Boot0000, but it will boot next time through Boot0004. Both are ubuntu items, which point to GRUB 2 on the ESPs on /dev/sda and /dev/sdb, respectively. You can add -v to the efibootmgr command to see more details, like this:

Boot0000* ubuntu    HD(1,GPT,5f63fbfe-1a11-4ed8-80ff-13f1df6f04c0,0x800,0x114000)/File(\EFI\UBUNTU\SHIMX64.EFI)

The long string of hexadecimal numbers (5f63fbfe-1a11-4ed8-80ff-13f1df6f04c0) is a GUID, which should match the PARTUUID reported by blkid, as this one does for my computer's /dev/nvme0n1p1, shown earlier.

After rebooting to be sure it's working, if you want to be thorough about this, you can mount the ESP for your /dev/sda somewhere convenient (like /mnt) and delete the EFI/ubuntu directory on that partition. This will eliminate the duplicate GRUB 2 installation.

Rod Smith
  • 44,284
  • 7
  • 63
  • 105