Score:1

GRUB not loading properly when external SSD is disconnected

ss flag

I have an internal SSD on which I have my primary Windows installed. I also have an external SSD where I installed my secondary Windows and Ubuntu OS. I mostly use both the Windows OS and sometimes the Ubuntu. Since my second Windows is in the external SSD, if I need to boot it, I need to boot to Windows boot manager, then select one of the OS (I know about default os.) The issue here is that the computer gets restarted (It might have obvious reasons for that I guess) and then boots up into the secondary Windows OS. I could not find a way to make an OS selection before the initial boot so I decided to use the GRUB loader. Now I get the OS selection (and the grub customization which I liked a lot) before an initial loading and I can have a fast boot into my secondary windows and my Ubuntu too (Previously with the Windows boot manager, I had to go to the BIOS to boot into ubuntu). So to make things easier, I chose the Ubuntu loader as the top order in the BIOS boot order. So everything is perfect for me except when the external SSD is not present, I cannot log into my primary windows without going to BIOS. GRUB loading is failed and an empty full-screen linux terminal is what I get. I need to go to BIOS every time to load my windows. (Of course I can make the Windows boot manager on top but I don't want to go back.)

Things I understood so far.

  • When we install grub, grub gets installed onto the first EFI partition, but the /boot files are stored on my external SSD. So the GRUB loads but fails to load its configuration files as the external SSD is not present.
  • If anyhow I can move my GRUB configuration files onto the internal SSD, I can use the GRUB loader without the external SSD, and my primary windows can be loaded.
  • I read about installing grub on the internal EFI partition, But I cannot afford to lose any data on the internal SSD. Does installing GRUB on internal ESP remove any existing data on it? Will it affect the Windows boot manager? I don't want that. (I would go with this if it is "Add" and not "Replace").

My disk configurations are given in the picture. By the way, all the partitions in internal SSD are made by the laptop manufacturer. I never touched it. And all the partitions in external are made by me. Disk 0 is internal and Disk 1 is external.

Directory structure from Linux POV (First one is the external SSD)

Model: Samsung PSSD T7 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name                          Flags
 1      17.4kB  16.8MB  16.8MB                  Microsoft reserved partition  msftres
 2      16.8MB  367GB   367GB                   Basic data partition          msftdata
 3      367GB   367GB   273MB   fat32           EFI System Partition          boot, esp
 6      367GB   734GB   367GB   ntfs            Ext Shared                    msftdata
 7      734GB   839GB   105GB   ext4            Linux system
 5      839GB   983GB   144GB   ext4            Ub-Home
 4      983GB   1000GB  16.8GB  linux-swap(v1)  Swap                          swap


Model: PM9A1 NVMe Samsung 512GB (nvme)
Disk /dev/nvme0n1: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size    File system  Name                          Flags
 1      1049kB  200MB  199MB   fat32        EFI system partition          boot, esp
 2      200MB   334MB  134MB                Microsoft reserved partition  msftres
 3      334MB   493GB  492GB                Basic data partition          msftdata
 4      493GB   494GB  1038MB  ntfs                                       hidden, diag
 5      494GB   511GB  16.8GB  ntfs                                       hidden, diag
 6      511GB   512GB  1488MB  ntfs  

Image link (I'm sorry I cannot post images directly as I'm newbie)

Paul Benson avatar
us flag
What we really need is a partition listing from Linux's POV as you're booting from Grub. So please plug in and start the external disk, boot to Ubuntu and run and post the output of **sudo parted -l**. Copy the output from the terminal, then paste it here, remembering to highlight it, then hit the 'braces' icon. so it all lines up.
oraterlee avatar
ss flag
Sorry @PaulBenson I've edited the answer.
Paul Benson avatar
us flag
You missed out an important bit shown before the partitions listing. Without having to list them all again run *sudo parted -l* and tell me what is shown against the title 'partition table' for each disk. Can you also clarify exactly what you mean by the term "when the external SSD is not present'?
oraterlee avatar
ss flag
@PaulBenson Did so. Please not that I am having some severe issues now as I cannot boot into my original OS too without the external disk. The problem is I don't understand why this is happening. Who is deciding which drive to choose for boot configuration? How can I modify that? (But I can NEVER risk the PC not booting up. Any way I could learn this without hard issues?)
Score:1
cc flag

While it's certainly possible to install grub to your internal disk on a FAT partition (even the EFI), there is an easier way to almost get what you want (boot Windows when external SSD is not present, get grub and a choice of OS when SSD is attached). The basic problem is that both your Windows installs are bitlocker encrypted, so grub will not be allowed to boot them.

Copy all the files and directory structure from the internal EFI to the external EFI. Nothing needs to be changed. The only thing to check is that the EFI/Boot/bootx64.efi 's size is the same as EFI/ubuntu/shimx64.efi (or maybe grubx64.efi if you don't use secure boot). bootx64.efi is the default device bootloader, and that will give you grub's menu when run. The grub installer usually replaces the existing bootx64.efi (a copy of the Windows bootloader, with shimx64.efi. Now, check the internal disk's EFI/Boot/bootx64.efi's size, and ensure it is the same size as the internal disk's EFI/Microsoft/bootmgfw.efi. If not, there should be a "bkp" backup of the original, or just copy the bootmfgw.efi to the bootx64.efi to ensure it is a Windows boot.

Select how you want to boot:
If you put the external SSD first in the boot-order using your machine's UEFI settings for changing the bootorder, your machine will boot the external grub, and from it you can (only) boot Ubuntu. Override this to boot Windows by using the EFI menu (some key at powerup to allow you to select the device or Os to boot). Select Windows from the choices (or even the internal disk since it should have the bootx64.efi as a copy of bootmgfw.efi.

Put Windows second in the bootorder, so when the external SSD is absent, Windows will boot.

The internal disk's EFI/ubuntu files will no longer be used, but wont hurt anything if left there.


The external device's bootloader, ERI/Boot/bootx64.efi, you say is the same size as shim -- that's good. I like to have the file grubx64.efi in the same directory, but for 23.04 that didn't seem to be a requirement. The UEFI boot order should have the device at the top of the boot order, not the "ubuntu" entry. The "ubuntu" entry is in non-volatile ran (nvram), and deleting the UEFI files will not delete the nvram entry (which definitely cannot work without the files)


With bitlocker enabled, grub wont boot either Windows, so try putting the internal hard disk Windows first in the boot list, which should allow windows booting with or without the second disk -- no grub involved. To boot Ubuntu, when the second disk is attached, use the EFI menu key at powerup (some function key or del or esc...) to allow you to select device or Os to boot). Select Ubuntu from that (or device if the rootx64 default is shim/grub). grub should then run, and should be able to boot Ubuntu (but not Windows even if it is present in the menu, since bitlocker is enabled).


To repeat, I don't think you can boot a bitlocked Windows from grub, so if that's really what you want to do, consider disabling bitlocker on your Windows installs.

oraterlee avatar
ss flag
I'm sorry but this did not worked. I'm still getting a minimal bash window when boot up with ubuntu as the top order in UEFI settings. Is it because my computer still loads up with the old ubuntu boot files in the internal drive? Also one more thing is I saw both shimx64.efi and grubx64.efi in EFI/ubuntu. shimx64 was of the same size. but grubx64.efi was not. If I delete the ubuntu boot files in the internal, then my ubuntu option in UEFI will never come is that right? So I should not do that should I?
oraterlee avatar
ss flag
Now I am having serious issues. After copying, there were some random issues. I think my original windows boot up configuration is completely taken from external ssd than the internal. The computer now never works without the external ssd. Its a mess. How can I debug this? What is the proper way to check what the computer is loading and from where? How to change its behaviour according to my need? Where is the proper documentation for that? (It would be much helpful if I didn’t need to spend a lot of time to understand this by the documentation)
mchid avatar
bo flag
@oraterlee Can you still boot into Ubuntu? If so, boot up ubuntu and then run `sudo grub-install /dev/sdX` where `/dev/sdX` is the internal disk. For example, if your internal disk is `/dev/sda` and your external disk is `/dev/sdb` then you would run `sudo grub-install /dev/sda` to install grub to the internal disk. Then, run `sudo update-grub` and hopefully this will install everything correctly to your internal disk so that you can remove the external disk and still boot up the system.
oraterlee avatar
ss flag
No use @mchid, I tried adding boot entry manually. Located bootx64 entry in my internal and it don't even boot up. I am kind of stuck here. I think I shouldn't have copied the boot files at the first place
mchid avatar
bo flag
@oraterlee So you can't boot into Ubuntu? And if I understand correctly, you copied some files to your internal drive? If so, then replace the files that were in your internal drive back to normal.
oraterlee avatar
ss flag
I found the issue!. This answer is not correct. Initially my second OS boot files was present in the external drive. After copying the files as mentioned in this answer, the files of the second os was replaced by the first OS. But then somehow the grub updates the entries in UEFI boot list and entries pointing to internal boot files was removed. I manually added and now the primary windows loads up without external SSD. But I am unable to locate the boot files of the second OS as it has been replaced. How to recreate that? (I can boot into ubuntu @mchid)
mchid avatar
bo flag
@oraterlee The second OS is Windows? If you can boot into Ubuntu, just run `sudo update-grub` first to see if that fixes the issue. Later, if you want grub installed to the internal drive, you can tell grub to install to the internal drive using the commands in my previous comment.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.