]> git.proxmox.com Git - pve-installer.git/commitdiff
mount efivarfs to ensure we can read bigger variables
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 8 Jul 2019 14:13:23 +0000 (16:13 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 8 Jul 2019 14:21:07 +0000 (16:21 +0200)
In short, EFI variables can get quite big, and the old sysfs
interface was made for when they couldn't. A few firmwares out there
have such big variables, and if those are accessed through the sysfs
backed interface one gets a "Input/Output Error". 'grub-install'
chokes on that error when it iterates over all variables to do it's
stuff, and thus fails our installation. When we mount the efivarfs,
which does not has this limitations, one can read all variables just
fine - at least as long as the NVRAM backing them is not broken.

from Linux Kernel Documentation/filesystems/efivarfs.txt:
> The efivarfs filesystem was created to address the shortcomings of
> using entries in sysfs to maintain EFI variables. The old sysfs EFI
> variables code only supported variables of up to 1024 bytes. This
> limitation existed in version 0.99 of the EFI specification, but was
> removed before any full releases. Since variables can now be larger
> than a single page, sysfs isn't the best interface for this.
> Variables can be created, deleted and modified with the efivarfs
> filesystem.

Also mount it in the installer environment for debugging purpose.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
proxinstall
unconfigured.sh

index 1f70720345623b77e3470bdb89643e2c6c92c88a..019ae0b2d6f4dac904cbc0f26d0a662ec7101d18 100755 (executable)
@@ -1097,7 +1097,7 @@ sub prepare_systemd_boot_esp {
     File::Path::make_path("$targetdir/$espmp/EFI/proxmox") ||
        die "unable to create directory $targetdir/$espmp/EFI/proxmox\n";
 
-    syscmd("chroot $targetdir bootctl --no-variables --path /$espmp install") == 0 ||
+    syscmd("chroot $targetdir bootctl --path /$espmp install") == 0 ||
        die "unable to install systemd-boot loader\n";
     write_config("timeout 3\ndefault proxmox-*\n",
        "$targetdir/$espmp/loader/loader.conf");
@@ -1378,6 +1378,10 @@ sub extract_data {
            die "unable to mount proc on $targetdir/proc\n";
        syscmd("mount -n -t sysfs sysfs $targetdir/sys") == 0 ||
            die "unable to mount sysfs on $targetdir/sys\n";
+       if ($boot_type eq 'efi') {
+           syscmd("mount -n -t efivarfs none $targetdir/sys/firmware/efi/efivars") == 0 ||
+               die "unable to mount efivarfs on $targetdir/sys/firmware/efi/efivars: $!\n";
+       }
        syscmd("chroot $targetdir mount --bind /mnt/hostrun /run") == 0 ||
            die "unable to re-bindmount hostrun on /run in chroot\n";
 
@@ -1735,6 +1739,7 @@ _EOD
     syscmd("umount $targetdir/mnt/hostrun");
     syscmd("umount $targetdir/tmp");
     syscmd("umount $targetdir/proc");
+    syscmd("umount $targetdir/sys/firmware/efi/efivars");
     syscmd("umount $targetdir/sys");
 
     if ($use_zfs) {
index 674605f66259b62f7e9e0e7292bef065558b6930..d16ea61f0df4279bba0e50990d009f932ad33717 100755 (executable)
@@ -63,6 +63,10 @@ export SYSTEMD_IGNORE_CHROOT=1
 
 mount -n -t proc proc /proc
 mount -n -t sysfs sysfs /sys
+if [ -d /sys/firmware/efi ]; then
+    echo "EFI boot mode detected, mounting efivars filesystem"
+    mount -nt efivarfs none /sys/firmware/efi/efivars
+fi
 mount -n -t tmpfs tmpfs /run
 
 parse_cmdline