-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzfs-prepare-rootfs
67 lines (52 loc) · 1.29 KB
/
zfs-prepare-rootfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/busybox sh
# shellcheck shell=busybox disable=SC3003
set -eo pipefail
SCRIPT_NAME="zfs-prepare-rootfs"
LIB_DIR="/usr/lib/zfs/initcpio"
# shellcheck source=zfs-functions
. "$LIB_DIR/zfs-functions"
#
# main
#
setup_debug
# The state file is loaded via systemd
if [[ ${ZFS_ROOT_MODE+set} ]]; then
:
# if vars_present; then
# load_vars
else
parse_cmdline
fi
case "${ZFS_ROOT_MODE?}" in
all)
if dataset=$(zpool list -Ho bootfs | grep -m1 -vFx -); then
ZFS_ROOT_POOL="${dataset%%/*}"
ZFS_ROOT_DATASET="$dataset"
else
die "no pool with bootfs property found"
fi
;;
pool)
[[ ${ZFS_ROOT_POOL+set} ]] || die "internal: \$ZFS_ROOT_POOL not set"
if dataset=$(zpool list -Ho bootfs "$ZFS_ROOT_POOL" | grep -m1 -vFx -); then
ZFS_ROOT_DATASET="$dataset"
else
die "no bootfs property found for pool \"$ZFS_ROOT_POOL\""
fi
;;
dataset)
[[ ${ZFS_ROOT_POOL+set} ]] || die "internal: \$ZFS_ROOT_POOL not set"
[[ ${ZFS_ROOT_DATASET+set} ]] || die "internal: \$ZFS_ROOT_DATASET not set"
;;
*)
die "invalid \$ZFS_ROOT_MODE=\"$ZFS_ROOT_MODE\""
;;
esac
dump_vars
if zfs list -Ho name -d1 "$ZFS_ROOT_DATASET" | grep -q -v -Fx "$ZFS_ROOT_DATASET"; then
log "nested datasets found under \"$ZFS_ROOT_DATASET\", reloading"
systemctl daemon-reload
fi
log "done"
exit 0
# vim: ft=sh ts=8 noet: