From: Adam Bell Date: 10 Mar 2022 22:22:39 +0700 Subject: ZFS snapshots causing grub.cfg generation failure In the situation where ZFS snapshots do not contain a .../etc directory, the generation of /b/g/grub.cfg silently fails, providing no "linux" kernel lines in the /b/g/grub.cfg file. This patch prevents this type of failure from occurring. This issue is especially apparent on systems running in FIPS mode with ZFS boot+root pools. Patch-Name: grubcfg-zfs-snapshot-generation-failure.patch --- diff --git a/util/grub.d/10_linux_zfs.in b/util/grub.d/10_linux_zfs.in index d9b79e2..4dd1609 100755 --- a/util/grub.d/10_linux_zfs.in +++ b/util/grub.d/10_linux_zfs.in @@ -520,11 +520,15 @@ get_dataset_info() { umount "${mntdir}" || true # We needed to look in / for snapshots on root dataset, umount the snapshot for etc before zfs lazily unmount it - case "${etc_dir}" in /.zfs/snapshot/*/etc) - snapshot_path="$(findmnt -n -o TARGET -T ${etc_dir})" - umount "${snapshot_path}" || true - ;; - esac + # This process only needs to run if the snapshot contains an .../etc path, + # otherwise the build process may silently fail and produce no kernel lines in grub.cfg + if [ -e "${etc_dir}" ]; then + case "${etc_dir}" in /.zfs/snapshot/*/etc) + snapshot_path="$(findmnt -n -o TARGET -T ${etc_dir})" + umount "${snapshot_path}" || true + ;; + esac + fi } # Scan available boot options and returns in a formatted list