mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-06-01 19:54:10 +03:00
contrib; dracut: centralise root= parsing, actually support root=s
So far, everything parsed root= manually, which meant that while
zfs-parse.sh was updated, and supposedly supported + -> ' ' conversion,
it meant nothing
Instead, centralise parsing, and allow:
root=
root=zfs
root=zfs:
root=zfs:AUTO
root=ZFS=data/set
root=zfs:data/set
root=zfs:ZFS=data/set (as a side-effect; allowed but undocumented)
rootfstype=zfs AND root=data/set <=> root=data/set
rootfstype=zfs AND root= <=> root=zfs:AUTO
So rootfstype=zfs /also/ behaves as expected, and + decoding works
Upstream-commit: 245529d85f
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13291
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
|
||||
. /lib/dracut-lib.sh
|
||||
# shellcheck source=zfs-lib.sh.in
|
||||
. /lib/dracut-zfs-lib.sh
|
||||
|
||||
# Let the command line override our host id.
|
||||
spl_hostid=$(getarg spl_hostid=)
|
||||
@@ -15,43 +16,20 @@ else
|
||||
warn "ZFS: Pools may not import correctly."
|
||||
fi
|
||||
|
||||
wait_for_zfs=0
|
||||
case "${root}" in
|
||||
""|zfs|zfs:)
|
||||
# We'll take root unset, root=zfs, or root=zfs:
|
||||
# No root set, so we want to read the bootfs attribute. We
|
||||
# can't do that until udev settles so we'll set dummy values
|
||||
# and hope for the best later on.
|
||||
root="zfs:AUTO"
|
||||
rootok=1
|
||||
wait_for_zfs=1
|
||||
if decode_root_args; then
|
||||
if [ "$root" = "zfs:AUTO" ]; then
|
||||
info "ZFS: Boot dataset autodetected from bootfs=."
|
||||
else
|
||||
info "ZFS: Boot dataset is ${root}."
|
||||
fi
|
||||
|
||||
info "ZFS: Enabling autodetection of bootfs after udev settles."
|
||||
;;
|
||||
|
||||
ZFS=*|zfs:*)
|
||||
# root is explicit ZFS root. Parse it now. We can handle
|
||||
# a root=... param in any of the following formats:
|
||||
# root=ZFS=rpool/ROOT
|
||||
# root=zfs:rpool/ROOT
|
||||
# root=ZFS=pool+with+space/ROOT+WITH+SPACE (translates to root=ZFS=pool with space/ROOT WITH SPACE)
|
||||
|
||||
# Strip down to just the pool/fs
|
||||
root="${root#zfs:}"
|
||||
root="zfs:${root#ZFS=}"
|
||||
# switch + with spaces because kernel cmdline does not allow us to quote parameters
|
||||
root=$(echo "$root" | tr '+' ' ')
|
||||
rootok=1
|
||||
wait_for_zfs=1
|
||||
|
||||
info "ZFS: Set ${root} as bootfs."
|
||||
;;
|
||||
esac
|
||||
|
||||
# Make sure Dracut is happy that we have a root and will wait for ZFS
|
||||
# modules to settle before mounting.
|
||||
if [ ${wait_for_zfs} -eq 1 ]; then
|
||||
ln -s /dev/null /dev/root 2>/dev/null
|
||||
initqueuedir="${hookdir}/initqueue/finished"
|
||||
echo '[ -e /dev/zfs ]' > "${initqueuedir}/zfs.sh"
|
||||
rootok=1
|
||||
# Make sure Dracut is happy that we have a root and will wait for ZFS
|
||||
# modules to settle before mounting.
|
||||
if [ -n "${wait_for_zfs}" ]; then
|
||||
ln -s null /dev/root
|
||||
echo '[ -e /dev/zfs ]' > "${hookdir}/initqueue/finished/zfs.sh"
|
||||
fi
|
||||
else
|
||||
info "ZFS: no ZFS-on-root."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user