Compare commits
4 Commits
aaa56f3f1c
...
64eafcb816
| Author | SHA1 | Date |
|---|---|---|
|
|
64eafcb816 | |
|
|
a0ab011100 | |
|
|
85206b2535 | |
|
|
f7d5e70362 |
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
: <<!
|
||||
"We hardcode the GRUB_CMDLINE_LINUX_DEFAULT options for zbm in 020_grub_zbm_payload.sh"
|
||||
!
|
||||
exit 1
|
||||
|
||||
# | Parameter | Purpose | Notes |
|
||||
# | --------------------------- | -------------------------------------------------- | ----------------------------------------------------------------- |
|
||||
# | zbm.prefer=<pool> | Tells ZBM which ZFS pool to import first | Highly recommended if you have multiple zpools or bootable clones |
|
||||
# | zbm.import_delay=<seconds> | Adds a startup delay before auto-importing pools | Useful for slow disks or sparse device init |
|
||||
# | zbm.readonly=1 | Forces all imports read‑only | For emergency/recovery boot entries |
|
||||
# | zbm.timeout=<sec> | Default menu timeout | Optional override of ZBM’s own internal timeout |
|
||||
# | zbm.skip=<boolean> | Skip pool discovery, assume you’ll import manually | Optional, advanced |
|
||||
# | loglevel=<n> | Controls kernel verbosity | 4 is a balanced choice; 7 for deep debugging |
|
||||
# | rd.vconsole.keymap=<keymap> | Keyboard layout for early TTY | Optional, good for non‑US systems |
|
||||
# | rd.vconsole.font=<font> | Sets framebuffer console font (e.g. ter-124n) | Helps when small fonts are hard to read on hi‑res screens |
|
||||
|
||||
# Define arguments to add
|
||||
# Font sizes : ter-v32n ter-v28n ter-v24n ter-v20n ter-v14n
|
||||
# Font sizes bold: ter-v32b ter-v28b ter-v24b ter-v20b ter-v14b
|
||||
NEWARG=("rd.vconsole.font=ter-124n" "zbm.prefer=rpool" "loglevel=4" "zbm.import_delay=5")
|
||||
|
||||
# Loop through each argument and append to GRUB_CMDLINE_LINUX_DEFAULT
|
||||
for arg in "${NEWARG[@]}"; do
|
||||
sudo sed -i -E "s|^(GRUB_CMDLINE_LINUX_DEFAULT=\"[^\"]*)\"|\1 ${arg}\"|" /etc/default/grub
|
||||
done
|
||||
|
||||
# Update GRUB
|
||||
sudo update-grub
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -x
|
||||
|
||||
# Dependencies
|
||||
sudo apt update && sudo apt install -y binutils wget binwalk # lastversion
|
||||
|
||||
# --- CONFIGURATION ---
|
||||
REPO="zbm-dev/zfsbootmenu"
|
||||
ZBM_VERSION=$(lastversion --format tag "${REPO}")
|
||||
ZBM_RELEASE="recovery"
|
||||
KERNEL=$(uname -r | cut -d'.' -f1,2)
|
||||
ARCH=$(uname -m)
|
||||
|
||||
# Target directory for GRUB to find
|
||||
FINAL_DEST=/boot/zfsbootmenu
|
||||
sudo mkdir -p ${FINAL_DEST}
|
||||
|
||||
ZBM_EFI="zfsbootmenu-${ZBM_RELEASE}-${ARCH}-${ZBM_VERSION}-linux${KERNEL}.EFI"
|
||||
ZBM_URL="https://github.com/zbm-dev/zfsbootmenu/releases/download/${ZBM_VERSION}/${ZBM_EFI}"
|
||||
|
||||
# --- TMPFS SETUP ---
|
||||
WORK_DIR=$(mktemp -d -p /dev/shm zbm_extract.XXXXXX)
|
||||
cleanup() {
|
||||
echo "--- Cleaning up RAM storage ---"
|
||||
rm -rf "$WORK_DIR"
|
||||
rm -f "$ZBM_EFI"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Downloading ZFSBootMenu ${ZBM_VERSION}..."
|
||||
# lastversion -d \
|
||||
# --output "${ZBM_EFI}" \
|
||||
# zbm-dev/zfsbootmenu \
|
||||
# --filter "${ZBM_RELEASE}.*${ARCH}.*${ZBM_VERSION}.*${KERNEL}.*EFI"
|
||||
|
||||
sudo curl -L "${ZBM_URL}" -o "${ZBM_EFI}"
|
||||
|
||||
# Extraction paths
|
||||
KERNEL_OUT="${WORK_DIR}/vmlinuz-zbm"
|
||||
INITRD_OUT="${WORK_DIR}/initrd-zbm.img"
|
||||
|
||||
echo "--- Extracting assets from $ZBM_EFI ---"
|
||||
|
||||
# 1. Extract Kernel & Initrd
|
||||
if objcopy --dump-section .linux="$KERNEL_OUT" "$ZBM_EFI" 2>/dev/null &&
|
||||
objcopy --dump-section .initrd="$INITRD_OUT" "$ZBM_EFI" 2>/dev/null; then
|
||||
|
||||
echo "[✓] Extraction successful. Moving to $FINAL_DEST..."
|
||||
sudo cp "$KERNEL_OUT" "$FINAL_DEST/"
|
||||
sudo cp "$INITRD_OUT" "$FINAL_DEST/"
|
||||
else
|
||||
echo "[!] Extraction failed. Check if binutils is installed correctly."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- GRUB MENU GENERATION ---
|
||||
conf_print_zbm_grub_menu() {
|
||||
cat <<EOF
|
||||
#!/bin/sh
|
||||
exec tail -n +3 \$0
|
||||
# This file provides an easy way to add custom menu entries.
|
||||
menuentry "ZFSBootMenu (Extracted)" --class zfs --class gnu-linux {
|
||||
insmod part_gpt
|
||||
insmod zfs
|
||||
insmod gzio
|
||||
|
||||
# Use UUID instead of file search
|
||||
search --no-floppy --fs-uuid --set=root f383eb9e238f6712
|
||||
|
||||
echo "Loading ZFSBootMenu Kernel..."
|
||||
linux /zfsbootmenu/vmlinuz-zbm zbm.import_policy=hostid zbm.prefer=rpool loglevel=4
|
||||
|
||||
echo "Loading ZFSBootMenu Initrd..."
|
||||
initrd /zfsbootmenu/initrd-zbm.img
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
echo "Generating GRUB configuration..."
|
||||
conf_print_zbm_grub_menu | sudo tee /etc/grub.d/40_zbm
|
||||
sudo chmod +x /etc/grub.d/40_zbm
|
||||
|
||||
echo "Updating GRUB..."
|
||||
sudo update-grub
|
||||
|
||||
echo "---------------------------------------"
|
||||
echo "Done! Files are located in $FINAL_DEST"
|
||||
grep -A 10 "menuentry \"ZFSBootMenu" /boot/grub/grub.cfg
|
||||
|
|
@ -14,6 +14,17 @@ set -euo pipefail
|
|||
# 4. ZBM Environment: ZBM initializes, finds your ZFS datasets, and provides the UI.
|
||||
# 5. kexec: Once you select a kernel in ZBM, it uses kexec to replace itself with your actual Devuan kernel.
|
||||
|
||||
# --- CLI Argument Parsing ---
|
||||
FORCE=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--force | --force=1 | --force=true)
|
||||
FORCE=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# --- Configuration ---
|
||||
REPO="zbm-dev/zfsbootmenu"
|
||||
ZBM_DIR="/boot/zfsbootmenu"
|
||||
|
|
@ -60,8 +71,7 @@ REMOTE_HASH_DATA=$(curl -sfSL --connect-timeout 10 "$HASH_URL")
|
|||
# REMOTE_HASH=$(echo "$REMOTE_HASH_DATA" | grep "$EFI_NAME" | sed -n "s/.*= \([0-9a-f]*\).*/\1/p")
|
||||
REMOTE_HASH=$(echo "$REMOTE_HASH_DATA" | grep "$EFI_NAME" | sed -n "s/.*= *\([0-9a-f]\{64\}\).*/\1/p")
|
||||
|
||||
mkdir -p "$ZBM_DIR"
|
||||
if [[ -f "$ZBM_DIR/.hash" && "$(cat "$ZBM_DIR/.hash")" == "$REMOTE_HASH" ]]; then
|
||||
if [[ -f "$ZBM_DIR/.hash" && "$(cat "$ZBM_DIR/.hash")" == "$REMOTE_HASH" && "$FORCE" -ne 1 ]]; then
|
||||
echo "✔ ZFSBootMenu $LATEST_TAG already installed and verified. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
|
@ -121,18 +131,45 @@ sudo bash -c "
|
|||
mv vmlinuz-zbm.tmp "$ZBM_DIR/vmlinuz-zbm"
|
||||
mv initramfs-zbm.img.tmp "$ZBM_DIR/initramfs-zbm.img"
|
||||
chmod 600 "$ZBM_DIR/vmlinuz-zbm" "$ZBM_DIR/initramfs-zbm.img"
|
||||
echo "$REMOTE_HASH" >"$ZBM_DIR/.hash"
|
||||
echo $REMOTE_HASH >$ZBM_DIR/.hash
|
||||
"
|
||||
|
||||
# --- 7. GRUB Integration ---
|
||||
ZBM_POOL=$(findmnt -n -o SOURCE -T "$ZBM_DIR" | cut -d'/' -f1)
|
||||
ZBM_DATASET_MNT=$(findmnt -n -o TARGET -T "$ZBM_DIR")
|
||||
REL_PATH="${ZBM_DIR#$ZBM_DATASET_MNT}"
|
||||
[[ -z "$REL_PATH" ]] && REL_PATH="/"
|
||||
REL_PATH="${REL_PATH//|/}"
|
||||
ZBM_SOURCE=$(findmnt -n -o SOURCE -T "$ZBM_DIR") # rpool/ROOT/devuan-1
|
||||
ZBM_DATASET="${ZBM_SOURCE#*/}" # ROOT/devuan-1
|
||||
ZBM_DATASET_PATH="/${ZBM_DATASET}@/" # /ROOT/devuan-1@/
|
||||
|
||||
# Combine dataset location with the ZBM storage path
|
||||
REL_PATH="${ZBM_DATASET_PATH}${ZBM_DIR#/}" # /ROOT/devuan-1@/boot/zfsbootmenu
|
||||
|
||||
echo "[*] Generating GRUB configuration for pool: $ZBM_POOL..."
|
||||
|
||||
# | Parameter | Purpose | Notes |
|
||||
# | --------------------------- | -------------------------------------------------- | ----------------------------------------------------------------- |
|
||||
# | zbm.prefer=<pool> | Tells ZBM which ZFS pool to import first | Highly recommended if you have multiple zpools or bootable clones |
|
||||
# | zbm.import_delay=<seconds> | Adds a startup delay before auto-importing pools | Useful for slow disks or sparse device init |
|
||||
# | zbm.readonly=1 | Forces all imports read‑only | For emergency/recovery boot entries |
|
||||
# | zbm.timeout=<sec> | Default menu timeout | Optional override of ZBM’s own internal timeout |
|
||||
# | zbm.skip=<boolean> | Skip pool discovery, assume you’ll import manually | Optional, advanced |
|
||||
# | loglevel=<n> | Controls kernel verbosity | 4 is a balanced choice; 7 for deep debugging |
|
||||
# | rd.vconsole.keymap=<keymap> | Keyboard layout for early TTY | Optional, good for non‑US systems |
|
||||
# | rd.vconsole.font=<font> | Sets framebuffer console font (e.g. ter-124n) | Helps when small fonts are hard to read on hi‑res screens |
|
||||
|
||||
# Define arguments to add
|
||||
# Font sizes : ter-v32n ter-v28n ter-v24n ter-v20n ter-v14n
|
||||
# Font sizes bold: ter-v32b ter-v28b ter-v24b ter-v20b ter-v14b
|
||||
|
||||
# FIXME: If this where placed in /etc/default/zfsbootmenu/ it could be sourced here rather than hardcoded here. Much like /etc/default/grub
|
||||
# The scripts is separated from the settings. Maybe something I would do if I were packaging zbm.
|
||||
GRUB_DEFAULTS='loglevel=4 zbm.import_delay=5 video=vesafb:1920x1200-32@60 rd.vconsole.keymap=uk'
|
||||
|
||||
echo "DEBUG: ZBM_SOURCE='$ZBM_SOURCE'"
|
||||
echo "DEBUG: ZBM_DATASET='$ZBM_DATASET'"
|
||||
echo "DEBUG: ZBM_DATASET_PATH='$ZBM_DATASET_PATH'"
|
||||
echo "DEBUG: REL_PATH='$REL_PATH'"
|
||||
echo "DEBUG: ZBM_DIR='$ZBM_DIR'"
|
||||
|
||||
conf_print_grub_menu_zbm() {
|
||||
cat <<EOF
|
||||
#!/bin/sh
|
||||
|
|
@ -144,7 +181,7 @@ submenu 'ZFSBootMenu>Recovery Options' {
|
|||
insmod part_gpt
|
||||
insmod zfs
|
||||
search --no-floppy --set=root --label $ZBM_POOL
|
||||
linux $REL_PATH/vmlinuz-zbm loglevel=4 zbm.import_delay=5
|
||||
linux $REL_PATH/vmlinuz-zbm ${GRUB_DEFAULTS} zbm.prefer=$ZBM_POOL
|
||||
initrd $REL_PATH/initramfs-zbm.img
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +189,7 @@ submenu 'ZFSBootMenu>Recovery Options' {
|
|||
insmod part_gpt
|
||||
insmod zfs
|
||||
search --no-floppy --set=root --label $ZBM_POOL
|
||||
linux $REL_PATH/vmlinuz-zbm.old loglevel=4 zbm.import_delay=5
|
||||
linux $REL_PATH/vmlinuz-zbm.old ${GRUB_DEFAULTS} zbm.prefer=$ZBM_POOL
|
||||
initrd $REL_PATH/initramfs-zbm.img.old
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +197,7 @@ submenu 'ZFSBootMenu>Recovery Options' {
|
|||
insmod part_gpt
|
||||
insmod zfs
|
||||
search --no-floppy --set=root --label $ZBM_POOL
|
||||
linux $REL_PATH/vmlinuz-zbm loglevel=4 zbm.import_delay=5 zbm.readonly=1
|
||||
linux $REL_PATH/vmlinuz-zbm ${GRUB_DEFAULTS} zbm.readonly=1 zbm.prefer=$ZBM_POOL
|
||||
initrd $REL_PATH/initramfs-zbm.img
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +205,7 @@ submenu 'ZFSBootMenu>Recovery Options' {
|
|||
insmod part_gpt
|
||||
insmod zfs
|
||||
search --no-floppy --set=root --label $ZBM_POOL
|
||||
linux $REL_PATH/vmlinuz-zbm loglevel=4 zbm.import_delay=5 zbm.readonly=1 zbm.prefer=$ZBM_POOL!
|
||||
linux $REL_PATH/vmlinuz-zbm ${GRUB_DEFAULTS} zbm.readonly=1 zbm.prefer=$ZBM_POOL!
|
||||
initrd $REL_PATH/initramfs-zbm.img
|
||||
}
|
||||
}
|
||||
|
|
@ -183,4 +220,5 @@ else
|
|||
sudo grub-mkconfig -o /boot/grub/grub.cfg
|
||||
fi
|
||||
|
||||
echo "✔ Deployment complete and verified."
|
||||
echo "✔ Deployment complete, verify your grub.cfg entries below: "
|
||||
grep -A5 'ZFSBootMenu' /boot/grub/grub.cfg
|
||||
|
|
|
|||
|
|
@ -640,6 +640,21 @@ EOF
|
|||
}
|
||||
conf_print_blink_no_frizbee | tee "${LAZY_DEST}/blink_no_frizbee.lua"
|
||||
#
|
||||
conf_print_local_parser_path() {
|
||||
cat <<EOF
|
||||
return {
|
||||
{
|
||||
dir = "/home/default/.local/share/nvim/site", -- Points to the local path
|
||||
lazy = false,
|
||||
priority = 1000, -- Load this early
|
||||
config = function()
|
||||
vim.opt.runtimepath:append("/home/default/.local/share/nvim/site")
|
||||
end,
|
||||
}
|
||||
}
|
||||
EOF
|
||||
}
|
||||
conf_print_local_parser_path | tee "${LAZY_DEST}/local_parser_path.lua"
|
||||
|
||||
############################
|
||||
# Hacking Below this Point #
|
||||
|
|
|
|||
Loading…
Reference in New Issue