]>
git.proxmox.com Git - mirror_zfs.git/blob - contrib/dracut/90zfs/mount-zfs.sh.in
2 # shellcheck disable=SC2034,SC2154
4 .
/lib
/dracut-zfs-lib.sh
6 decode_root_args ||
return 0
8 GENERATOR_FILE
=/run
/systemd
/generator
/sysroot.mount
9 GENERATOR_EXTENSION
=/run
/systemd
/generator
/sysroot.mount.d
/zfs-enhancement.conf
11 if [ -e "$GENERATOR_FILE" ] && [ -e "$GENERATOR_EXTENSION" ]; then
12 # We're under systemd and dracut-zfs-generator ran to completion.
13 info
"ZFS: Delegating root mount to sysroot.mount at al."
15 # We now prevent Dracut from running this thing again.
16 rm -f "$hookdir"/mount
/*zfs
*
20 info
"ZFS: No sysroot.mount exists or zfs-generator did not extend it."
21 info
"ZFS: Mounting root with the traditional mount-zfs.sh instead."
23 # Delay until all required block devices are present.
24 modprobe zfs
2>/dev
/null
30 if [ "${root}" = "zfs:AUTO" ] ; then
31 if ! ZFS_DATASET
="$(find_bootfs)" ; then
32 # shellcheck disable=SC2086
33 zpool import
-N -a ${ZPOOL_IMPORT_OPTS}
34 if ! ZFS_DATASET
="$(find_bootfs)" ; then
35 warn
"ZFS: No bootfs attribute found in importable pools."
42 info
"ZFS: Using ${ZFS_DATASET} as root."
45 ZFS_DATASET
="${ZFS_DATASET:-${root}}"
46 ZFS_POOL
="${ZFS_DATASET%%/*}"
48 if import_pool
"${ZFS_POOL}" ; then
49 # Load keys if we can or if we need to
50 if [ "$(zpool list -H -o feature@encryption "${ZFS_POOL}")" = 'active' ]; then
51 # if the root dataset has encryption enabled
52 ENCRYPTIONROOT
="$(zfs get -H -o value encryptionroot "${ZFS_DATASET}")"
53 if ! [ "${ENCRYPTIONROOT}" = "-" ]; then
54 KEYSTATUS
="$(zfs get -H -o value keystatus "${ENCRYPTIONROOT}")"
55 # if the key needs to be loaded
56 if [ "$KEYSTATUS" = "unavailable" ]; then
60 --prompt "Encrypted ZFS password for ${ENCRYPTIONROOT}: " \
61 --cmd "zfs load-key '${ENCRYPTIONROOT}'"
65 # Let us tell the initrd to run on shutdown.
66 # We have a shutdown hook to run
67 # because we imported the pool.
68 info
"ZFS: Mounting dataset ${ZFS_DATASET}..."
69 if mount_dataset
"${ZFS_DATASET}" ; then