--- a/grub.d/10_linux_zfs +++ b/grub.d/10_linux_zfs @@ -369,6 +369,7 @@ is_secure_boot_enabled() { get_dataset_info() { local dataset="$1" local mntdir="$2" + local has_bpool="$3" local base_dataset="${dataset}" local etc_dir="${mntdir}/etc" @@ -405,7 +406,10 @@ get_dataset_info() { mountpoint -q "${mntdir}/etc" && umount "${mntdir}/etc" || true # read available kernels from /boot - boot_dir="$(try_default_layout_bpool "${dataset}" "${mntdir}")" + local boot_dir= + if [ $has_bpool -eq 1 ]; then + boot_dir="$(try_default_layout_bpool "${dataset}" "${mntdir}")" + fi if [ -z "${boot_dir}" ]; then boot_dir=$(get_system_directory "${dataset}" "boot" "false" "${mntdir}" "${etc_dir}") fi @@ -421,7 +425,9 @@ get_dataset_info() { kernel_list="" list=$(find "${boot_dir}" -maxdepth 1 -type f -regex '.*/\(vmlinuz\|vmlinux\|kernel\)-.*') while [ "x$list" != "x" ] ; do - linux=`version_find_latest $list` + list_basename=$(echo $list | tr ' ' '\n' | sed -e 's#.*/##') + linux=`version_find_latest $list_basename` + linux=$(for l in $list; do test "${l##*/}" = "${linux}" && echo "$l" && break; done) list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '` if ! grub_file_is_not_garbage "${linux}" ; then continue @@ -532,14 +538,15 @@ get_dataset_info() { bootlist() { local mntdir="$1" local boot_list="" + local has_bpool=$(zpool list -Honame bpool >/dev/null 2>&1 && echo 1 || echo 0) for dataset in $(get_root_datasets); do # get information from current root dataset - boot_list="${boot_list}$(get_dataset_info ${dataset} ${mntdir})\n" + boot_list="${boot_list}$(get_dataset_info ${dataset} ${mntdir} ${has_bpool})\n" # get information from snapshots of this root dataset for snapshot_dataset in $(zfs list -H -o name -t snapshot "${dataset}"); do - boot_list="${boot_list}$(get_dataset_info ${snapshot_dataset} ${mntdir})\n" + boot_list="${boot_list}$(get_dataset_info ${snapshot_dataset} ${mntdir} ${has_bpool})\n" done done echo "${boot_list}"