This is a followup question after
How to Make BIOS/UEFI Flash Drive with Full Disk Encryption
I have followed the answers in this question and created an encrypted full installation of Ubuntu 20.04 in an USB flash drive that booted from either from BIOS or from UEFI configured computers.
Over time I have used this USB flash drive installed Ubuntu in a BIOS only computer and kept it updated with security and other updates. Now the UEFI computer won't boot from this USB drive. When I select Ubuntu from the GRUB it shows me the error:
error file '/vmlinuz-5.8.0-48-generic' not found.
you need to load the kernel first.
This specific kernel is not installed as it was superseded by newer kernels during security and other updates.
How do I regain the UEFI boot functionality for this USB based Ubuntu installation?
The Tale of Two
grub.cfg
This USB flash drive installation has two separate
grub.cfg
in two locations. One is used for booting BIOS only computers and the other is used for booting UEFI computers. When new kernels are installed and old ones removed the installation process updates only the grub.cfg file that was used for the current boot. As a result, the twogrub.cfg
files get out of sync.The file needed for BIOS boot is at:
The file needed for UEFI boot is at:
Note, since this is an encrypted installation, the boot partition has the mount point
/boot
and the ESP partition has the mount point/boot/efi
.Solution
Replace the older grub.cfg with the newer version. In my case, the BIOS one was newer. So I used the command:
This fixed the problem for now.
A Script
I wrote a small script called
grubsync.sh
to copy and replace the oldergrub.cfg
with the newer one, if they are different based on which mode (BIOS or UEFI) the USB booted from.The hostname of my USB full installation is
USB123
. Change it before you run the script. You will need to run this script withsudo
prefix.As of now, I have to run this script every time there is a kernel update. With a few tweaks, I may be able to run it at every boot using crontab.
Hope this helps