mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-03-22 08:51:30 +03:00
Make lines stay within 80 char limit.
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Rob Norris <robn@despairlabs.com> Signed-off-by: Turbo Fredriksson <turbo@bayour.com> Closes #18000
This commit is contained in:
parent
9ef326b987
commit
c54825f7eb
@ -25,6 +25,14 @@ shell() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_cmdline()
|
||||||
|
{
|
||||||
|
_option="${1}"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2089
|
||||||
|
grep -qiE "(^|[^\\](\\\\)* )(${_option})=(on|yes|1)( |$)" /proc/cmdline
|
||||||
|
}
|
||||||
|
|
||||||
# This runs any scripts that should run before we start importing
|
# This runs any scripts that should run before we start importing
|
||||||
# pools and mounting any filesystems.
|
# pools and mounting any filesystems.
|
||||||
pre_mountroot()
|
pre_mountroot()
|
||||||
@ -197,7 +205,8 @@ import_pool()
|
|||||||
|
|
||||||
# Verify that the pool isn't already imported
|
# Verify that the pool isn't already imported
|
||||||
# Make as sure as we can to not require '-f' to import.
|
# Make as sure as we can to not require '-f' to import.
|
||||||
"${ZPOOL}" get -H -o value name,guid 2>/dev/null | grep -Fxq "${_import_pool}" && return 0
|
"${ZPOOL}" get -H -o value name,guid 2>/dev/null | \
|
||||||
|
grep -Fxq "${_import_pool}" && return 0
|
||||||
|
|
||||||
# For backwards compatibility, make sure that ZPOOL_IMPORT_PATH is set
|
# For backwards compatibility, make sure that ZPOOL_IMPORT_PATH is set
|
||||||
# to something we can use later with the real import(s). We want to
|
# to something we can use later with the real import(s). We want to
|
||||||
@ -242,7 +251,8 @@ import_pool()
|
|||||||
[ "${quiet}" != "y" ] && zfs_log_begin_msg \
|
[ "${quiet}" != "y" ] && zfs_log_begin_msg \
|
||||||
"Importing pool '${_import_pool}' using cachefile."
|
"Importing pool '${_import_pool}' using cachefile."
|
||||||
|
|
||||||
ZFS_CMD="${ZPOOL} import -c ${ZPOOL_CACHE} -N ${ZPOOL_FORCE} ${ZPOOL_IMPORT_OPTS}"
|
ZFS_CMD="${ZPOOL} import -c ${ZPOOL_CACHE} -N ${ZPOOL_FORCE}"
|
||||||
|
ZFS_CMD="${ZFS_CMD} ${ZPOOL_IMPORT_OPTS}"
|
||||||
ZFS_STDERR="$(${ZFS_CMD} "${_import_pool}" 2>&1)"
|
ZFS_STDERR="$(${ZFS_CMD} "${_import_pool}" 2>&1)"
|
||||||
ZFS_ERROR="${?}"
|
ZFS_ERROR="${?}"
|
||||||
fi
|
fi
|
||||||
@ -280,7 +290,8 @@ load_module_initrd()
|
|||||||
|
|
||||||
if [ "${ZFS_INITRD_PRE_MOUNTROOT_SLEEP}" -gt 0 ]
|
if [ "${ZFS_INITRD_PRE_MOUNTROOT_SLEEP}" -gt 0 ]
|
||||||
then
|
then
|
||||||
[ "${quiet}" != "y" ] && zfs_log_begin_msg "Delaying for up to '${ZFS_INITRD_PRE_MOUNTROOT_SLEEP}' seconds."
|
[ "${quiet}" != "y" ] && \
|
||||||
|
zfs_log_begin_msg "Delaying for up to '${ZFS_INITRD_PRE_MOUNTROOT_SLEEP}' seconds."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
START="$(/bin/date -u +%s)"
|
START="$(/bin/date -u +%s)"
|
||||||
@ -345,7 +356,8 @@ mount_fs()
|
|||||||
_mount_fs="${1}"
|
_mount_fs="${1}"
|
||||||
|
|
||||||
# Check that the filesystem exists
|
# Check that the filesystem exists
|
||||||
"${ZFS}" list -oname -tfilesystem -H "${_mount_fs}" > /dev/null 2>&1 || return 1
|
"${ZFS}" list -oname -tfilesystem -H "${_mount_fs}" \
|
||||||
|
> /dev/null 2>&1 || return 1
|
||||||
|
|
||||||
# Skip filesystems with canmount=off. The root fs should not have
|
# Skip filesystems with canmount=off. The root fs should not have
|
||||||
# canmount=off, but ignore it for backwards compatibility just in case.
|
# canmount=off, but ignore it for backwards compatibility just in case.
|
||||||
@ -389,9 +401,11 @@ mount_fs()
|
|||||||
decrypt_fs "${_mount_fs}"
|
decrypt_fs "${_mount_fs}"
|
||||||
|
|
||||||
[ "${quiet}" != "y" ] && \
|
[ "${quiet}" != "y" ] && \
|
||||||
zfs_log_begin_msg "Mounting '${_mount_fs}' on '${rootmnt}/${_mountpoint}'"
|
zfs_log_begin_msg \
|
||||||
|
"Mounting '${_mount_fs}' on '${rootmnt}/${_mountpoint}'"
|
||||||
[ -n "${ZFS_DEBUG}" ] && \
|
[ -n "${ZFS_DEBUG}" ] && \
|
||||||
zfs_log_begin_msg "CMD: '${ZFS_CMD} ${_mount_fs} ${rootmnt}/${_mountpoint}'"
|
zfs_log_begin_msg \
|
||||||
|
"CMD: '${ZFS_CMD} ${_mount_fs} ${rootmnt}/${_mountpoint}'"
|
||||||
|
|
||||||
ZFS_STDERR="$(${ZFS_CMD} "${_mount_fs}" "${rootmnt}/${_mountpoint}" 2>&1)"
|
ZFS_STDERR="$(${ZFS_CMD} "${_mount_fs}" "${rootmnt}/${_mountpoint}" 2>&1)"
|
||||||
ZFS_ERROR="${?}"
|
ZFS_ERROR="${?}"
|
||||||
@ -420,8 +434,10 @@ decrypt_fs()
|
|||||||
{
|
{
|
||||||
_decrypt_fs="${1}"
|
_decrypt_fs="${1}"
|
||||||
|
|
||||||
# If pool encryption is active and the zfs command understands '-o encryption'
|
# If pool encryption is active and the zfs command understands
|
||||||
if [ "$("${ZPOOL}" list -H -o feature@encryption "${_decrypt_fs%%/*}")" = 'active' ]
|
# '-o encryption'.
|
||||||
|
_enc="$("${ZPOOL}" list -H -o feature@encryption "${_decrypt_fs%%/*}")"
|
||||||
|
if [ "${_enc}" = 'active' ]
|
||||||
then
|
then
|
||||||
# Determine dataset that holds key for root dataset
|
# Determine dataset that holds key for root dataset
|
||||||
ENCRYPTIONROOT="$(get_fs_value "${_decrypt_fs}" encryptionroot)"
|
ENCRYPTIONROOT="$(get_fs_value "${_decrypt_fs}" encryptionroot)"
|
||||||
@ -437,7 +453,8 @@ decrypt_fs()
|
|||||||
[ "${KEYSTATUS}" = "unavailable" ] || return 0
|
[ "${KEYSTATUS}" = "unavailable" ] || return 0
|
||||||
|
|
||||||
# Try extensions first
|
# Try extensions first
|
||||||
for key in "/etc/zfs/initramfs-tools-load-key" "/etc/zfs/initramfs-tools-load-key.d/"*
|
for key in "/etc/zfs/initramfs-tools-load-key" \
|
||||||
|
"/etc/zfs/initramfs-tools-load-key.d/"*
|
||||||
do
|
do
|
||||||
[ -r "${key}" ] || continue
|
[ -r "${key}" ] || continue
|
||||||
(. "${key}") && {
|
(. "${key}") && {
|
||||||
@ -458,7 +475,8 @@ decrypt_fs()
|
|||||||
echo "plymouth" > /run/zfs_console_askpwd_cmd
|
echo "plymouth" > /run/zfs_console_askpwd_cmd
|
||||||
for _ in 1 2 3
|
for _ in 1 2 3
|
||||||
do
|
do
|
||||||
plymouth ask-for-password --prompt "Encrypted ZFS password for ${ENCRYPTIONROOT}" | \
|
plymouth ask-for-password --prompt \
|
||||||
|
"Encrypted ZFS password for ${ENCRYPTIONROOT}" | \
|
||||||
"${ZFS}" load-key "${ENCRYPTIONROOT}" && break
|
"${ZFS}" load-key "${ENCRYPTIONROOT}" && break
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -468,13 +486,16 @@ decrypt_fs()
|
|||||||
echo "systemd-ask-password" > /run/zfs_console_askpwd_cmd
|
echo "systemd-ask-password" > /run/zfs_console_askpwd_cmd
|
||||||
for _ in 1 2 3
|
for _ in 1 2 3
|
||||||
do
|
do
|
||||||
systemd-ask-password --no-tty "Encrypted ZFS password for ${ENCRYPTIONROOT}" | \
|
systemd-ask-password \
|
||||||
|
--no-tty \
|
||||||
|
"Encrypted ZFS password for ${ENCRYPTIONROOT}" | \
|
||||||
"${ZFS}" load-key "${ENCRYPTIONROOT}" && break
|
"${ZFS}" load-key "${ENCRYPTIONROOT}" && break
|
||||||
done
|
done
|
||||||
|
|
||||||
# Prompt with ZFS tty, otherwise
|
# Prompt with ZFS tty, otherwise
|
||||||
else
|
else
|
||||||
# Temporarily setting "printk" to "7" allows the prompt to appear even when the "quiet" kernel option has been used
|
# Temporarily setting "printk" to "7" allows the prompt to
|
||||||
|
# appear even when the "quiet" kernel option has been used.
|
||||||
echo "load-key" > /run/zfs_console_askpwd_cmd
|
echo "load-key" > /run/zfs_console_askpwd_cmd
|
||||||
read -r storeprintk _ < /proc/sys/kernel/printk
|
read -r storeprintk _ < /proc/sys/kernel/printk
|
||||||
echo 7 > /proc/sys/kernel/printk
|
echo 7 > /proc/sys/kernel/printk
|
||||||
@ -508,9 +529,11 @@ destroy_fs()
|
|||||||
echo "Message: ${ZFS_STDERR}"
|
echo "Message: ${ZFS_STDERR}"
|
||||||
echo "Error: ${ZFS_ERROR}"
|
echo "Error: ${ZFS_ERROR}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Failed to destroy '${_destroy_fs}'. Please make sure that it is not available."
|
echo "Failed to destroy '${_destroy_fs}'."
|
||||||
|
echo "Please make sure that it is not available."
|
||||||
echo "Hint: Try: zfs destroy -Rfn ${_destroy_fs}"
|
echo "Hint: Try: zfs destroy -Rfn ${_destroy_fs}"
|
||||||
echo "If this dryrun looks good, then remove the 'n' from '-Rfn' and try again."
|
echo "If this dryrun looks good, then remove the 'n' from '-Rfn'" \
|
||||||
|
"and try again."
|
||||||
shell
|
shell
|
||||||
else
|
else
|
||||||
[ "${quiet}" != "y" ] && zfs_log_end_msg
|
[ "${quiet}" != "y" ] && zfs_log_end_msg
|
||||||
@ -529,7 +552,8 @@ clone_snap()
|
|||||||
_clone_destfs="${2}"
|
_clone_destfs="${2}"
|
||||||
_clone_mountpoint="${3}"
|
_clone_mountpoint="${3}"
|
||||||
|
|
||||||
[ "${quiet}" != "y" ] && zfs_log_begin_msg "Cloning '${_clone_snap}' to '${_clone_destfs}'"
|
[ "${quiet}" != "y" ] && \
|
||||||
|
zfs_log_begin_msg "Cloning '${_clone_snap}' to '${_clone_destfs}'"
|
||||||
|
|
||||||
# Clone the snapshot into a dataset we can boot from
|
# Clone the snapshot into a dataset we can boot from
|
||||||
# + We don't want this filesystem to be automatically mounted, we
|
# + We don't want this filesystem to be automatically mounted, we
|
||||||
@ -659,7 +683,7 @@ setup_snapshot_booting()
|
|||||||
_snapname="${_boot_snap##*@}"
|
_snapname="${_boot_snap##*@}"
|
||||||
ZFS_BOOTFS="${_rootfs}_${_snapname}"
|
ZFS_BOOTFS="${_rootfs}_${_snapname}"
|
||||||
|
|
||||||
if ! grep -qiE '(^|[^\\](\\\\)* )(rollback)=(on|yes|1)( |$)' /proc/cmdline
|
if ! get_cmdline 'rollback'
|
||||||
then
|
then
|
||||||
# If the destination dataset for the clone
|
# If the destination dataset for the clone
|
||||||
# already exists, destroy it. Recursively
|
# already exists, destroy it. Recursively
|
||||||
@ -679,7 +703,7 @@ setup_snapshot_booting()
|
|||||||
for s in $("${ZFS}" list -H -oname -tsnapshot -r "${_rootfs}" | \
|
for s in $("${ZFS}" list -H -oname -tsnapshot -r "${_rootfs}" | \
|
||||||
grep "${_snapname}")
|
grep "${_snapname}")
|
||||||
do
|
do
|
||||||
if grep -qiE '(^|[^\\](\\\\)* )(rollback)=(on|yes|1)( |$)' /proc/cmdline
|
if get_cmdline 'rollback'
|
||||||
then
|
then
|
||||||
# Rollback snapshot
|
# Rollback snapshot
|
||||||
rollback_snap "${s}" || _retval="$((_retval + 1))"
|
rollback_snap "${s}" || _retval="$((_retval + 1))"
|
||||||
@ -687,10 +711,10 @@ setup_snapshot_booting()
|
|||||||
else
|
else
|
||||||
# Setup a destination filesystem name.
|
# Setup a destination filesystem name.
|
||||||
# Ex: Called with 'rpool/ROOT/debian@snap2'
|
# Ex: Called with 'rpool/ROOT/debian@snap2'
|
||||||
# rpool/ROOT/debian@snap2 => rpool/ROOT/debian_snap2
|
# rpool/ROOT/debian@snap2 => rpool/ROOT/debian_snap2
|
||||||
# rpool/ROOT/debian/boot@snap2 => rpool/ROOT/debian_snap2/boot
|
# rpool/ROOT/debian/boot@snap2 => rpool/ROOT/debian_snap2/boot
|
||||||
# rpool/ROOT/debian/usr@snap2 => rpool/ROOT/debian_snap2/usr
|
# rpool/ROOT/debian/usr@snap2 => rpool/ROOT/debian_snap2/usr
|
||||||
# rpool/ROOT/debian/var@snap2 => rpool/ROOT/debian_snap2/var
|
# rpool/ROOT/debian/var@snap2 => rpool/ROOT/debian_snap2/var
|
||||||
_subfs="${s##"${_rootfs}"}"
|
_subfs="${s##"${_rootfs}"}"
|
||||||
_subfs="${_subfs%%@"${_snapname}"}"
|
_subfs="${_subfs%%@"${_snapname}"}"
|
||||||
|
|
||||||
@ -737,7 +761,7 @@ mountroot()
|
|||||||
|
|
||||||
# ------------
|
# ------------
|
||||||
# Support debug option
|
# Support debug option
|
||||||
if grep -qiE '(^|[^\\](\\\\)* )(zfs_debug|zfs\.debug|zfsdebug)=(on|yes|1)( |$)' /proc/cmdline
|
if get_cmdline 'zfs_debug|zfs\.debug|zfsdebug'
|
||||||
then
|
then
|
||||||
ZFS_DEBUG=1
|
ZFS_DEBUG=1
|
||||||
mkdir /var/log
|
mkdir /var/log
|
||||||
@ -794,22 +818,22 @@ mountroot()
|
|||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
# P A R S E C O M M A N D L I N E O P T I O N S
|
# P A R S E C O M M A N D L I N E O P T I O N S
|
||||||
|
|
||||||
# This part is the really ugly part - there's so many options and permutations
|
# This part is the really ugly part - there's so many options and
|
||||||
# 'out there', and if we should make this the 'primary' source for ZFS initrd
|
# permutations 'out there', and if we should make this the 'primary'
|
||||||
# scripting, we need/should support them all.
|
# source for ZFS initrd scripting, we need/should support them all.
|
||||||
#
|
#
|
||||||
# Supports the following kernel command line argument combinations
|
# Supports the following kernel command line argument combinations
|
||||||
# (in this order - first match win):
|
# (in this order - first match win):
|
||||||
#
|
#
|
||||||
# rpool=<pool> (tries to finds bootfs automatically)
|
# rpool=<pool> (tries to finds bootfs automatically)
|
||||||
# bootfs=<pool>/<dataset> (uses this for rpool - first part)
|
# bootfs=<pool>/<dataset> (uses this for rpool - first part)
|
||||||
# rpool=<pool> bootfs=<pool>/<dataset>
|
# rpool=<pool> bootfs=<pool>/<dataset>
|
||||||
# -B zfs-bootfs=<pool>/<fs> (uses this for rpool - first part)
|
# -B zfs-bootfs=<pool>/<fs> (uses this for rpool - first part)
|
||||||
# rpool=rpool (default if none of the above is used)
|
# rpool=rpool (default if none of the above is used)
|
||||||
# root=<pool>/<dataset> (uses this for rpool - first part)
|
# root=<pool>/<dataset> (uses this for rpool - first part)
|
||||||
# root=ZFS=<pool>/<dataset> (uses this for rpool - first part, without 'ZFS=')
|
# root=ZFS=<pool>/<dataset> (uses this for rpool - first part, without 'ZFS=')
|
||||||
# root=zfs:AUTO (tries to detect both pool and rootfs)
|
# root=zfs:AUTO (tries to detect both pool and rootfs)
|
||||||
# root=zfs:<pool>/<dataset> (uses this for rpool - first part, without 'zfs:')
|
# root=zfs:<pool>/<dataset> (uses this for rpool - first part, without 'zfs:')
|
||||||
#
|
#
|
||||||
# Option <dataset> could also be <snapshot>
|
# Option <dataset> could also be <snapshot>
|
||||||
# Option <pool> could also be <guid>
|
# Option <pool> could also be <guid>
|
||||||
@ -821,7 +845,7 @@ mountroot()
|
|||||||
# This should (almost) never be needed, but it's here for
|
# This should (almost) never be needed, but it's here for
|
||||||
# completeness.
|
# completeness.
|
||||||
ZPOOL_FORCE=""
|
ZPOOL_FORCE=""
|
||||||
if grep -qiE '(^|[^\\](\\\\)* )(zfs_force|zfs\.force|zfsforce)=(on|yes|1)( |$)' /proc/cmdline
|
if get_cmdline 'zfs_force|zfs\.force|zfsforce'
|
||||||
then
|
then
|
||||||
ZPOOL_FORCE="-f"
|
ZPOOL_FORCE="-f"
|
||||||
fi
|
fi
|
||||||
@ -969,7 +993,8 @@ mountroot()
|
|||||||
echo " not specified on the kernel command line."
|
echo " not specified on the kernel command line."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Manually mount the root filesystem on ${rootmnt} and then exit."
|
echo "Manually mount the root filesystem on ${rootmnt} and then exit."
|
||||||
echo "Hint: Try: mount -o zfsutil -t zfs ${ZFS_RPOOL:-rpool}/ROOT/system ${rootmnt}"
|
echo "Hint: Try: mount -o zfsutil -t zfs " \
|
||||||
|
"${ZFS_RPOOL:-rpool}/ROOT/system ${rootmnt}"
|
||||||
shell
|
shell
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user