diff --git a/playbook/blancco-init.sh b/playbook/blancco-init.sh index 7ab524f..5aa6e6e 100644 --- a/playbook/blancco-init.sh +++ b/playbook/blancco-init.sh @@ -7,31 +7,38 @@ # NIC driver set), download Blancco rootfs (squashfs), overlay-mount, and # switch_root into Blancco's userspace. # -# Verbose trace + shell-on-NIC-failure because silent hangs during Blancco -# PXE boot are painful to debug. set -x goes to /dev/console so the screen -# shows every step; if no NIC appears after the modprobe sweep, we dump -# dmesg / lspci / /proc/modules and drop to sh so the operator can +# Quiet by default: one line per step. Add blancco.debug=1 to the kernel +# cmdline for the full trace (set -x, modprobe -v, ip link/addr). Failures +# always print their diagnostics and drop to sh so the operator can # investigate without re-imaging. exec >/dev/console 2>&1 -set -x - -echo "" -echo "============================================" -echo " Blancco PXE loader (verbose)" -echo "============================================" -echo "" export PATH=/bin:/sbin mount -t proc proc /proc mount -t sysfs sysfs /sys mount -t devtmpfs devtmpfs /dev 2>/dev/null || mount -t tmpfs tmpfs /dev + +DEBUG="" +grep -q 'blancco.debug=1' /proc/cmdline && DEBUG=1 +# dbg CMD...: run only in debug mode +dbg() { [ -n "$DEBUG" ] && "$@"; return 0; } +if [ -n "$DEBUG" ]; then + set -x +else + printf '\033c' # clear the kernel messages off the screen + dmesg -n 1 2>/dev/null || true +fi + +echo "" +echo " Blancco Drive Eraser - loading from $( [ -n "$DEBUG" ] && echo "PXE (debug)" || echo "PXE")" +echo "" mkdir -p /tmp /run /run/lower /run/upper /run/work /run/newroot KVER=$(uname -r) -echo "Running kernel: $KVER" -ls /lib/modules/ 2>/dev/null +dbg echo "Running kernel: $KVER" +dbg ls /lib/modules/ -echo "[1/5] Loading NIC drivers via modprobe (resolves deps automatically)..." +echo " [1/5] Network drivers" # Throw the full common-NIC driver list at the wall. modprobe resolves the # deps from /lib/modules/$KVER/modules.dep (built by prepare-boot-tools). # Anything missing is silently ignored; whatever matches PCI IDs will bind. @@ -50,15 +57,19 @@ for drv in \ alx atl1c atl1e atl2 \ via_rhine via_velocity forcedeth \ pegasus dm9601 asix ax88179_178a cdc_ether cdc_ncm rndis_host; do - modprobe -v "$drv" 2>/dev/null && echo " OK $drv" || true + if [ -n "$DEBUG" ]; then + modprobe -v "$drv" 2>/dev/null && echo " OK $drv" || true + else + modprobe "$drv" >/dev/null 2>&1 || true + fi done sleep 3 -echo "[2/5] /sys/class/net after driver load:" -ls /sys/class/net/ || true -ip link || true +echo " [2/5] Waiting for a network link" +dbg ls /sys/class/net/ +dbg ip link -echo " Waiting up to 60s for non-lo interface..." +dbg echo " Waiting up to 60s for non-lo interface..." IFACE="" for i in $(seq 1 60); do for n in /sys/class/net/*; do @@ -89,7 +100,7 @@ for n in /sys/class/net/*; do case "$name" in lo|wl*) continue ;; esac ip link set "$name" up 2>/dev/null || ifconfig "$name" up 2>/dev/null || true done -echo " Waiting up to 30s for a cabled interface..." +dbg echo " Waiting up to 30s for a cabled interface..." CARRIER="" for i in $(seq 1 30); do for n in /sys/class/net/*; do @@ -116,21 +127,21 @@ if [ -z "$CARRIER" ]; then fi IFACE="$CARRIER" -echo " IFACE=$IFACE (has link), bringing up..." +echo " using $IFACE" ip link set "$IFACE" up || ifconfig "$IFACE" up sleep 2 SERVER=172.16.9.1 ifconfig "$IFACE" 172.16.9.250 netmask 255.255.255.0 up sleep 1 -echo " IP: 172.16.9.250 SERVER: $SERVER" -ip addr +dbg echo " IP: 172.16.9.250 SERVER: $SERVER" +dbg ip addr -echo "[3/5] Downloading airootfs.sfs (~756 MB)..." +echo " [3/5] Downloading Blancco (~850 MB)" wget -T 30 -O /tmp/airootfs.sfs http://$SERVER/blancco/arch/x86_64/airootfs.sfs 2>&1 [ -s /tmp/airootfs.sfs ] || { echo "ERROR: download failed"; exec /bin/sh; } -echo "[4/5] Mounting rootfs + overlay..." +echo " [4/5] Preparing system" modprobe overlay 2>/dev/null || insmod /lib/modules/$KVER/kernel/fs/overlayfs/overlay.ko 2>/dev/null modprobe squashfs 2>/dev/null || insmod /lib/modules/$KVER/kernel/fs/squashfs/squashfs.ko 2>/dev/null modprobe loop 2>/dev/null @@ -140,8 +151,8 @@ mount -t tmpfs -o size=50% tmpfs /run/upper mkdir -p /run/upper/upper /run/upper/work mount -t overlay overlay -o lowerdir=/run/lower,upperdir=/run/upper/upper,workdir=/run/upper/work /run/newroot -echo "[5/5] Fetching kmod tarball + config..." -wget -T 30 -O /tmp/kmod.tar.gz http://$SERVER/blancco/kmod.tar.gz 2>&1 +echo " [5/5] Loading drivers and settings" +wget -q -T 30 -O /tmp/kmod.tar.gz http://$SERVER/blancco/kmod.tar.gz 2>&1 [ -s /tmp/kmod.tar.gz ] && (cd /run/newroot && gunzip -c /tmp/kmod.tar.gz | tar xf - && rm -f /tmp/kmod.tar.gz) mkdir -p /run/newroot/albus @@ -151,7 +162,7 @@ mkdir -p /run/newroot/albus # /albus/preferences.save (factory defaults, empty network_share) so # erasure reports never reach SMB. Fail loud here instead. PREFS=/run/newroot/albus/preferences.xml -if ! wget -T 30 -O "$PREFS" "http://$SERVER/blancco/preferences.xml"; then +if ! wget -q -T 30 -O "$PREFS" "http://$SERVER/blancco/preferences.xml"; then echo "ERROR: preferences.xml download failed from http://$SERVER/blancco/preferences.xml" echo "Reports would fall back to factory defaults (no SMB target)." echo "Dropping to shell - check Apache + network." @@ -172,7 +183,7 @@ fi # fires, we want the fallback to still have the right SMB target. cp -f "$PREFS" /run/newroot/albus/preferences.save -if ! wget -T 30 -O /run/newroot/albus/config.xml "http://$SERVER/blancco/config-clean.xml"; then +if ! wget -q -T 30 -O /run/newroot/albus/config.xml "http://$SERVER/blancco/config-clean.xml"; then echo "ERROR: config.xml (license container) download failed." exec /bin/sh fi @@ -246,5 +257,5 @@ mount --bind /dev/null /run/newroot/sys/power/disk 2>/dev/null || true mount --bind /dev/null /run/newroot/sys/power/mem_sleep 2>/dev/null || true mount --bind /dev/null /run/newroot/sys/power/autosleep 2>/dev/null || true -echo "Switching root..." +echo " Starting Blancco..." exec switch_root /run/newroot /sbin/init diff --git a/playbook/pxe_server_setup.yml b/playbook/pxe_server_setup.yml index 9efc15a..f750ad5 100644 --- a/playbook/pxe_server_setup.yml +++ b/playbook/pxe_server_setup.yml @@ -267,7 +267,7 @@ :blancco_bios echo Loading Blancco for legacy BIOS (canonical)... - kernel http://${server}/blancco/vmlinuz-bde-linux initrd=initramfs-bde-linux.img,config.img,intel-ucode.img,amd-ucode.img archisobasedir=arch archiso_http_srv=http://${server}/blancco/ copytoram=y cow_spacesize=50% memtest=00 vmalloc=400M ip=dhcp libata.allow_tpm=1 modprobe.blacklist=btusb rd.udev.timeout=10 systemd.battery-check=0 || goto blancco_bios_failed + kernel http://${server}/blancco/vmlinuz-bde-linux initrd=initramfs-bde-linux.img,config.img,intel-ucode.img,amd-ucode.img quiet loglevel=3 archisobasedir=arch archiso_http_srv=http://${server}/blancco/ copytoram=y cow_spacesize=50% memtest=00 vmalloc=400M ip=dhcp libata.allow_tpm=1 modprobe.blacklist=btusb rd.udev.timeout=10 systemd.battery-check=0 || goto blancco_bios_failed initrd --name intel-ucode.img http://${server}/blancco/intel-ucode.img || goto blancco_bios_failed initrd --name amd-ucode.img http://${server}/blancco/amd-ucode.img || goto blancco_bios_failed initrd --name config.img http://${server}/blancco/config.img || goto blancco_bios_failed @@ -280,7 +280,7 @@ :blancco_efi echo Loading Blancco UEFI (direct kernel)... - kernel http://${server}/blancco/vmlinuz-ubuntu initrd=kexec-initrd.img ip=dhcp nomodeset vga=normal console=tty0 i915.modeset=0 nouveau.modeset=0 modprobe.blacklist=nouveau,nvidiafb,nvidia,nvidia_drm,mei_me,btusb,dcdbas libata.allow_tpm=1 rd.udev.timeout=10 efi=noruntime usbcore.autosuspend=-1 pcie_aspm=off e1000e.IntMode=0 e1000e.eee_enable=0 consoleblank=0 systemd.battery-check=0 systemd.mask=suspend.target,sleep.target,hibernate.target,hybrid-sleep.target no_console_suspend mem_sleep_default=s2idle || goto blancco_efi_grub + kernel http://${server}/blancco/vmlinuz-ubuntu initrd=kexec-initrd.img ip=dhcp quiet loglevel=3 nomodeset vga=normal console=tty0 i915.modeset=0 nouveau.modeset=0 modprobe.blacklist=nouveau,nvidiafb,nvidia,nvidia_drm,mei_me,btusb,dcdbas libata.allow_tpm=1 rd.udev.timeout=10 efi=noruntime usbcore.autosuspend=-1 pcie_aspm=off e1000e.IntMode=0 e1000e.eee_enable=0 consoleblank=0 systemd.battery-check=0 systemd.mask=suspend.target,sleep.target,hibernate.target,hybrid-sleep.target no_console_suspend mem_sleep_default=s2idle || goto blancco_efi_grub initrd --name intel-ucode.img http://${server}/blancco/intel-ucode.img || goto blancco_efi_grub initrd --name amd-ucode.img http://${server}/blancco/amd-ucode.img || goto blancco_efi_grub initrd --name kexec-initrd.img http://${server}/blancco/kexec-initrd.img || goto blancco_efi_grub