Merge pull request #19 from zdykstra/set-restore-loglevel

Set restore loglevel
This commit is contained in:
Zach Dykstra 2020-02-18 00:16:10 -06:00 committed by GitHub
commit c99412ef78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 16 deletions

View File

@ -56,6 +56,7 @@ install() {
fi
dracut_install /usr/bin/mount.zfs
dracut_install /usr/lib/udev/vdev_id
dracut_install /usr/lib/udev/zvol_id
dracut_install tac
dracut_install awk
dracut_install basename
@ -76,12 +77,11 @@ install() {
dracut_install mount
dracut_install df
dracut_install ip
dracut_install /usr/bin/timeout
dracut_install /usr/bin/mkdir
dracut_install /usr/bin/tail
dracut_install /usr/lib/udev/zvol_id
inst_simple "${moddir}/zfsbootmenu-lib.sh" "/lib/zfsbootmenu-lib.sh"
inst_simple "${moddir}/zfsbootmenu-preview.sh" "/bin/zfsbootmenu-preview.sh"
inst_simple "${moddir}/zfs-chroot" "/bin/zfs-chroot"
inst_hook cmdline 95 "${moddir}/zfsbootmenu-parse-commandline.sh"
inst_hook pre-mount 90 "${moddir}/zfsbootmenu.sh"

19
90zfsbootmenu/zfs-chroot Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
BASE="$( mktemp -d /tmp/zfs.XXXX )"
fs="$( zfs list -H -o name ${1} )"
if [ "$fs" != "${1}" ]; then
echo "Filesystem $1 doesn't exist"
exit
fi
mount -o zfsutil -t zfs "${1}" "${BASE}"
mount -t proc proc "${BASE}/proc"
mount -t sysfs sys "${BASE}/sys"
mount -B /dev "${BASE}/dev"
mount -B /tmp "${BASE}/var/tmp"
mount -t devpts pts "${BASE}/dev/pts"
chroot "${BASE}" /bin/bash
umount "${1}"

View File

@ -110,18 +110,21 @@ kexec_kernel() {
cli_args="${line}"
done < "${BASE}/${fs}/default_args"
kexec -l ${mnt}${kernel} \
--initrd=${mnt}/${initramfs} \
# restore kernel log level just before we kexec
echo "${printk}" > /proc/sys/kernel/printk
kexec -l "${mnt}${kernel}" \
--initrd="${mnt}${initramfs}" \
--command-line="root=zfs:${fs} ${cli_args}"
umount ${mnt}
# Export if read-write, to ensure a clean pool
pool="${selected%%/*}"
if [ "$( zpool get -H -o value readonly ${pool} )" = "off" ]; then
if [ "$( zpool get -H -o value readonly "${pool}" )" = "off" ]; then
export_pool "${pool}"
fi
kexec -e -i
}
@ -137,7 +140,7 @@ clone_snapshot() {
pool="${selected%%/*}"
# If the pool is read-only, flip the arg off then export and import
if [ "$( zpool get -H -o value readonly ${pool} )" = "on" ]; then
if [ "$( zpool get -H -o value readonly "${pool}" )" = "on" ]; then
export_pool "${pool}"
import_args="${import_args/readonly=on/readonly=off}"
import_pool "${pool}"
@ -145,26 +148,26 @@ clone_snapshot() {
target="${selected/@/_}"
if $( zfs list -H -o name | grep -q ${target} ); then
last_env="$( zfs list -H -o name | grep ${target} | tail -1 )"
if $( zfs list -H -o name | grep -q "${target}" ); then
last_env="$( zfs list -H -o name | grep "${target}" | tail -1 )"
index="${last_env##${target}_}"
index="$(( ${index} + 1 ))"
else
index="0"
fi
target="$( printf "%s_%0.3d" ${target} ${index} )"
target="$( printf "%s_%0.3d" "${target}" "${index}" )"
zfs clone -o mountpoint=/ \
-o canmount=noauto \
${selected} ${target}
"${selected}" "${target}"
ret=$?
if [ $ret -eq 0 ]; then
key_wrapper "${target}"
if [ $? -eq 0 ]; then
if output=$( find_be_kernels "${target}" ); then
echo "${target}" >> ${BASE}/env
echo "${target}" >> "${BASE}/env"
return 0
else
# No kernels were found
@ -187,14 +190,14 @@ set_default_env() {
pool="${selected%%/*}"
# If the pool is read-only, flip the arg off then export and import
if [ "$( zpool get -H -o value readonly ${pool} )" = "on" ]; then
if [ "$( zpool get -H -o value readonly "${pool}" )" = "on" ]; then
export_pool "${pool}"
import_args="${import_args/readonly=on/readonly=off}"
import_pool "${pool}"
key_wrapper "${pool}"
fi
if output="$( zpool set bootfs=${selected} ${pool} )"; then
if output="$( zpool set bootfs="${selected}" "${pool}" )"; then
BOOTFS="${selected}"
fi
}
@ -210,7 +213,6 @@ find_be_kernels() {
local sane kernel version kernel_records
pairs=()
# Check if /boot even exists in the environment
mnt="$( mount_zfs "${fs}" )"

View File

@ -1,9 +1,14 @@
#!/bin/bash
# store current kernel log level
read -r printk < /proc/sys/kernel/printk
printk=${printk:0:1}
# Set it to 0
echo 0 > /proc/sys/kernel/printk
test -f /lib/zfsbootmenu-lib.sh && source /lib/zfsbootmenu-lib.sh
test -f zfsbootmenu-lib.sh && source zfsbootmenu-lib.sh
echo "Loading boot menu ..."
TERM=linux
tput reset