JohnstonJ / ubuntu-secure-boot

Self-signed UEFI- and GRUB-based secure boot system for Ubuntu.
MIT License
23 stars 10 forks source link

efibootmgr: Could not set variable: No such file or directory #2

Open ragkousism opened 6 years ago

ragkousism commented 6 years ago

Hello, running make-secure-boot-keys as root on ubuntu 16.04 fails in the end with:

Generating grub configuration file ...
patching file /tmp/tmp.CuOB9NyrEo (read from /etc/ubuntu-secure-boot/10_linux.distrib)
Found linux image: /boot/vmlinuz-4.4.0-116-generic
Found initrd image: /boot/initrd.img-4.4.0-116-generic
Found linux image: /boot/vmlinuz-4.4.0-87-generic
Found initrd image: /boot/initrd.img-4.4.0-87-generic
Adding boot menu entry for EFI firmware configuration
done
Gathering GRUB modules... (please disregard any messages regarding network configuration...
Netboot directory for x86_64-efi created. Configure your DHCP server to point to /tmp/tmp.xHxB5wKqW0/boot/grub/x86_64-efi/core.efi
Signing GRUB modules... (this will take a minute)
Creating memdisk...
Building GRUB image...
writing RSA key
Signing GRUB image...
Adding bootloader to EFI configuration...
efibootmgr: Could not set variable: No such file or directory
efibootmgr: Could not prepare boot variable: No such file or directory

The part in which it fails is:

    DEVICE="$(df -T /boot/efi | sed -n 2p | awk '{ print $1}')"
    DISK="$(echo "$DEVICE" | sed 's|[0-9]||g')"
    PARTNUM="$(echo "$DEVICE" | sed 's|[^0-9]||g')"
    efibootmgr --quiet --create --disk "$DISK" --part "$PARTNUM" \
        --write-signature --label "$BOOTLOADER_ID" \
        --loader "\\EFI\\$BOOTLOADER_ID\\$EFI_FILENAME"

Any ideas what could be wrong?

ragkousism commented 6 years ago

I found the problem. On my system I am using a nvm ssd, which means that df -T /boot/efi | sed -n 2p | awk '{ print $1}' evaluates to /dev/nvme0n1p1. The issue is that echo "$DEVICE" | sed 's|[0-9]||g' evaluates into /dev/nvmenp and echo "$DEVICE" | sed 's|[^0-9]||g' evaluates into 011 which is completely wrong. the correct values are DISK=/dev/nvme0n1 and PARTNUM=1