]>
git.proxmox.com Git - mirror_zfs.git/blob - contrib/dracut/90zfs/mount-zfs.sh.in
68e3f0e0d60bf847aea20b25ef5a35671ab282a8
2 # shellcheck disable=SC2034,SC2154
4 .
/lib
/dracut-zfs-lib.sh
14 GENERATOR_FILE
=/run
/systemd
/generator
/sysroot.mount
15 GENERATOR_EXTENSION
=/run
/systemd
/generator
/sysroot.mount.d
/zfs-enhancement.conf
17 if [ -e "$GENERATOR_FILE" ] && [ -e "$GENERATOR_EXTENSION" ] ; then
18 # If the ZFS sysroot.mount flag exists, the initial RAM disk configured
19 # it to mount ZFS on root. In that case, we bail early. This flag
20 # file gets created by the zfs-generator program upon successful run.
21 info
"ZFS: There is a sysroot.mount and zfs-generator has extended it."
22 info
"ZFS: Delegating root mount to sysroot.mount."
23 # Let us tell the initrd to run on shutdown.
24 # We have a shutdown hook to run
25 # because we imported the pool.
26 # We now prevent Dracut from running this thing again.
27 for zfsmounthook
in "$hookdir"/mount
/*zfs
* ; do
28 if [ -f "$zfsmounthook" ] ; then
34 info
"ZFS: No sysroot.mount exists or zfs-generator did not extend it."
35 info
"ZFS: Mounting root with the traditional mount-zfs.sh instead."
37 # Delay until all required block devices are present.
38 modprobe zfs
2>/dev
/null
41 if [ "${root}" = "zfs:AUTO" ] ; then
42 if ! ZFS_DATASET
="$(find_bootfs)" ; then
43 # shellcheck disable=SC2086
44 zpool import
-N -a ${ZPOOL_IMPORT_OPTS}
45 if ! ZFS_DATASET
="$(find_bootfs)" ; then
46 warn
"ZFS: No bootfs attribute found in importable pools."
53 info
"ZFS: Using ${ZFS_DATASET} as root."
56 ZFS_DATASET
="${ZFS_DATASET:-${root#zfs:}}"
57 ZFS_POOL
="${ZFS_DATASET%%/*}"
59 if import_pool
"${ZFS_POOL}" ; then
60 # Load keys if we can or if we need to
61 if [ "$(zpool list -H -o feature@encryption "${ZFS_POOL}")" = 'active' ]; then
62 # if the root dataset has encryption enabled
63 ENCRYPTIONROOT
="$(zfs get -H -o value encryptionroot "${ZFS_DATASET}")"
64 if ! [ "${ENCRYPTIONROOT}" = "-" ]; then
65 KEYSTATUS
="$(zfs get -H -o value keystatus "${ENCRYPTIONROOT}")"
66 # if the key needs to be loaded
67 if [ "$KEYSTATUS" = "unavailable" ]; then
71 --prompt "Encrypted ZFS password for ${ENCRYPTIONROOT}: " \
72 --cmd "zfs load-key '${ENCRYPTIONROOT}'"
76 # Let us tell the initrd to run on shutdown.
77 # We have a shutdown hook to run
78 # because we imported the pool.
79 info
"ZFS: Mounting dataset ${ZFS_DATASET}..."
80 if mount_dataset
"${ZFS_DATASET}" ; then