dracut: use /bin/sh instead of bash as the intepreter
Despite that dracut has a hard dependency on bash,
its modules doesn't, dracut only has a hard dependency on bash for
module-setup (on a fully usable machine). Inside initramfs, dracut
allows users choose from a list of handful other shells, e.g. bash,
busybox, dash, mkfsh.
In fact, my local machine's initramfs is being built with dash,
and it's functional for a very long time.
Before 64025fa3a (Silence 'make checkbashisms', 2020-08-20), we also
allows our users to have that right, too.
Let's fix the problem 'make checkbashisms' reported and allows our users
to have that right, again.
For 'plymouth' case, let's simply run the command inside the if instead
of checking for the existence of command before running it, because the
status is also failture if plymouth is unavailable.
While we're at it, let's remove an unnecessary fork for grep in
zfs-generator.sh.in and its following complicated 'if elif fi' with
a simple 'case ... esac'.
To support this change, also exclude 90zfs from "make checkbashisms"
because the current CI infrastructure ships an old version of
"checkbashisms", which complains about "command -v", while the current
latest "checkbashisms" thinks it's fine. In the near future, we can
revert that change to "Makefile.am" when CI infrastructure is updated.
Reviewed-by: Gabriel A. Devenyi <gdevenyi@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Closes #11244
2020-11-28 22:02:08 +03:00
|
|
|
#!/bin/sh
|
2015-02-15 22:28:42 +03:00
|
|
|
|
2015-02-16 12:16:46 +03:00
|
|
|
command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
2016-04-24 14:35:44 +03:00
|
|
|
command -v getargbool >/dev/null || {
|
|
|
|
# Compatibility with older Dracut versions.
|
|
|
|
# With apologies to the Dracut developers.
|
|
|
|
getargbool() {
|
|
|
|
_default="$1"; shift
|
2021-05-14 12:55:17 +03:00
|
|
|
! _b=$(getarg "$@") && [ -z "$_b" ] && _b="$_default"
|
2016-04-24 14:35:44 +03:00
|
|
|
if [ -n "$_b" ]; then
|
2018-02-22 04:54:54 +03:00
|
|
|
[ "$_b" = "0" ] && return 1
|
|
|
|
[ "$_b" = "no" ] && return 1
|
|
|
|
[ "$_b" = "off" ] && return 1
|
2016-04-24 14:35:44 +03:00
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
2015-02-15 22:28:42 +03:00
|
|
|
|
|
|
|
OLDIFS="${IFS}"
|
|
|
|
NEWLINE="
|
|
|
|
"
|
contrib/dracut: 90: mount essential datasets under root
This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order
The following extreme-case set-up boots w/o issues now:
/ zoot zfs rw,relatime,xattr,noacl
├─/etc zoot/etc zfs rw,relatime,xattr,noacl
├─/usr zoot/usr zfs rw,relatime,xattr,noacl
│ └─/usr/local zoot/usr/local zfs rw,relatime,xattr,noacl
├─/var zoot/var zfs rw,relatime,xattr,noacl
│ ├─/var/lib zoot/var/lib zfs rw,relatime,xattr,noacl
│ ├─/var/log zoot/var/log zfs rw,relatime,xattr,posixacl
│ ├─/var/cache zoot/var/cache zfs rw,relatime,xattr,noacl
│ └─/var/tmp zoot/var/tmp zfs rw,relatime,xattr,noacl
├─/home zoot/home zfs rw,relatime,xattr,noacl
│ └─/home/nab zoot/home/nab zfs rw,relatime,xattr,noacl
├─/boot zoot/boot zfs rw,relatime,xattr,noacl
├─/root zoot/home/root zfs rw,relatime,xattr,noacl
├─/opt zoot/opt zfs rw,relatime,xattr,noacl
└─/srv zoot/srv zfs rw,relatime,xattr,noacl
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11898
2021-04-13 23:41:10 +03:00
|
|
|
TAB=" "
|
2015-02-15 22:28:42 +03:00
|
|
|
|
|
|
|
ZPOOL_IMPORT_OPTS=""
|
|
|
|
if getargbool 0 zfs_force -y zfs.force -y zfsforce ; then
|
2018-02-22 04:54:54 +03:00
|
|
|
warn "ZFS: Will force-import pools if necessary."
|
|
|
|
ZPOOL_IMPORT_OPTS="${ZPOOL_IMPORT_OPTS} -f"
|
2015-02-15 22:28:42 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# find_bootfs
|
|
|
|
# returns the first dataset with the bootfs attribute.
|
|
|
|
find_bootfs() {
|
2018-02-22 04:54:54 +03:00
|
|
|
IFS="${NEWLINE}"
|
|
|
|
for dataset in $(zpool list -H -o bootfs); do
|
|
|
|
case "${dataset}" in
|
|
|
|
"" | "-")
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
"no pools available")
|
|
|
|
IFS="${OLDIFS}"
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
IFS="${OLDIFS}"
|
|
|
|
echo "${dataset}"
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
IFS="${OLDIFS}"
|
|
|
|
return 1
|
2015-02-15 22:28:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# import_pool POOL
|
|
|
|
# imports the given zfs pool if it isn't imported already.
|
|
|
|
import_pool() {
|
contrib/dracut: 90: mount essential datasets under root
This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order
The following extreme-case set-up boots w/o issues now:
/ zoot zfs rw,relatime,xattr,noacl
├─/etc zoot/etc zfs rw,relatime,xattr,noacl
├─/usr zoot/usr zfs rw,relatime,xattr,noacl
│ └─/usr/local zoot/usr/local zfs rw,relatime,xattr,noacl
├─/var zoot/var zfs rw,relatime,xattr,noacl
│ ├─/var/lib zoot/var/lib zfs rw,relatime,xattr,noacl
│ ├─/var/log zoot/var/log zfs rw,relatime,xattr,posixacl
│ ├─/var/cache zoot/var/cache zfs rw,relatime,xattr,noacl
│ └─/var/tmp zoot/var/tmp zfs rw,relatime,xattr,noacl
├─/home zoot/home zfs rw,relatime,xattr,noacl
│ └─/home/nab zoot/home/nab zfs rw,relatime,xattr,noacl
├─/boot zoot/boot zfs rw,relatime,xattr,noacl
├─/root zoot/home/root zfs rw,relatime,xattr,noacl
├─/opt zoot/opt zfs rw,relatime,xattr,noacl
└─/srv zoot/srv zfs rw,relatime,xattr,noacl
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11898
2021-04-13 23:41:10 +03:00
|
|
|
pool="${1}"
|
2015-02-15 22:28:42 +03:00
|
|
|
|
2018-02-22 04:54:54 +03:00
|
|
|
if ! zpool list -H "${pool}" > /dev/null 2>&1; then
|
|
|
|
info "ZFS: Importing pool ${pool}..."
|
Trim excess shellcheck annotations. Widen to all non-Korn scripts
Before, make shellcheck checked
scripts/{commitcheck,make_gitrev,man-dates,paxcheck,zfs-helpers,zfs,
zfs-tests,zimport,zloop}.sh
cmd/zed/zed.d/{{all-debug,all-syslog,data-notify,generic-notify,
resilver_finish-start-scrub,scrub_finish-notify,
statechange-led,statechange-notify,trim_finish-notify,
zed-functions}.sh,history_event-zfs-list-cacher.sh.in}
cmd/zpool/zpool.d/{dm-deps,iostat,lsblk,media,ses,smart,upath}
now it also checks
contrib/dracut/{02zfsexpandknowledge/module-setup,
90zfs/{export-zfs,parse-zfs,zfs-needshutdown,
zfs-load-key,zfs-lib,module-setup,
mount-zfs,zfs-generator}}.sh.in
cmd/zed/zed.d/{pool_import-led,vdev_attach-led,
resilver_finish-notify,vdev_clear-led}.sh
contrib/initramfs/{zfsunlock,hooks/zfs.in,scripts/local-top/zfs}
tests/zfs-tests/tests/perf/scripts/prefetch_io.sh
scripts/common.sh.in
contrib/bpftrace/zfs-trace.sh
autogen.sh
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12042
2021-05-14 15:02:11 +03:00
|
|
|
# shellcheck disable=SC2086
|
2018-02-22 04:54:54 +03:00
|
|
|
if ! zpool import -N ${ZPOOL_IMPORT_OPTS} "${pool}" ; then
|
|
|
|
warn "ZFS: Unable to import pool ${pool}"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
2015-02-15 22:28:42 +03:00
|
|
|
|
2018-02-22 04:54:54 +03:00
|
|
|
return 0
|
2015-02-15 22:28:42 +03:00
|
|
|
}
|
|
|
|
|
contrib/dracut: 90: mount essential datasets under root
This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order
The following extreme-case set-up boots w/o issues now:
/ zoot zfs rw,relatime,xattr,noacl
├─/etc zoot/etc zfs rw,relatime,xattr,noacl
├─/usr zoot/usr zfs rw,relatime,xattr,noacl
│ └─/usr/local zoot/usr/local zfs rw,relatime,xattr,noacl
├─/var zoot/var zfs rw,relatime,xattr,noacl
│ ├─/var/lib zoot/var/lib zfs rw,relatime,xattr,noacl
│ ├─/var/log zoot/var/log zfs rw,relatime,xattr,posixacl
│ ├─/var/cache zoot/var/cache zfs rw,relatime,xattr,noacl
│ └─/var/tmp zoot/var/tmp zfs rw,relatime,xattr,noacl
├─/home zoot/home zfs rw,relatime,xattr,noacl
│ └─/home/nab zoot/home/nab zfs rw,relatime,xattr,noacl
├─/boot zoot/boot zfs rw,relatime,xattr,noacl
├─/root zoot/home/root zfs rw,relatime,xattr,noacl
├─/opt zoot/opt zfs rw,relatime,xattr,noacl
└─/srv zoot/srv zfs rw,relatime,xattr,noacl
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11898
2021-04-13 23:41:10 +03:00
|
|
|
_mount_dataset_cb() {
|
2021-11-30 21:23:10 +03:00
|
|
|
# shellcheck disable=SC2154
|
contrib/dracut: 90: mount essential datasets under root
This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order
The following extreme-case set-up boots w/o issues now:
/ zoot zfs rw,relatime,xattr,noacl
├─/etc zoot/etc zfs rw,relatime,xattr,noacl
├─/usr zoot/usr zfs rw,relatime,xattr,noacl
│ └─/usr/local zoot/usr/local zfs rw,relatime,xattr,noacl
├─/var zoot/var zfs rw,relatime,xattr,noacl
│ ├─/var/lib zoot/var/lib zfs rw,relatime,xattr,noacl
│ ├─/var/log zoot/var/log zfs rw,relatime,xattr,posixacl
│ ├─/var/cache zoot/var/cache zfs rw,relatime,xattr,noacl
│ └─/var/tmp zoot/var/tmp zfs rw,relatime,xattr,noacl
├─/home zoot/home zfs rw,relatime,xattr,noacl
│ └─/home/nab zoot/home/nab zfs rw,relatime,xattr,noacl
├─/boot zoot/boot zfs rw,relatime,xattr,noacl
├─/root zoot/home/root zfs rw,relatime,xattr,noacl
├─/opt zoot/opt zfs rw,relatime,xattr,noacl
└─/srv zoot/srv zfs rw,relatime,xattr,noacl
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11898
2021-04-13 23:41:10 +03:00
|
|
|
mount -o zfsutil -t zfs "${1}" "${NEWROOT}${2}"
|
|
|
|
}
|
|
|
|
|
2015-02-15 22:28:42 +03:00
|
|
|
# mount_dataset DATASET
|
|
|
|
# mounts the given zfs dataset.
|
|
|
|
mount_dataset() {
|
contrib/dracut: 90: mount essential datasets under root
This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order
The following extreme-case set-up boots w/o issues now:
/ zoot zfs rw,relatime,xattr,noacl
├─/etc zoot/etc zfs rw,relatime,xattr,noacl
├─/usr zoot/usr zfs rw,relatime,xattr,noacl
│ └─/usr/local zoot/usr/local zfs rw,relatime,xattr,noacl
├─/var zoot/var zfs rw,relatime,xattr,noacl
│ ├─/var/lib zoot/var/lib zfs rw,relatime,xattr,noacl
│ ├─/var/log zoot/var/log zfs rw,relatime,xattr,posixacl
│ ├─/var/cache zoot/var/cache zfs rw,relatime,xattr,noacl
│ └─/var/tmp zoot/var/tmp zfs rw,relatime,xattr,noacl
├─/home zoot/home zfs rw,relatime,xattr,noacl
│ └─/home/nab zoot/home/nab zfs rw,relatime,xattr,noacl
├─/boot zoot/boot zfs rw,relatime,xattr,noacl
├─/root zoot/home/root zfs rw,relatime,xattr,noacl
├─/opt zoot/opt zfs rw,relatime,xattr,noacl
└─/srv zoot/srv zfs rw,relatime,xattr,noacl
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11898
2021-04-13 23:41:10 +03:00
|
|
|
dataset="${1}"
|
2018-02-22 04:54:54 +03:00
|
|
|
mountpoint="$(zfs get -H -o value mountpoint "${dataset}")"
|
contrib/dracut: 90: mount essential datasets under root
This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order
The following extreme-case set-up boots w/o issues now:
/ zoot zfs rw,relatime,xattr,noacl
├─/etc zoot/etc zfs rw,relatime,xattr,noacl
├─/usr zoot/usr zfs rw,relatime,xattr,noacl
│ └─/usr/local zoot/usr/local zfs rw,relatime,xattr,noacl
├─/var zoot/var zfs rw,relatime,xattr,noacl
│ ├─/var/lib zoot/var/lib zfs rw,relatime,xattr,noacl
│ ├─/var/log zoot/var/log zfs rw,relatime,xattr,posixacl
│ ├─/var/cache zoot/var/cache zfs rw,relatime,xattr,noacl
│ └─/var/tmp zoot/var/tmp zfs rw,relatime,xattr,noacl
├─/home zoot/home zfs rw,relatime,xattr,noacl
│ └─/home/nab zoot/home/nab zfs rw,relatime,xattr,noacl
├─/boot zoot/boot zfs rw,relatime,xattr,noacl
├─/root zoot/home/root zfs rw,relatime,xattr,noacl
├─/opt zoot/opt zfs rw,relatime,xattr,noacl
└─/srv zoot/srv zfs rw,relatime,xattr,noacl
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11898
2021-04-13 23:41:10 +03:00
|
|
|
ret=0
|
2015-02-15 22:28:42 +03:00
|
|
|
|
2018-02-22 04:54:54 +03:00
|
|
|
# We need zfsutil for non-legacy mounts and not for legacy mounts.
|
|
|
|
if [ "${mountpoint}" = "legacy" ] ; then
|
contrib/dracut: 90: mount essential datasets under root
This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order
The following extreme-case set-up boots w/o issues now:
/ zoot zfs rw,relatime,xattr,noacl
├─/etc zoot/etc zfs rw,relatime,xattr,noacl
├─/usr zoot/usr zfs rw,relatime,xattr,noacl
│ └─/usr/local zoot/usr/local zfs rw,relatime,xattr,noacl
├─/var zoot/var zfs rw,relatime,xattr,noacl
│ ├─/var/lib zoot/var/lib zfs rw,relatime,xattr,noacl
│ ├─/var/log zoot/var/log zfs rw,relatime,xattr,posixacl
│ ├─/var/cache zoot/var/cache zfs rw,relatime,xattr,noacl
│ └─/var/tmp zoot/var/tmp zfs rw,relatime,xattr,noacl
├─/home zoot/home zfs rw,relatime,xattr,noacl
│ └─/home/nab zoot/home/nab zfs rw,relatime,xattr,noacl
├─/boot zoot/boot zfs rw,relatime,xattr,noacl
├─/root zoot/home/root zfs rw,relatime,xattr,noacl
├─/opt zoot/opt zfs rw,relatime,xattr,noacl
└─/srv zoot/srv zfs rw,relatime,xattr,noacl
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11898
2021-04-13 23:41:10 +03:00
|
|
|
mount -t zfs "${dataset}" "${NEWROOT}" || ret=$?
|
2018-02-22 04:54:54 +03:00
|
|
|
else
|
contrib/dracut: 90: mount essential datasets under root
This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order
The following extreme-case set-up boots w/o issues now:
/ zoot zfs rw,relatime,xattr,noacl
├─/etc zoot/etc zfs rw,relatime,xattr,noacl
├─/usr zoot/usr zfs rw,relatime,xattr,noacl
│ └─/usr/local zoot/usr/local zfs rw,relatime,xattr,noacl
├─/var zoot/var zfs rw,relatime,xattr,noacl
│ ├─/var/lib zoot/var/lib zfs rw,relatime,xattr,noacl
│ ├─/var/log zoot/var/log zfs rw,relatime,xattr,posixacl
│ ├─/var/cache zoot/var/cache zfs rw,relatime,xattr,noacl
│ └─/var/tmp zoot/var/tmp zfs rw,relatime,xattr,noacl
├─/home zoot/home zfs rw,relatime,xattr,noacl
│ └─/home/nab zoot/home/nab zfs rw,relatime,xattr,noacl
├─/boot zoot/boot zfs rw,relatime,xattr,noacl
├─/root zoot/home/root zfs rw,relatime,xattr,noacl
├─/opt zoot/opt zfs rw,relatime,xattr,noacl
└─/srv zoot/srv zfs rw,relatime,xattr,noacl
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11898
2021-04-13 23:41:10 +03:00
|
|
|
mount -o zfsutil -t zfs "${dataset}" "${NEWROOT}" || ret=$?
|
|
|
|
|
|
|
|
if [ "$ret" = "0" ]; then
|
|
|
|
for_relevant_root_children "${dataset}" _mount_dataset_cb || ret=$?
|
|
|
|
fi
|
2018-02-22 04:54:54 +03:00
|
|
|
fi
|
2015-02-15 22:28:42 +03:00
|
|
|
|
2021-11-30 21:23:10 +03:00
|
|
|
return "${ret}"
|
contrib/dracut: 90: mount essential datasets under root
This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order
The following extreme-case set-up boots w/o issues now:
/ zoot zfs rw,relatime,xattr,noacl
├─/etc zoot/etc zfs rw,relatime,xattr,noacl
├─/usr zoot/usr zfs rw,relatime,xattr,noacl
│ └─/usr/local zoot/usr/local zfs rw,relatime,xattr,noacl
├─/var zoot/var zfs rw,relatime,xattr,noacl
│ ├─/var/lib zoot/var/lib zfs rw,relatime,xattr,noacl
│ ├─/var/log zoot/var/log zfs rw,relatime,xattr,posixacl
│ ├─/var/cache zoot/var/cache zfs rw,relatime,xattr,noacl
│ └─/var/tmp zoot/var/tmp zfs rw,relatime,xattr,noacl
├─/home zoot/home zfs rw,relatime,xattr,noacl
│ └─/home/nab zoot/home/nab zfs rw,relatime,xattr,noacl
├─/boot zoot/boot zfs rw,relatime,xattr,noacl
├─/root zoot/home/root zfs rw,relatime,xattr,noacl
├─/opt zoot/opt zfs rw,relatime,xattr,noacl
└─/srv zoot/srv zfs rw,relatime,xattr,noacl
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11898
2021-04-13 23:41:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# for_relevant_root_children DATASET EXEC
|
|
|
|
# Runs "EXEC dataset mountpoint" for all children of DATASET that are needed for system bringup
|
|
|
|
# Used by zfs-generator.sh and friends, too!
|
|
|
|
for_relevant_root_children() {
|
|
|
|
dataset="${1}"
|
|
|
|
exec="${2}"
|
|
|
|
|
|
|
|
zfs list -t filesystem -Ho name,mountpoint,canmount -r "${dataset}" |
|
|
|
|
(
|
|
|
|
_ret=0
|
|
|
|
while IFS="${TAB}" read -r dataset mountpoint canmount; do
|
|
|
|
[ "$canmount" != "on" ] && continue
|
|
|
|
|
|
|
|
case "$mountpoint" in
|
|
|
|
/etc|/bin|/lib|/lib??|/libx32|/usr)
|
|
|
|
# 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
|
|
|
|
"${exec}" "${dataset}" "${mountpoint}" || _ret=$?
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# Up to the real init to remount everything else it might need
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2021-11-30 21:23:10 +03:00
|
|
|
exit "${_ret}"
|
contrib/dracut: 90: mount essential datasets under root
This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order
The following extreme-case set-up boots w/o issues now:
/ zoot zfs rw,relatime,xattr,noacl
├─/etc zoot/etc zfs rw,relatime,xattr,noacl
├─/usr zoot/usr zfs rw,relatime,xattr,noacl
│ └─/usr/local zoot/usr/local zfs rw,relatime,xattr,noacl
├─/var zoot/var zfs rw,relatime,xattr,noacl
│ ├─/var/lib zoot/var/lib zfs rw,relatime,xattr,noacl
│ ├─/var/log zoot/var/log zfs rw,relatime,xattr,posixacl
│ ├─/var/cache zoot/var/cache zfs rw,relatime,xattr,noacl
│ └─/var/tmp zoot/var/tmp zfs rw,relatime,xattr,noacl
├─/home zoot/home zfs rw,relatime,xattr,noacl
│ └─/home/nab zoot/home/nab zfs rw,relatime,xattr,noacl
├─/boot zoot/boot zfs rw,relatime,xattr,noacl
├─/root zoot/home/root zfs rw,relatime,xattr,noacl
├─/opt zoot/opt zfs rw,relatime,xattr,noacl
└─/srv zoot/srv zfs rw,relatime,xattr,noacl
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11898
2021-04-13 23:41:10 +03:00
|
|
|
)
|
2015-02-15 22:28:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# export_all OPTS
|
|
|
|
# exports all imported zfs pools.
|
|
|
|
export_all() {
|
2018-02-22 04:54:54 +03:00
|
|
|
ret=0
|
|
|
|
|
|
|
|
IFS="${NEWLINE}"
|
|
|
|
for pool in $(zpool list -H -o name) ; do
|
|
|
|
if zpool list -H "${pool}" > /dev/null 2>&1; then
|
Trim excess shellcheck annotations. Widen to all non-Korn scripts
Before, make shellcheck checked
scripts/{commitcheck,make_gitrev,man-dates,paxcheck,zfs-helpers,zfs,
zfs-tests,zimport,zloop}.sh
cmd/zed/zed.d/{{all-debug,all-syslog,data-notify,generic-notify,
resilver_finish-start-scrub,scrub_finish-notify,
statechange-led,statechange-notify,trim_finish-notify,
zed-functions}.sh,history_event-zfs-list-cacher.sh.in}
cmd/zpool/zpool.d/{dm-deps,iostat,lsblk,media,ses,smart,upath}
now it also checks
contrib/dracut/{02zfsexpandknowledge/module-setup,
90zfs/{export-zfs,parse-zfs,zfs-needshutdown,
zfs-load-key,zfs-lib,module-setup,
mount-zfs,zfs-generator}}.sh.in
cmd/zed/zed.d/{pool_import-led,vdev_attach-led,
resilver_finish-notify,vdev_clear-led}.sh
contrib/initramfs/{zfsunlock,hooks/zfs.in,scripts/local-top/zfs}
tests/zfs-tests/tests/perf/scripts/prefetch_io.sh
scripts/common.sh.in
contrib/bpftrace/zfs-trace.sh
autogen.sh
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12042
2021-05-14 15:02:11 +03:00
|
|
|
zpool export "${pool}" "$@" || ret=$?
|
2018-02-22 04:54:54 +03:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS="${OLDIFS}"
|
|
|
|
|
2021-11-30 21:23:10 +03:00
|
|
|
return "${ret}"
|
2015-02-15 22:28:42 +03:00
|
|
|
}
|
2018-02-20 21:13:20 +03:00
|
|
|
|
|
|
|
# ask_for_password
|
|
|
|
#
|
|
|
|
# Wraps around plymouth ask-for-password and adds fallback to tty password ask
|
|
|
|
# if plymouth is not present.
|
|
|
|
#
|
|
|
|
# --cmd command
|
|
|
|
# Command to execute. Required.
|
|
|
|
# --prompt prompt
|
|
|
|
# Password prompt. Note that function already adds ':' at the end.
|
|
|
|
# Recommended.
|
|
|
|
# --tries n
|
|
|
|
# How many times repeat command on its failure. Default is 3.
|
|
|
|
# --ply-[cmd|prompt|tries]
|
|
|
|
# Command/prompt/tries specific for plymouth password ask only.
|
|
|
|
# --tty-[cmd|prompt|tries]
|
|
|
|
# Command/prompt/tries specific for tty password ask only.
|
|
|
|
# --tty-echo-off
|
|
|
|
# Turn off input echo before tty command is executed and turn on after.
|
|
|
|
# It's useful when password is read from stdin.
|
|
|
|
ask_for_password() {
|
2018-02-22 04:54:54 +03:00
|
|
|
ply_tries=3
|
|
|
|
tty_tries=3
|
|
|
|
while [ "$#" -gt 0 ]; do
|
2018-02-20 21:13:20 +03:00
|
|
|
case "$1" in
|
|
|
|
--cmd) ply_cmd="$2"; tty_cmd="$2"; shift;;
|
|
|
|
--ply-cmd) ply_cmd="$2"; shift;;
|
|
|
|
--tty-cmd) tty_cmd="$2"; shift;;
|
|
|
|
--prompt) ply_prompt="$2"; tty_prompt="$2"; shift;;
|
|
|
|
--ply-prompt) ply_prompt="$2"; shift;;
|
|
|
|
--tty-prompt) tty_prompt="$2"; shift;;
|
|
|
|
--tries) ply_tries="$2"; tty_tries="$2"; shift;;
|
|
|
|
--ply-tries) ply_tries="$2"; shift;;
|
|
|
|
--tty-tries) tty_tries="$2"; shift;;
|
|
|
|
--tty-echo-off) tty_echo_off=yes;;
|
2021-11-30 21:23:10 +03:00
|
|
|
*) echo "ask_for_password(): wrong opt '$1'" >&2;;
|
2018-02-20 21:13:20 +03:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
{ flock -s 9;
|
|
|
|
# Prompt for password with plymouth, if installed and running.
|
dracut: use /bin/sh instead of bash as the intepreter
Despite that dracut has a hard dependency on bash,
its modules doesn't, dracut only has a hard dependency on bash for
module-setup (on a fully usable machine). Inside initramfs, dracut
allows users choose from a list of handful other shells, e.g. bash,
busybox, dash, mkfsh.
In fact, my local machine's initramfs is being built with dash,
and it's functional for a very long time.
Before 64025fa3a (Silence 'make checkbashisms', 2020-08-20), we also
allows our users to have that right, too.
Let's fix the problem 'make checkbashisms' reported and allows our users
to have that right, again.
For 'plymouth' case, let's simply run the command inside the if instead
of checking for the existence of command before running it, because the
status is also failture if plymouth is unavailable.
While we're at it, let's remove an unnecessary fork for grep in
zfs-generator.sh.in and its following complicated 'if elif fi' with
a simple 'case ... esac'.
To support this change, also exclude 90zfs from "make checkbashisms"
because the current CI infrastructure ships an old version of
"checkbashisms", which complains about "command -v", while the current
latest "checkbashisms" thinks it's fine. In the near future, we can
revert that change to "Makefile.am" when CI infrastructure is updated.
Reviewed-by: Gabriel A. Devenyi <gdevenyi@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Closes #11244
2020-11-28 22:02:08 +03:00
|
|
|
if plymouth --ping 2>/dev/null; then
|
2018-02-20 21:13:20 +03:00
|
|
|
plymouth ask-for-password \
|
2021-06-26 08:43:25 +03:00
|
|
|
--prompt "$ply_prompt" --number-of-tries="$ply_tries" | \
|
|
|
|
eval "$ply_cmd"
|
2018-02-20 21:13:20 +03:00
|
|
|
ret=$?
|
|
|
|
else
|
|
|
|
if [ "$tty_echo_off" = yes ]; then
|
|
|
|
stty_orig="$(stty -g)"
|
|
|
|
stty -echo
|
|
|
|
fi
|
|
|
|
|
2018-02-22 04:54:54 +03:00
|
|
|
i=1
|
|
|
|
while [ "$i" -le "$tty_tries" ]; do
|
2018-02-20 21:13:20 +03:00
|
|
|
[ -n "$tty_prompt" ] && \
|
2018-02-22 04:54:54 +03:00
|
|
|
printf "%s [%i/%i]:" "$tty_prompt" "$i" "$tty_tries" >&2
|
2018-02-20 21:13:20 +03:00
|
|
|
eval "$tty_cmd" && ret=0 && break
|
|
|
|
ret=$?
|
2018-02-22 04:54:54 +03:00
|
|
|
i=$((i+1))
|
2018-02-20 21:13:20 +03:00
|
|
|
[ -n "$tty_prompt" ] && printf '\n' >&2
|
|
|
|
done
|
2018-02-22 04:54:54 +03:00
|
|
|
unset i
|
|
|
|
[ "$tty_echo_off" = yes ] && stty "$stty_orig"
|
2018-02-20 21:13:20 +03:00
|
|
|
fi
|
|
|
|
} 9>/.console_lock
|
|
|
|
|
2021-11-30 21:23:10 +03:00
|
|
|
[ "$ret" -ne 0 ] && echo "Wrong password" >&2
|
|
|
|
return "$ret"
|
2018-02-20 21:13:20 +03:00
|
|
|
}
|