File tree Expand file tree Collapse file tree 9 files changed +276
-5
lines changed Expand file tree Collapse file tree 9 files changed +276
-5
lines changed Original file line number Diff line number Diff line change
1
+ [1mNAME[0m
2
+
3
+ [1mzfsbootmenu[0m - Recovery Shell
4
+
5
+ [1mCommon Commands[0m
6
+
7
+ [33mzfsbootmenu[0m
8
+ Launch the interactive boot environment menu.
9
+
10
+ [33mzfs-chroot[0m [1mzfs filesystem[0m
11
+ Enter a chroot of the specified boot environment. The boot environment is mounted [33mread/write[0m if the zpool is imported [33mread/write[0m.
12
+
13
+ [33mset_rw_pool[0m [1mpool[0m
14
+ Export, then re-import the pool [33mread/write[0m.
15
+
16
+ [33mset_ro_pool[0m [1mpool[0m
17
+ Export, then re-import the pool [33mread-only[0m.
18
+
19
+ [33mmount_zfs[0m [1mzfs filesystem[0m
20
+ Mount the filesystem at a unique location and print the mount point.
21
+
22
+ [33mhelp[0m
23
+ View the online help system.
24
+
25
+ [33mlogs[0m
26
+ View warning/error/debug logs.
27
+
28
+ [1mAUTHOR[0m
29
+
30
+ ZFSBootMenu Team <https://github.com/zbm-dev/zfsbootmenu>
31
+
Original file line number Diff line number Diff line change
1
+ [1mNAME[0m
2
+
3
+ [1mzfsbootmenu[0m - Recovery Shell
4
+
5
+ [1mCommon Commands[0m
6
+
7
+ [33mzfsbootmenu[0m
8
+ Launch the interactive boot environment menu.
9
+
10
+ [33mzfs-chroot[0m [1mzfs filesystem[0m
11
+ Enter a chroot of the specified boot environment.
12
+ The boot environment is mounted [33mread/write[0m if the
13
+ zpool is imported [33mread/write[0m.
14
+
15
+ [33mset_rw_pool[0m [1mpool[0m
16
+ Export, then re-import the pool [33mread/write[0m.
17
+
18
+ [33mset_ro_pool[0m [1mpool[0m
19
+ Export, then re-import the pool [33mread-only[0m.
20
+
21
+ [33mmount_zfs[0m [1mzfs filesystem[0m
22
+ Mount the filesystem at a unique location and print
23
+ the mount point.
24
+
25
+ [33mhelp[0m
26
+ View the online help system.
27
+
28
+ [33mlogs[0m
29
+ View warning/error/debug logs.
30
+
31
+ [1mAUTHOR[0m
32
+
33
+ ZFSBootMenu Team
34
+ <https://github.com/zbm-dev/zfsbootmenu>
35
+
Original file line number Diff line number Diff line change
1
+ [1mNAME[0m
2
+
3
+ [1mzfsbootmenu[0m - Recovery Shell
4
+
5
+ [1mCommon Commands[0m
6
+
7
+ [33mzfsbootmenu[0m
8
+ Launch the interactive boot environment menu.
9
+
10
+ [33mzfs-chroot[0m [1mzfs filesystem[0m
11
+ Enter a chroot of the specified boot environment. The boot environment is mounted [33mread/write[0m
12
+ if the zpool is imported [33mread/write[0m.
13
+
14
+ [33mset_rw_pool[0m [1mpool[0m
15
+ Export, then re-import the pool [33mread/write[0m.
16
+
17
+ [33mset_ro_pool[0m [1mpool[0m
18
+ Export, then re-import the pool [33mread-only[0m.
19
+
20
+ [33mmount_zfs[0m [1mzfs filesystem[0m
21
+ Mount the filesystem at a unique location and print the mount point.
22
+
23
+ [33mhelp[0m
24
+ View the online help system.
25
+
26
+ [33mlogs[0m
27
+ View warning/error/debug logs.
28
+
29
+ [1mAUTHOR[0m
30
+
31
+ ZFSBootMenu Team <https://github.com/zbm-dev/zfsbootmenu>
32
+
Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ install() {
146
146
_ret=0
147
147
# shellcheck disable=SC2154
148
148
inst_simple " ${moddir} /zfsbootmenu-lib.sh" " /lib/zfsbootmenu-lib.sh" || _ret=$?
149
+ inst_simple " ${moddir} /zfsbootmenu-completions.sh" " /lib/zfsbootmenu-completions.sh" || _ret=$?
149
150
inst_simple " ${moddir} /zfsbootmenu-init.sh" " /libexec/zfsbootmenu-init" || _ret=$?
150
151
inst_simple " ${moddir} /zfsbootmenu-preview.sh" " /libexec/zfsbootmenu-preview" || _ret=$?
151
152
inst_simple " ${moddir} /zfsbootmenu-input.sh" " /libexec/zfsbootmenu-input" || _ret=$?
@@ -317,12 +318,29 @@ EOF
317
318
cat << EOF >> "${initdir} /etc/profile"
318
319
[ -f /lib/zfsbootmenu-lib.sh ] && source /lib/zfsbootmenu-lib.sh
319
320
[ -f /etc/zfsbootmenu.conf ] && source /etc/zfsbootmenu.conf
321
+
320
322
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
321
323
export TERM=vt220
324
+
325
+ zdebug "sourced /etc/profile"
326
+
327
+ EOF
328
+
329
+ # Setup a default environment for all login shells
330
+ cat << EOF >> "${initdir} /.bashrc"
331
+ [ -f /etc/profile ] && source /etc/profile
332
+ [ -f /lib/zfsbootmenu-completions.sh ] && source /lib/zfsbootmenu-completions.sh
322
333
export PS1="\033[0;33mzfsbootmenu\033[0m \w > "
334
+
323
335
alias clear="tput clear"
324
336
alias reset="tput reset"
325
337
alias zbm="zfsbootmenu"
326
- alias logs="zlogtail -f"
338
+ alias logs="ztrace"
339
+ alias trace="ztrace"
340
+ alias debug="ztrace"
341
+ alias help="/libexec/zfsbootmenu-help -L recovery-shell"
342
+
343
+ zdebug "sourced /.bashrc"
344
+
327
345
EOF
328
346
}
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # shellcheck disable=SC2207
3
+
4
+ # disabling this allows completions with the @ character
5
+ shopt -u hostcomplete
6
+
7
+ _zfs-chroot () {
8
+ local ZFS
9
+ COMPREPLY=()
10
+
11
+ [ " ${# COMP_WORDS[@]} " != " 2" ] && return
12
+
13
+ for SNAP in $( zfs list -H -o name -t snapshot ) ; do
14
+ ZFS+=(" ${SNAP} " )
15
+ done
16
+
17
+ for FS in $( zfs list -H -o name ) ; do
18
+ ZFS+=(" ${FS} " )
19
+ done
20
+
21
+ COMPREPLY=( $( compgen -W " ${ZFS[*]} " -- " ${COMP_WORDS[1]} " ) )
22
+ }
23
+ complete -F _zfs-chroot zfs-chroot
24
+ complete -F _zfs-chroot zfs_chroot
25
+
26
+ _set_rw_pool () {
27
+ local ZPOOL
28
+ COMPREPLY=()
29
+
30
+ [ " ${# COMP_WORDS[@]} " != " 2" ] && return
31
+
32
+ for POOL in $( zpool list -H -o name ) ; do
33
+ if ! is_writable " ${POOL} " ; then
34
+ ZPOOL+=(" ${POOL} " )
35
+ fi
36
+ done
37
+ COMPREPLY=( $( compgen -W " ${ZPOOL[*]} " -- " ${COMP_WORDS[1]} " ) )
38
+ }
39
+ complete -F _set_rw_pool set_rw_pool
40
+
41
+ _set_ro_pool () {
42
+ local ZPOOL
43
+ COMPREPLY=()
44
+
45
+ [ " ${# COMP_WORDS[@]} " != " 2" ] && return
46
+
47
+ for POOL in $( zpool list -H -o name ) ; do
48
+ if is_writable " ${POOL} " ; then
49
+ ZPOOL+=(" ${POOL} " )
50
+ fi
51
+ done
52
+ COMPREPLY=( $( compgen -W " ${ZPOOL[*]} " -- " ${COMP_WORDS[1]} " ) )
53
+ }
54
+ complete -F _set_ro_pool set_ro_pool
55
+
56
+ _mount_zfs () {
57
+ local ZFS
58
+ COMPREPLY=()
59
+
60
+ [ " ${# COMP_WORDS[@]} " != " 2" ] && return
61
+
62
+ for SNAP in $( zfs list -H -o name -t snapshot ) ; do
63
+ ZFS+=(" ${SNAP} " )
64
+ done
65
+
66
+ for FS in $( zfs list -H -o name ) ; do
67
+ ZFS+=(" ${FS} " )
68
+ done
69
+
70
+ COMPREPLY=( $( compgen -W " ${ZFS[*]} " -- " ${COMP_WORDS[1]} " ) )
71
+ }
72
+ complete -F _mount_zfs mount_zfs
Original file line number Diff line number Diff line change @@ -28,13 +28,14 @@ help_pager() {
28
28
SORTED+=(" ${FINAL} " )
29
29
30
30
printf ' %s\n' " ${SORTED[@]} " | ${FUZZYSEL} \
31
- --prompt ' Topic >' \
31
+ --prompt ' Topic > ' \
32
32
--with-nth=2.. \
33
33
--bind pgup:preview-up,pgdn:preview-down \
34
34
--preview=" $0 -s {1}" \
35
35
--preview-window=" right:${PREVIEW_SIZE} :wrap" \
36
36
--header=" $( colorize green " [ESC]" ) $( colorize lightblue " back" ) " \
37
37
--tac \
38
+ --inline-info \
38
39
--ansi
39
40
}
40
41
Original file line number Diff line number Diff line change @@ -1710,6 +1710,33 @@ set_rw_pool() {
1710
1710
return 1
1711
1711
}
1712
1712
1713
+ # arg1: pool name
1714
+ # prints: nothing
1715
+ # returns: 0 on success, 1 on failure
1716
+
1717
+ set_ro_pool () {
1718
+ local pool ret
1719
+
1720
+ pool=" ${1} "
1721
+ if [ -z " ${pool} " ]; then
1722
+ zerror " pool is undefined"
1723
+ return 1
1724
+ fi
1725
+ zdebug " pool set to ${pool} "
1726
+
1727
+ if export_pool " ${pool} " ; then
1728
+ read_write=' ' import_pool " ${pool} "
1729
+ ret=$?
1730
+
1731
+ zdebug " import_pool: ${ret} "
1732
+
1733
+ return ${ret}
1734
+ fi
1735
+
1736
+ return 1
1737
+ }
1738
+
1739
+
1713
1740
# arg1: ZFS filesystem
1714
1741
# prints: name of encryption root, if present
1715
1742
# returns: 0 if system has an encryption root, 1 otherwise
@@ -2082,7 +2109,7 @@ zfs_chroot() {
2082
2109
# returns: nothing
2083
2110
2084
2111
emergency_shell () {
2085
- local message
2112
+ local message skip mp fs
2086
2113
message=${1:- unknown reason}
2087
2114
2088
2115
tput clear
@@ -2091,7 +2118,17 @@ emergency_shell() {
2091
2118
2092
2119
echo -n " Launching emergency shell: "
2093
2120
echo -e " ${message} \n"
2094
- /bin/bash -l
2121
+
2122
+ # -i (interactive) mode will source /.bashrc
2123
+ /bin/bash -i
2124
+
2125
+ # shellcheck disable=SC2034
2126
+ while read -r skip mp fs skip ; do
2127
+ if [ " ${fs} " == " zfs" ]; then
2128
+ umount " ${mp} "
2129
+ zdebug " unmounting: ${mp} "
2130
+ fi
2131
+ done < /proc/self/mounts
2095
2132
}
2096
2133
2097
2134
# prints: nothing
Original file line number Diff line number Diff line change @@ -299,7 +299,7 @@ while true; do
299
299
# This will make all keys in the pool unavailable, but populate_be_list
300
300
# should reload the missing keys in the next iteration, so why unlock here?
301
301
if is_writable " ${pool} " ; then
302
- export_pool " ${pool} " && read_write= ' ' import_pool " ${pool} "
302
+ set_ro_pool " ${pool} "
303
303
else
304
304
set_rw_pool " ${pool} "
305
305
fi
Original file line number Diff line number Diff line change
1
+ =pod
2
+
3
+ =head1 NAME
4
+
5
+ B<zfsbootmenu> - Recovery Shell
6
+
7
+ =head1 Common Commands
8
+
9
+ =over 2
10
+
11
+ =item I<zfsbootmenu>
12
+
13
+ Launch the interactive boot environment menu.
14
+
15
+ =item I<zfs-chroot> B<zfs filesystem>
16
+
17
+ Enter a chroot of the specified boot environment. The boot environment is mounted I<read/write> if the zpool is imported I<read/write>.
18
+
19
+ =item I<set_rw_pool> B<pool>
20
+
21
+ Export, then re-import the pool I<read/write>.
22
+
23
+ =item I<set_ro_pool> B<pool>
24
+
25
+ Export, then re-import the pool I<read-only>.
26
+
27
+ =item I<mount_zfs> B<zfs filesystem>
28
+
29
+ Mount the filesystem at a unique location and print the mount point.
30
+
31
+ =item I<help>
32
+
33
+ View the online help system.
34
+
35
+ =item I<logs>
36
+
37
+ View warning/error/debug logs.
38
+
39
+ =back
40
+
41
+ =head2 AUTHOR
42
+
43
+ ZFSBootMenu Team L<https://github.com/zbm-dev/zfsbootmenu>
44
+
45
+ =cut
You can’t perform that action at this time.
0 commit comments