Skip to content

Commit

Permalink
dracut: support mountpoint=legacy for root dataset
Browse files Browse the repository at this point in the history
Support mountpoint=legacy for the root dataset in the dracut zfs support
scripts.

mountpoint=/ or mountpoint=/sysroot also works.

Change zfs-env-bootfs.service to add zfsutil to BOOTFSFLAGS only for
non-legacy root datasets, using the support function
determine_rootflags() added to zfs-lib.sh.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
  • Loading branch information
rkitover committed Aug 3, 2023
1 parent e47e9bb commit bf8ae34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 1 addition & 6 deletions contrib/dracut/90zfs/zfs-env-bootfs.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ ExecStart=/bin/sh -c '
. /lib/dracut-zfs-lib.sh; \
decode_root_args || exit 0; \
[ "$root" = "zfs:AUTO" ] && root="$(@sbindir@/zpool list -H -o bootfs | grep -m1 -vFx -)"; \
rootflags="$(getarg rootflags=)"; \
case ",$rootflags," in \
*,zfsutil,*) ;; \
,,) rootflags=zfsutil ;; \
*) rootflags="zfsutil,$rootflags" ;; \
esac; \
determine_rootflags; \
exec systemctl set-environment BOOTFS="$root" BOOTFSFLAGS="$rootflags"'

[Install]
Expand Down
16 changes: 16 additions & 0 deletions contrib/dracut/90zfs/zfs-lib.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,19 @@ decode_root_args() {

return 1
}

# Gets rootflags and adds zfsutil for non-legacy mountpoints.
# Requires that decode_root_args() has already been called and $root is set.
determine_rootflags() {
rootflags="$(getarg rootflags=)"

mountpoint="$(zfs get -H -o value mountpoint "$root")"

if [ "$mountpoint" != legacy ]; then
case ",$rootflags," in
*,zfsutil,*) ;;
,,) rootflags=zfsutil ;;
*) rootflags="zfsutil,$rootflags" ;;
esac
fi
}

0 comments on commit bf8ae34

Please sign in to comment.