In yesterdays post Install Debian on RAID1 I showed how to install a complete Debian system on software RAID1 (MD RAID, not LVM RAID).
During my tests I removed disks and checked if the system still was bootable. As I did not test on bare metal, but on Proxmox, I just had to detach virtual disks to simulate this.
But that had an unpleasant side effect: each time I detached a drive the Proxmox UEFI BIOS (OVMF) would forget about all boot entries on this disk. I asked for help, but nothing yet. So every time after removing a disk, I had to re-install the boot entries with “efibootmgr -c ...
“.
Then I got a nice tip from @nitram: by default, UEFI boots from the EFI partition (/boot/efi
in our example) from EFI/boot/bootx64.efi
. Debian instead wants to be booted from EFI/debian/shimx64.efi
(when running Secure Boot) and then loads grubx64.efi
from the same directory. This loads /EFI/debian/grub.cfg
and from there on we are on familiar territory.
So why not copy EFI/debian/shimx64.efi
to EFI/boot/bootx64.efi
and EFI/debian/grubx64.efi
to EFI/boot/grubx64.efi
?
The following procedure does exactly this:
# vi /etc/grub.d/80_copy_debian_uefi_to_standard
#!/bin/sh
set -e
mkdir -p /boot/efi/EFI/boot
cd /boot/efi/EFI
if [ -f debian/shimx64.efi ] ; then
cmp -s debian/shimx64.efi boot/bootx64.efi ||
cp debian/shimx64.efi boot/bootx64.efi
cmp -s debian/grubx64.efi boot/grubx64.efi ||
cp debian/grubx64.efi boot/grubx64.efi
else
cmp -s debian/grubx64.efi boot/bootx64.efi ||
cp debian/grubx64.efi boot/bootx64.efi
fi
# chmod 700 /etc/grub.d/80_copy_debian_uefi_to_standard
# update-grub
There is one thing you still have to do: the partition type of the EFI partition on the second disk is not “EFI System” yet (we installed it as FAT32, which makes the partition type “Microsoft basic data”). To change that:
# cfdisk /dev/sdb
Select /dev/sdb1
, type “t” for “Type”, select “EFI system”, type “W” (the uppercase letter) for “Write” and “yes” (you have to spell it out). Then “q” for “quit”.
Now you no longer need the “debian
” boot entries but can use the default ones from Proxmox, “UEFI QEMU QEMU HARDDISK
” and “UEFI QEMU QEMU HARDDISK 2
” or whatever your BIOS offers for standard drives. Through update-grub
the configuration gets updated every time something changes in GRUB. And through /etc/grub.d/90_copy_to_boot_efi2
from yesterdays post it is copied to the second disk.