1

Setup:

  • Multiple Offline Computers with Hot Swappable Single SSDs (single SSD containing OS & data)
  • Ubuntu 20.04.1 installed in UEFI mode (Single OS, entire disk)

Problem: After moving to Ubuntu 20.04 LTS, it has become a common incident that following a complete shutdown of a PC, taking out the SSD (containing the OS) and moving it to another (exactly same HW) PC, I face grub rescue. This didn't happen in 16.04 LTS (non UEFI) and I could replace SSDs normally.

Symptoms:

  • After moving the SSD (100% sure about proper shut down), I face grub window (in rescue mode) both in original and the new PC (i.e. OS is corrupted)
  • Even setting up grub in manual mode (set root=(hd0,gpt2); linux /boot/vm...) and calling 'boot', takes me to a command-line environment with (initramfs) at the start of the line where it suggests running fsck on root partition because the checksum is wrong!
  • fsck nearly invalidates all sectors and the partition becomes unusable.

Suggestions:

  • The only thing I can think of (though not necessarily true) is use of LZ4 for initramfs in Ubuntu 20.04. Or it could be grub problems with UEFI mode. Since most folks out there don't usually move their OS disk around between different PCs, this might be a rare problem.

Notes:

  • I don't do anything strange with these disks. As all my Windows setups (and previously, Ubuntu 16.04 LTS ones) work OK during these replacements.
  • UEFI forgets UEFI boot entry or resets it, if drive is removed. Look at ubuntu entry before & after you remove drive. sudo efibootmgr -v UEFI has fallback or hard drive entry that uses /EFI/Boot/bootx64.efi which should allow you to boot. Typically bootx64.efi is just a copy of /EFI/ubuntu/shimx64.efi. Some UEFI seem to auto find a Windows entry & recreate it, but not any other system. External drives all boot from the same type of entry as the fallback on internal drives (same as yo use for Ubuntu or Windows flash drive installer). – oldfred Oct 27 '20 at 15:40
  • @oldfred Thanks, So what I understand from your comment is that this is a UEFI problem and the reason that I didn't face this before is because my all my UEFI OSs were Windows and all my Ubuntu installations (16.04) were not UEFI? is this correct? and is there any way around it? – Sina Bizbone Oct 28 '20 at 10:21
  • If you were booting in BIOS mode, just selecting drive in UEFI/BIOS will boot. You should be able to do same with UEFI, but select drive, not a "ubuntu" entry that is now not correct. The drive boot in UEFI mode will use the fallback boot entry at /EFI/Boot/bootx64.efi. Windows makes bootx64.efi a copy of Windows .efi boot file, Ubuntu install makes it a copy of shimx64.efi. So you should be able to directly boot drive. – oldfred Oct 28 '20 at 13:18
  • @oldfred would you please post your comment as the answer – Sina Bizbone Dec 19 '20 at 04:28
  • Added some more info and link to grub entries example you can also use in internal drive's grub to boot your installs in other drives. – oldfred Dec 19 '20 at 15:38

1 Answers1

1

External drives boot should boot from an ESP - efi system partition on external drive as drive entry. Ubuntu's Ubiquity installer creates a standard boot entry "ubuntu" on internal drive's ESP for external drives also, and then if external drive missing you cannot boot default entry.

UEFI forgets a specific internal UEFI boot entry or resets it, if drive is removed. Look at ubuntu entry before & after you remove drive.

sudo efibootmgr -v 

UEFI has fallback or hard drive entry that uses /EFI/Boot/bootx64.efi which should allow you to boot. Typically bootx64.efi is just a copy of /EFI/ubuntu/shimx64.efi. Some UEFI seem to auto find a Windows entry & recreate it, but not any other system. External drives all boot from the same type of entry as the fallback on internal drives (same as you use for Ubuntu or Windows flash drive installer).

If you were booting in BIOS mode, just selecting drive in UEFI/BIOS will boot. You should be able to do same with UEFI, but select drive, not a "ubuntu" entry that is now not correct.

The drive boot in UEFI mode will use the fallback boot entry at /EFI/Boot/bootx64.efi. Windows makes bootx64.efi a copy of Windows .efi boot file, Ubuntu install makes it a copy of shimx64.efi. So you should be able to directly boot drive.

You need to make default boot an internal drive's ESP entry. And then will have to manually choose from UEFI the entries for each external drive.

You can also in grub do a configfile type entry to have your other drive's ESP as boot entries. Or a specific boot entry.

How to add a GRUB2 menu entry for booting installed Ubuntu on a USB drive?

oldfred
  • 12,100