Comment 2 for bug 1990143

Revision history for this message
satmandu (satadru-umich) wrote : Re: grub-common update broke zfs root boots

--- 10_linux_zfs.working 2022-09-19 09:28:36.280002568 -0400
+++ 10_linux_zfs.broken 2022-09-19 09:28:14.093006608 -0400
@@ -529,11 +529,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
@@ -1128,7 +1132,3 @@ case "${GRUB_LINUX_ZFS_TEST}" in
         grub_menu="$(generate_grub_menu "${menu_metadata}")"
         if [ -n "${grub_menu}" ]; then
             # We want the trailing newline as a marker will be added
- echo "${grub_menu}"
- fi
- ;;