Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No warning/error when the output file could not be written completely #2197

Closed
omcaif opened this issue Feb 11, 2023 · 6 comments
Closed

No warning/error when the output file could not be written completely #2197

omcaif opened this issue Feb 11, 2023 · 6 comments
Labels
bug Our bugs

Comments

@omcaif
Copy link

omcaif commented Feb 11, 2023

Edit: Look at comment.

Describe the bug
Creating a new UEFI image with dracut makes a smaller image than previously (see Additional Context section), and it does not boot. The image does not seem to have an initial ramdisk. Trying to boot from UEFI shell gives the error of something like "Command Error Status: Unsupported".

$ ls -l /boot/linux.efi*
-rwxr-xr-x 1 root root 60010496 2023-02-11 14:46 /boot/linux.efi
-rwxr-xr-x 1 root root 89476248 2023-02-11 13:32 /boot/linux.efi.bak
$ lsinitrd /boot/linux.efi
objcopy: /boot/linux.efi: file truncated
$ lsinitrd /boot/linux.efi.bak
<expected output>

Distribution used
Gentoo

Dracut version
dracut 059

Init system
OpenRC 0.46

To Reproduce

$ cat /etc/dracut.conf /etc/dracut.conf.d/*
# PUT YOUR CONFIG IN separate files
# in /etc/dracut.conf.d named "<name>.conf"
# SEE man dracut.conf(5) for options
hostonly_cmdline="no"
kernel_cmdline="rd.luks.uuid=luks-uuid root=/dev/mapper/luks-uuid rootfstype=btrfs ro rootflags=compress=zstd,ssd,subvol=@ mitigations=auto,nosmt"
compress="zstd"
hostonly="yes"
early_microcode="yes"
uefi_secureboot_cert="/etc/efikeys/db.crt"
uefi_secureboot_key="/etc/efikeys/db.key"
uefi_stub="/usr/lib/systemd/boot/efi/linuxx64.efi.stub"
$ ls /lib/modules/
6.1.11-gentoo
$ dracut --kver 6.1.11-gentoo --kernel-image /usr/src/linux/arch/x86/boot/bzImage --uefi /boot/linux.efi --force
dracut: Executing: /usr/bin/dracut --kver 6.1.11-gentoo --kernel-image /usr/src/linux/arch/x86/boot/bzImage --uefi /boot/linux.efi --force
dracut: dracut module 'mksh' will not be installed, because command 'mksh' could not be found!
dracut: dracut module 'systemd' will not be installed, because command '/lib/systemd/systemd' could not be found!
dracut: dracut module 'systemd-ask-password' will not be installed, because command 'systemd-ask-password' could not be found!
dracut: dracut module 'systemd-ask-password' will not be installed, because command 'systemd-tty-ask-password-agent' could not be found!
dracut: dracut module 'systemd-coredump' will not be installed, because command 'coredumpctl' could not be found!
dracut: dracut module 'systemd-coredump' will not be installed, because command '/lib/systemd/systemd-coredump' could not be found!
dracut: dracut module 'systemd-hostnamed' will not be installed, because command 'hostnamectl' could not be found!
dracut: dracut module 'systemd-hostnamed' will not be installed, because command '/lib/systemd/systemd-hostnamed' could not be found!
dracut: dracut module 'systemd' will not be installed, because command '/lib/systemd/systemd' could not be found!
dracut: dracut module 'systemd-initrd' depends on 'systemd', which can't be installed
dracut: dracut module 'systemd-integritysetup' will not be installed, because command '/lib/systemd/systemd-integritysetup' could not be found!
dracut: dracut module 'systemd-integritysetup' will not be installed, because command '/lib/systemd/system-generators/systemd-integritysetup-generator' could not be found!
dracut: dracut module 'systemd-journald' will not be installed, because command 'journalctl' could not be found!
dracut: dracut module 'systemd-journald' will not be installed, because command '/lib/systemd/systemd-journald' could not be found!
dracut: dracut module 'systemd-modules-load' will not be installed, because command '/lib/systemd/systemd-modules-load' could not be found!
dracut: dracut module 'systemd-networkd' will not be installed, because command 'networkctl' could not be found!
dracut: dracut module 'systemd-networkd' will not be installed, because command '/lib/systemd/systemd-networkd' could not be found!
dracut: dracut module 'systemd-networkd' will not be installed, because command '/lib/systemd/systemd-network-generator' could not be found!
dracut: dracut module 'systemd-networkd' will not be installed, because command '/lib/systemd/systemd-networkd-wait-online' could not be found!
dracut: dracut module 'systemd-pcrphase' will not be installed, because command '/lib/systemd/systemd-pcrphase' could not be found!
dracut: dracut module 'systemd-portabled' will not be installed, because command 'portablectl' could not be found!
dracut: dracut module 'systemd-portabled' will not be installed, because command '/lib/systemd/systemd-portabled' could not be found!
dracut: dracut module 'systemd-pstore' will not be installed, because command '/lib/systemd/systemd-pstore' could not be found!
dracut: dracut module 'systemd-repart' will not be installed, because command 'systemd-repart' could not be found!
dracut: dracut module 'systemd-resolved' will not be installed, because command 'resolvectl' could not be found!
dracut: dracut module 'systemd-resolved' will not be installed, because command '/lib/systemd/systemd-resolved' could not be found!
dracut: dracut module 'systemd-rfkill' will not be installed, because command '/lib/systemd/systemd-rfkill' could not be found!
dracut: dracut module 'systemd-sysctl' will not be installed, because command '/lib/systemd/systemd-sysctl' could not be found!
dracut: dracut module 'systemd-sysext' will not be installed, because command 'systemd-sysext' could not be found!
dracut: dracut module 'systemd-sysusers' will not be installed, because command 'systemd-sysusers' could not be found!
dracut: dracut module 'systemd-timedated' will not be installed, because command 'timedatectl' could not be found!
dracut: dracut module 'systemd-timedated' will not be installed, because command '/lib/systemd/systemd-timedated' could not be found!
dracut: dracut module 'systemd-timesyncd' will not be installed, because command '/lib/systemd/systemd-timesyncd' could not be found!
dracut: dracut module 'systemd-timesyncd' will not be installed, because command '/lib/systemd/systemd-time-wait-sync' could not be found!
dracut: dracut module 'systemd-veritysetup' will not be installed, because command '/lib/systemd/systemd-veritysetup' could not be found!
dracut: dracut module 'systemd-veritysetup' will not be installed, because command '/lib/systemd/system-generators/systemd-veritysetup-generator' could not be found!
dracut: dracut module 'modsign' will not be installed, because command 'keyctl' could not be found!
dracut: dracut module 'busybox' will not be installed, because command 'busybox' could not be found!
dracut: dracut module 'dbus-broker' will not be installed, because command 'busctl' could not be found!
dracut: dracut module 'dbus-daemon' will not be installed, because command 'busctl' could not be found!
dracut: dracut module 'rngd' will not be installed, because command 'rngd' could not be found!
dracut: dracut module 'connman' will not be installed, because command 'connmand' could not be found!
dracut: dracut module 'connman' will not be installed, because command 'connmanctl' could not be found!
dracut: dracut module 'connman' will not be installed, because command 'connmand-wait-online' could not be found!
dracut: dracut module 'network-legacy' will not be installed, because command 'dhclient' could not be found!
dracut: dracut module 'network-wicked' will not be installed, because command 'wicked' could not be found!
dracut: dracut module 'lvmmerge' will not be installed, because command 'lvm' could not be found!
dracut: dracut module 'lvmthinpool-monitor' will not be installed, because command 'lvm' could not be found!
dracut: dracut module 'dmraid' will not be installed, because command 'dmraid' could not be found!
dracut: dracut module 'dmsquash-live-ntfs' will not be installed, because command 'ntfs-3g' could not be found!
dracut: dracut module 'lvm' will not be installed, because command 'lvm' could not be found!
dracut: dracut module 'mdraid' will not be installed, because command 'mdadm' could not be found!
dracut: dracut module 'pcsc' will not be installed, because command 'pcscd' could not be found!
dracut: dracut module 'tpm2-tss' will not be installed, because command 'tpm2' could not be found!
dracut: dracut module 'cifs' will not be installed, because command 'mount.cifs' could not be found!
dracut: dracut module 'iscsi' will not be installed, because command 'iscsi-iname' could not be found!
dracut: dracut module 'iscsi' will not be installed, because command 'iscsiadm' could not be found!
dracut: dracut module 'iscsi' will not be installed, because command 'iscsid' could not be found!
dracut: 95nfs: Could not find any command of 'rpcbind portmap'!
dracut: dracut module 'nvmf' will not be installed, because command 'nvme' could not be found!
dracut: dracut module 'biosdevname' will not be installed, because command 'biosdevname' could not be found!
dracut: dracut module 'masterkey' will not be installed, because command 'keyctl' could not be found!
dracut: dracut module 'systemd-initrd' depends on 'systemd', which can't be installed
dracut: dracut module 'dracut-systemd' depends on 'systemd-initrd', which can't be installed
dracut: dracut module 'memstrack' will not be installed, because command 'memstrack' could not be found!
dracut: memstrack is not available
dracut: If you need to use rd.memdebug>=4, please install memstrack and procps-ng
dracut: dracut module 'squash' will not be installed, because command 'mksquashfs' could not be found!
dracut: dracut module 'squash' will not be installed, because command 'unsquashfs' could not be found!
dracut: dracut module 'mksh' will not be installed, because command 'mksh' could not be found!
dracut: dracut module 'systemd-ask-password' will not be installed, because command 'systemd-ask-password' could not be found!
dracut: dracut module 'systemd-ask-password' will not be installed, because command 'systemd-tty-ask-password-agent' could not be found!
dracut: dracut module 'systemd-coredump' will not be installed, because command 'coredumpctl' could not be found!
dracut: dracut module 'systemd-coredump' will not be installed, because command '/lib/systemd/systemd-coredump' could not be found!
dracut: dracut module 'systemd-hostnamed' will not be installed, because command 'hostnamectl' could not be found!
dracut: dracut module 'systemd-hostnamed' will not be installed, because command '/lib/systemd/systemd-hostnamed' could not be found!
dracut: dracut module 'systemd-integritysetup' will not be installed, because command '/lib/systemd/systemd-integritysetup' could not be found!
dracut: dracut module 'systemd-integritysetup' will not be installed, because command '/lib/systemd/system-generators/systemd-integritysetup-generator' could not be found!
dracut: dracut module 'systemd-journald' will not be installed, because command 'journalctl' could not be found!
dracut: dracut module 'systemd-journald' will not be installed, because command '/lib/systemd/systemd-journald' could not be found!
dracut: dracut module 'systemd-modules-load' will not be installed, because command '/lib/systemd/systemd-modules-load' could not be found!
dracut: dracut module 'systemd-pcrphase' will not be installed, because command '/lib/systemd/systemd-pcrphase' could not be found!
dracut: dracut module 'systemd-portabled' will not be installed, because command 'portablectl' could not be found!
dracut: dracut module 'systemd-portabled' will not be installed, because command '/lib/systemd/systemd-portabled' could not be found!
dracut: dracut module 'systemd-pstore' will not be installed, because command '/lib/systemd/systemd-pstore' could not be found!
dracut: dracut module 'systemd-repart' will not be installed, because command 'systemd-repart' could not be found!
dracut: dracut module 'systemd-resolved' will not be installed, because command 'resolvectl' could not be found!
dracut: dracut module 'systemd-resolved' will not be installed, because command '/lib/systemd/systemd-resolved' could not be found!
dracut: dracut module 'systemd-rfkill' will not be installed, because command '/lib/systemd/systemd-rfkill' could not be found!
dracut: dracut module 'systemd-sysctl' will not be installed, because command '/lib/systemd/systemd-sysctl' could not be found!
dracut: dracut module 'systemd-sysext' will not be installed, because command 'systemd-sysext' could not be found!
dracut: dracut module 'systemd-sysusers' will not be installed, because command 'systemd-sysusers' could not be found!
dracut: dracut module 'systemd-timedated' will not be installed, because command 'timedatectl' could not be found!
dracut: dracut module 'systemd-timedated' will not be installed, because command '/lib/systemd/systemd-timedated' could not be found!
dracut: dracut module 'systemd-timesyncd' will not be installed, because command '/lib/systemd/systemd-timesyncd' could not be found!
dracut: dracut module 'systemd-timesyncd' will not be installed, because command '/lib/systemd/systemd-time-wait-sync' could not be found!
dracut: dracut module 'systemd-veritysetup' will not be installed, because command '/lib/systemd/systemd-veritysetup' could not be found!
dracut: dracut module 'systemd-veritysetup' will not be installed, because command '/lib/systemd/system-generators/systemd-veritysetup-generator' could not be found!
dracut: dracut module 'modsign' will not be installed, because command 'keyctl' could not be found!
dracut: dracut module 'busybox' will not be installed, because command 'busybox' could not be found!
dracut: dracut module 'dbus-broker' will not be installed, because command 'busctl' could not be found!
dracut: dracut module 'dbus-daemon' will not be installed, because command 'busctl' could not be found!
dracut: dracut module 'rngd' will not be installed, because command 'rngd' could not be found!
dracut: dracut module 'connman' will not be installed, because command 'connmand' could not be found!
dracut: dracut module 'connman' will not be installed, because command 'connmanctl' could not be found!
dracut: dracut module 'connman' will not be installed, because command 'connmand-wait-online' could not be found!
dracut: dracut module 'network-legacy' will not be installed, because command 'dhclient' could not be found!
dracut: dracut module 'network-wicked' will not be installed, because command 'wicked' could not be found!
dracut: dracut module 'lvmmerge' will not be installed, because command 'lvm' could not be found!
dracut: dracut module 'lvmthinpool-monitor' will not be installed, because command 'lvm' could not be found!
dracut: dracut module 'dmraid' will not be installed, because command 'dmraid' could not be found!
dracut: dracut module 'dmsquash-live-ntfs' will not be installed, because command 'ntfs-3g' could not be found!
dracut: dracut module 'lvm' will not be installed, because command 'lvm' could not be found!
dracut: dracut module 'mdraid' will not be installed, because command 'mdadm' could not be found!
dracut: dracut module 'pcsc' will not be installed, because command 'pcscd' could not be found!
dracut: dracut module 'tpm2-tss' will not be installed, because command 'tpm2' could not be found!
dracut: dracut module 'cifs' will not be installed, because command 'mount.cifs' could not be found!
dracut: dracut module 'iscsi' will not be installed, because command 'iscsi-iname' could not be found!
dracut: dracut module 'iscsi' will not be installed, because command 'iscsiadm' could not be found!
dracut: dracut module 'iscsi' will not be installed, because command 'iscsid' could not be found!
dracut: 95nfs: Could not find any command of 'rpcbind portmap'!
dracut: dracut module 'nvmf' will not be installed, because command 'nvme' could not be found!
dracut: dracut module 'masterkey' will not be installed, because command 'keyctl' could not be found!
dracut: dracut module 'memstrack' will not be installed, because command 'memstrack' could not be found!
dracut: memstrack is not available
dracut: If you need to use rd.memdebug>=4, please install memstrack and procps-ng
dracut: dracut module 'squash' will not be installed, because command 'mksquashfs' could not be found!
dracut: dracut module 'squash' will not be installed, because command 'unsquashfs' could not be found!
dracut: *** Including module: i18n ***
dracut: i18n_vars not set!  Please set up i18n_vars in  configuration file.
dracut: No KEYMAP configured.
dracut: *** Including module: btrfs ***
dracut: *** Including module: crypt ***
dracut: *** Including module: dm ***
dracut: Skipping udev rule: 64-device-mapper.rules
dracut: Skipping udev rule: 60-persistent-storage-dm.rules
dracut: Skipping udev rule: 55-dm.rules
dracut: *** Including module: kernel-modules ***
dracut: *** Including module: kernel-modules-extra ***
dracut: *** Including module: rootfs-block ***
dracut: *** Including module: terminfo ***
dracut: *** Including module: udev-rules ***
dracut: Skipping udev rule: 40-redhat.rules
dracut: Skipping udev rule: 50-firmware.rules
dracut: Skipping udev rule: 50-udev.rules
dracut: Skipping udev rule: 91-permissions.rules
dracut: Skipping udev rule: 80-drivers-modprobe.rules
dracut: Skipping udev rule: 70-persistent-net.rules
dracut: *** Including module: usrmount ***
dracut: *** Including module: base ***
dracut: *** Including module: fs-lib ***
dracut: *** Including module: shutdown ***
dracut: *** Including modules done ***
dracut: *** Installing kernel module dependencies ***
dracut: *** Installing kernel module dependencies done ***
dracut: *** Resolving executable dependencies ***
dracut: *** Resolving executable dependencies done ***
dracut: *** Hardlinking files ***
dracut: Mode:                     real
dracut: Method:                   sha256
dracut: Files:                    1261
dracut: Linked:                   3 files
dracut: Compared:                 0 xattrs
dracut: Compared:                 385 files
dracut: Saved:                    6.22 KiB
dracut: Duration:                 0.004181 seconds
dracut: *** Hardlinking files done ***
dracut: *** Store current command line parameters ***
dracut: *** Stripping files ***
dracut: *** Stripping files done ***
dracut: *** Creating image file '/boot/linux.efi' ***
dracut: Using UEFI kernel cmdline:
dracut: rd.luks.uuid=luks-uuid root=/dev/mapper/luks-uuid rootfstype=btrfs ro rootflags=compress=zstd,ssd,subvol=@ mitigations=auto,nosmt
warning: data remaining[88342016 vs 88356964]: gaps between PE/COFF sections?
warning: data remaining[88342016 vs 88356968]: gaps between PE/COFF sections?
Signing Unsigned original image
dracut: *** Creating signed UEFI image file '/boot/linux.efi' done ***

The kernel config I am using is the same as the one from Arch Linux.

Expected behavior
lsinitrd on the generated image would show the kernel modules and executing it would boot into Linux.

Additional context
I recently switched my kernel config from a minimal non-modular config to the huge modular one from Arch Linux (because being able to unload modules is sometimes useful and I am currently too lazy to minimize the configuration). The first time I tried to generate an image, dracut, unsurprisingly, could not create a host only image because it could not read currently loaded modules, so I decided to boot from a Arch Linux USB installer and chroot into my Gentoo install, then run dracut to create linux.efi.bak. This worked.

Later, I booted using linux.efi.bak and tried to recreate the UEFI image, and the result is as seen above. I do not think I changed any of the dracut configuration, and I think I ran the same command as above, so I am not sure what is wrong...

I tried booting back into the Arch Linux USB installer to see if I can recreate the image, but I could not.

@omcaif omcaif added the bug Our bugs label Feb 11, 2023
@omcaif omcaif changed the title UEFI Executable Unbootable (no initrd?) No warning/error when the output file could not be written completely Feb 11, 2023
@omcaif
Copy link
Author

omcaif commented Feb 11, 2023

My bad. The issue is there was not enough space in the /boot partition. I should have interpreted the error message from lsinitrd literally.

Should dracut give a warning if the file will not fit? If not, feel free to close this issue.

@LaszloGombos
Copy link
Collaborator

@omcaif was it dracut executable (shell scrip) that was not handling the out of space situation, or perhaps some other app - e.g. cpio.

I am trying to understand if dracut or some other process/executable should handle this

@omcaif
Copy link
Author

omcaif commented Feb 13, 2023

was it dracut executable (shell scrip) that was not handling the out of space situation, or perhaps some other app - e.g. cpio.

I am not sure... Here is an easy way to try it out for yourself:

$ mktemp -d
/tmp/tmp.8qON0uOPQ2
$ mount -t tmpfs -o defaults,size=10M tmpfs /tmp/tmp.8qON0uOPQ2 # size should be smaller than generated image to reproduce issue
$ dracut --kver 6.1.11-gentoo --kernel-image /usr/src/linux/arch/x86/boot/bzImage --uefi /tmp/tmp.8qON0uOPQ2/out.uefi

The output from the original "To Reproduce" section is still valid to this issue. There is no warning or error in that output, so I do not know who is at fault...

@aafeijoo-suse
Copy link
Member

It's sbsign not returning an error in this case:

# sbsign --key /home/dev/sbsign/uefi-private.key --cert /home/dev/sbsign/uefi-public.pem --output /tmp/tmp.YC4iYlF8UF/test.img /var/tmp/dracut.9SDv5P/uefi/linux.efi
warning: data remaining[88702464 vs 88714976]: gaps between PE/COFF sections?
Signing Unsigned original image
# echo $?
0

aafeijoo-suse added a commit to aafeijoo-suse/dracut that referenced this issue Feb 13, 2023
`sbsign` does not issue any error if there is not enough disk space to create
the signed file using its `--output` option. So, verify the signed image after
its creation using `sbverify`.

Fixes issue dracutdevs#2197
johannbg pushed a commit that referenced this issue Feb 13, 2023
`sbsign` does not issue any error if there is not enough disk space to create
the signed file using its `--output` option. So, verify the signed image after
its creation using `sbverify`.

Fixes issue #2197
@johannbg
Copy link
Collaborator

@aafeijoo-suse it's an harmless error from sbsign, the problem I'm suspecting here is that he forgot to boot into an efi shell and manually set the image as a boot option and or created the entry with wrong path to efi file in anycase we need something more to work on.

@aafeijoo-suse
Copy link
Member

@aafeijoo-suse it's an harmless error from sbsign, the problem I'm suspecting here is that he forgot to boot into an efi shell and manually set the image as a boot option and or created the entry with wrong path to efi file in anycase we need something more to work on.

Hmm.. it's not harmless:

https://groups.io/g/sbsigntools/message/58?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cspace%2C20%2C2%2C0%2C87943692

The problem for us is we are trusting the sbsign exit code, and it's always zero even if the write with --output fails.

aafeijoo-suse added a commit to aafeijoo-suse/dracut that referenced this issue Jun 15, 2023
`sbsign` does not issue any error if there is not enough disk space to create
the signed file using its `--output` option. So, verify the signed image after
its creation using `sbverify`.

Fixes issue dracutdevs#2197

(cherry picked from commit a6dd5bf)
pvalena pushed a commit to pvalena/dracut that referenced this issue Jul 23, 2023
`sbsign` does not issue any error if there is not enough disk space to create
the signed file using its `--output` option. So, verify the signed image after
its creation using `sbverify`.

Fixes issue dracutdevs#2197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Our bugs
Projects
None yet
Development

No branches or pull requests

4 participants