Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
- Add a force_import kernel command line option, default to not force
importing
- Fix noting that we found a valid root= value
- wipe the screen before kexec
- remove static pool definition leftover from testing
  • Loading branch information
zdykstra committed Oct 22, 2019
1 parent 08df12d commit 915a136
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
19 changes: 14 additions & 5 deletions 90zfsbootmenu/parse-zfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@
# Let the command line override our host id.
spl_hostid=$(getarg spl_hostid=)
if [ -n "${spl_hostid}" ] ; then
info "ZFS: Using hostid from command line: ${spl_hostid}"
info "ZFSBootMenu: Using hostid from command line: ${spl_hostid}"
AA=$(echo "${spl_hostid}" | cut -b 1,2)
BB=$(echo "${spl_hostid}" | cut -b 3,4)
CC=$(echo "${spl_hostid}" | cut -b 5,6)
DD=$(echo "${spl_hostid}" | cut -b 7,8)
echo -ne "\\x${DD}\\x${CC}\\x${BB}\\x${AA}" >/etc/hostid
elif [ -f "/etc/hostid" ] ; then
info "ZFS: Using hostid from /etc/hostid: $(hostid)"
info "ZFSBootMenu: Using hostid from /etc/hostid: $(hostid)"
else
warn "ZFS: No hostid found on kernel command line or /etc/hostid."
warn "ZFS: Pools may not import correctly."
warn "ZFSBootMenu: No hostid found on kernel command line or /etc/hostid."
warn "ZFSBootMenu: Pools may not import correctly."
fi

# Force import pools only when explicitly told to do so
force_import=$(getarg force_import=)
if [[ -n "${force_import}" && "${force_import}" -eq 1 ]] ; then
info "ZFSBootMenu: Enabling force import of ZFS pools"
import_args="-f -N"
else
import_args="-N"
fi

wait_for_zfs=0
Expand All @@ -31,7 +40,7 @@ case "${root}" in
zfsbootmenu:POOL\=*)
# Prefer a specific pool for bootfs value, root=zfsbootmenu:POOL=zroot
root="${root#zfsbootmenu:POOL=}"
rootk=1
rootok=1
wait_for_zfs=1

info "ZFSBootMenu: Preferring ${root} for bootfs"
Expand Down
8 changes: 4 additions & 4 deletions 90zfsbootmenu/zfs-bootmenu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ kexec_kernel() {

selected="${1}"

clear

# zfs filesystem
# kernel
# initramfs
Expand Down Expand Up @@ -150,7 +152,7 @@ kexec_snapshot() {
last="${pairs[-1]}"
IFS=';' read kernel initramfs <<<"${last}"

kexec_kernel "${target} $kernel $initramfs"
kexec_kernel "${target} ${kernel} ${initramfs}"
}

# Return code is the number of kernels that can be used
Expand Down Expand Up @@ -209,7 +211,7 @@ import_pool() {
local pool
pool="${1}"

status=$( zpool import -f -N ${pool} )
status=$( zpool import ${import_args} ${pool} )
ret=$?

return ${ret}
Expand Down Expand Up @@ -253,8 +255,6 @@ else
pool="${root}"
fi

pool="zroot"

datasets="$( zpool list -H -o bootfs ${pool} )"
if [ -z "$datasets" ]; then
BOOTFS=
Expand Down

0 comments on commit 915a136

Please sign in to comment.