2 # shellcheck disable=SC2034
4 command -v getarg
>/dev
/null || .
/lib
/dracut-lib.sh || .
/usr
/lib
/dracut
/modules.d
/99base
/dracut-lib.sh
9 if getargbool
0 zfs_force
-y zfs.force
-y zfsforce
; then
10 warn
"ZFS: Will force-import pools if necessary."
15 # shellcheck disable=SC2154
16 mount
-o zfsutil
-t zfs
"${1}" "${NEWROOT}${2}"
19 # mount_dataset DATASET
20 # mounts the given zfs dataset.
23 mountpoint
="$(zfs get -H -o value mountpoint "${dataset}")"
26 # We need zfsutil for non-legacy mounts and not for legacy mounts.
27 if [ "${mountpoint}" = "legacy" ] ; then
28 mount
-t zfs
"${dataset}" "${NEWROOT}" || ret
=$?
30 mount
-o zfsutil
-t zfs
"${dataset}" "${NEWROOT}" || ret
=$?
32 if [ "$ret" = "0" ]; then
33 for_relevant_root_children
"${dataset}" _mount_dataset_cb || ret
=$?
40 # for_relevant_root_children DATASET EXEC
41 # Runs "EXEC dataset mountpoint" for all children of DATASET that are needed for system bringup
42 # Used by zfs-nonroot-necessities.service and friends, too!
43 for_relevant_root_children
() {
47 zfs list
-t filesystem
-Ho name
,mountpoint
,canmount
-r "${dataset}" |
50 while IFS
="${TAB}" read -r dataset mountpoint canmount
; do
51 [ "$canmount" != "on" ] && continue
54 /etc|
/bin|
/lib|
/lib??|
/libx32|
/usr
)
55 # If these aren't mounted we may not be able to get to the real init at all, or pollute the dataset holding the rootfs
56 "${exec}" "${dataset}" "${mountpoint}" || _ret
=$?
59 # Up to the real init to remount everything else it might need
67 # Parse root=, rootfstype=, return them decoded and normalised to zfs:AUTO for auto, plain dset for explicit
69 # True if ZFS-on-root, false if we shouldn't
79 # root=zfs:ZFS=data/set (as a side-effect; allowed but undocumented)
81 # rootfstype=zfs AND root=data/set <=> root=data/set
82 # rootfstype=zfs AND root= <=> root=zfs:AUTO
84 # '+'es in explicit dataset decoded to ' 's.
86 if [ -n "$rootfstype" ]; then
87 [ "$rootfstype" = zfs
]
92 rootfstype
=$
(getarg rootfstype
=)
94 # shellcheck disable=SC2249
105 root
=$
(echo "$root" |
tr '+' ' ')
111 if [ "$rootfstype" = "zfs" ]; then
114 *) root
=$
(echo "$xroot" |
tr '+' ' ') ;;