Boot menu: "Clonezilla: back up this PC" and "restore this PC" ask for the machine number and boot Clonezilla (64-bit with Debian shim, or 32-bit i686 by cpuid) with ocs_repository=smb3://clonezilla:<pw>@server/clonezilla/, ocs_prerun fetching clonezilla-scripts/pxe-cz.sh and ocs_live_run running it. The script validates the machine number, saves <machine>-<YYYY-MM-DD-HHMM> (server time), writes pxe-meta.txt, runs ocs-chkimg, and restores only that machine's images with -k1 -r after a typed YES. The old entry is "Clonezilla: manual". Playbook: clonezilla Samba user for the [clonezilla] share only, password from clonezilla_smb_password (validated, filled into the menu placeholder), scripts installed to the web root. Webapp: Clonezilla backups page lists image folders and zips grouped by machine number with serial/model/version/check, serial mismatch flag, delete, move to another machine, streamed tar download, disk space bar and an explicit keep-last-N retention with preview. Tests and a VM test plan added.
196 lines
11 KiB
Plaintext
196 lines
11 KiB
Plaintext
#!ipxe
|
|
|
|
set server 172.16.9.1
|
|
|
|
:menu
|
|
menu GE Aerospace PXE Boot Menu
|
|
item --gap -- ---- Windows Deployment ----
|
|
item winpe Windows PE (Image Deployment)
|
|
item --gap -- ---- Drive Erase ----
|
|
item blancco Blancco Drive Eraser
|
|
item blancco_debug Blancco Drive Eraser (debug / SSH)
|
|
item --gap -- ---- Utilities ----
|
|
item cz_backup Clonezilla: back up this PC
|
|
item cz_restore Clonezilla: restore this PC
|
|
item clonezilla Clonezilla: manual (USB or other location)
|
|
item clonezilla32 Clonezilla: manual, 32-bit (XP-era PCs, forced)
|
|
item --gap -- Memory test: Dell PCs press F12 at power-on, Diagnostics
|
|
item --gap -- ----
|
|
item reboot Reboot
|
|
item exit Exit to BIOS
|
|
choose --default winpe --timeout 30000 target && goto ${target}
|
|
|
|
:winpe
|
|
# iPXE 2.0 reads the firmware variable; older iPXE cannot (empty), so it
|
|
# warns as before. Secure Boot confirmed on: no warning, no wait.
|
|
iseq ${efi/SecureBoot:uint8} 1 && goto winpe_boot ||
|
|
iseq ${efi/SecureBoot:hex} 01 && goto winpe_boot ||
|
|
echo
|
|
echo Secure Boot is OFF on this PC (or this iPXE cannot tell).
|
|
echo (iPXE read SecureBoot as: [${efi/SecureBoot:hex}] [${efi/SecureBoot:uint8}])
|
|
echo Windows deployment requires Secure Boot to be ENABLED.
|
|
echo If you disabled it earlier, re-enable it in BIOS Setup now.
|
|
echo
|
|
prompt --timeout 5000 Press any key to continue (auto-boot in 5s)... && goto winpe_boot || goto winpe_boot
|
|
|
|
:winpe_boot
|
|
kernel http://${server}/win11/wimboot gui
|
|
initrd http://${server}/win11/EFI/Microsoft/Boot/boot.stl EFI/Microsoft/Boot/Boot.stl
|
|
initrd http://${server}/win11/EFI/Microsoft/Boot/BCD EFI/Microsoft/Boot/BCD
|
|
initrd http://${server}/win11/EFI/Boot/bootx64.efi EFI/Boot/bootx64.efi
|
|
initrd http://${server}/win11/Boot/boot.sdi Boot/boot.sdi
|
|
initrd http://${server}/win11/sources/boot.wim sources/boot.wim
|
|
# A command that fails without || aborts the whole iPXE script (the PC
|
|
# drops to firmware with no explanation), so every boot line has one.
|
|
boot || goto winpe_failed
|
|
|
|
:winpe_failed
|
|
echo
|
|
echo Windows PE boot FAILED (see the error above).
|
|
echo Check that the PXE server is up and the win11 boot files are staged.
|
|
prompt Press any key to return to menu... && goto menu || goto menu
|
|
|
|
# --- Clonezilla by machine number (back up / restore) ---------------------
|
|
# The image share is \\${server}\clonezilla (Samba account clonezilla,
|
|
# the playbook fills in its password). Clonezilla mounts it on
|
|
# /home/partimag (ocs_repository, SMB 3), downloads
|
|
# clonezilla-scripts/pxe-cz.sh (ocs_prerun) and runs it (ocs_live_run):
|
|
# it checks the machine number, saves <machine>-<YYYY-MM-DD-HHMM> or lists
|
|
# that machine's images to restore, and writes pxe-meta.txt.
|
|
:cz_backup
|
|
set cz_mode save
|
|
goto cz_machine
|
|
|
|
:cz_restore
|
|
set cz_mode restore
|
|
goto cz_machine
|
|
|
|
:cz_machine
|
|
# iPXE cannot check characters: pxe-cz.sh accepts letters, digits and dash
|
|
# and asks again there. Empty: ask again. Esc / Ctrl-C: back to the menu.
|
|
echo
|
|
echo -n Machine number: && read czmachine || goto menu
|
|
isset ${czmachine} || goto cz_machine
|
|
# Same CPU check as the manual entry below (cpuid --ext 29 = 64-bit).
|
|
cpuid --ext 29 && goto cz_auto64 || goto cz_auto32
|
|
|
|
:cz_auto64
|
|
set base http://${server}/clonezilla
|
|
kernel ${base}/vmlinuz boot=live username=user union=overlay config components noswap edd=on nomodeset nodmraid locales=en_US.UTF-8 keyboard-layouts=us ocs_prerun="wget -q -T 15 -t 5 -O /tmp/pxe-cz.sh http://${server}/clonezilla-scripts/pxe-cz.sh" ocs_repository="smb3://clonezilla:__CLONEZILLA_SMB_PASSWORD__@${server}/clonezilla/" echo_ocs_repository=no ocs_live_run="bash /tmp/pxe-cz.sh" ocs_live_extra_param="" ocs_live_batch=no net.ifnames=0 nosplash noprompt fetch=${base}/filesystem.squashfs pxe_cz_mode=${cz_mode} pxe_machine=${czmachine} pxe_end=1 || goto secureboot_warn
|
|
initrd ${base}/initrd.img || goto boot_failed
|
|
# Secure Boot ON: Debian's shim, as in :clonezilla64 below.
|
|
shim ${base}/shimx64.efi ||
|
|
boot || goto secureboot_warn
|
|
|
|
:cz_auto32
|
|
# 3.2.0-5 i686 over legacy BIOS only; UEFI goes to the 64-bit build.
|
|
iseq ${platform} efi && goto cz_auto64 ||
|
|
set base http://${server}/clonezilla-i686
|
|
kernel ${base}/vmlinuz boot=live username=user union=overlay config components noswap edd=on nomodeset nodmraid locales=en_US.UTF-8 keyboard-layouts=us ocs_prerun="wget -q -T 15 -t 5 -O /tmp/pxe-cz.sh http://${server}/clonezilla-scripts/pxe-cz.sh" ocs_repository="smb3://clonezilla:__CLONEZILLA_SMB_PASSWORD__@${server}/clonezilla/" echo_ocs_repository=no ocs_live_run="bash /tmp/pxe-cz.sh" ocs_live_extra_param="" ocs_live_batch=no net.ifnames=0 nosplash noprompt fetch=${base}/filesystem.squashfs pxe_cz_mode=${cz_mode} pxe_machine=${czmachine} pxe_end=1 || goto boot_failed
|
|
initrd ${base}/initrd.img || goto boot_failed
|
|
boot || goto boot_failed
|
|
|
|
# --- Clonezilla manual (interactive: USB, SSH, NFS or any share) ------------
|
|
:clonezilla
|
|
# 64-bit CPUs (cpuid extended bit 29 = long mode) get the current Clonezilla;
|
|
# older 32-bit-only CPUs (Pentium 4 without EM64T, Pentium M, early Atom:
|
|
# many XP-era PCs) get the last 32-bit release. If this iPXE has no cpuid
|
|
# command the check fails and the 32-bit build is used, which also runs
|
|
# on 64-bit CPUs.
|
|
cpuid --ext 29 && goto clonezilla64 || goto clonezilla32
|
|
|
|
:clonezilla64
|
|
set base http://${server}/clonezilla
|
|
kernel ${base}/vmlinuz boot=live username=user union=overlay config components noswap edd=on nomodeset nodmraid locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch=no net.ifnames=0 nosplash noprompt fetch=${base}/filesystem.squashfs || goto secureboot_warn
|
|
initrd ${base}/initrd.img || goto boot_failed
|
|
# Secure Boot ON: Clonezilla runs a Debian-signed kernel, started through
|
|
# Debian's Microsoft-signed shim (from the Clonezilla release, staged as
|
|
# clonezilla/shimx64.efi by prepare-boot-tools.sh), the same way Blancco
|
|
# uses Ubuntu's. Its modules (usb-storage, uas, exfat) are signed by the
|
|
# same build key, so USB drives work. Without the shim command (legacy
|
|
# BIOS, old iPXE) the line fails harmlessly and the kernel boots directly.
|
|
shim ${base}/shimx64.efi ||
|
|
boot || goto secureboot_warn
|
|
|
|
:clonezilla32
|
|
# Clonezilla 3.2.0-5 i686 (the last 32-bit release; later ones are amd64
|
|
# only), for legacy-BIOS XP-era PCs. A UEFI PC is always 64-bit and its
|
|
# firmware cannot start a 32-bit kernel, so UEFI goes to the 64-bit build.
|
|
iseq ${platform} efi && goto clonezilla64 ||
|
|
set base http://${server}/clonezilla-i686
|
|
kernel ${base}/vmlinuz boot=live username=user union=overlay config components noswap edd=on nomodeset nodmraid locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch=no net.ifnames=0 nosplash noprompt fetch=${base}/filesystem.squashfs || goto boot_failed
|
|
initrd ${base}/initrd.img || goto boot_failed
|
|
boot || goto boot_failed
|
|
|
|
:blancco
|
|
iseq ${platform} pcbios && goto blancco_bios || goto blancco_efi
|
|
|
|
: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 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
|
|
initrd --name initramfs-bde-linux.img http://${server}/blancco/initramfs-bde-linux.img || goto blancco_bios_failed
|
|
boot || goto blancco_bios_failed
|
|
:blancco_bios_failed
|
|
echo
|
|
echo Blancco BIOS boot FAILED.
|
|
prompt Press any key to return to menu... && goto menu
|
|
|
|
:blancco_debug
|
|
iseq ${platform} pcbios && goto blancco_bios ||
|
|
echo Loading Blancco UEFI (debug: verbose, SSH for root)...
|
|
kernel http://${server}/blancco/vmlinuz-ubuntu-70 initrd=kexec-initrd-70.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 blancco.debug=1 || 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-70.img http://${server}/blancco/kexec-initrd-70.img || goto blancco_efi_grub
|
|
# Secure Boot ON: iPXE 2.0 starts the Canonical-signed kernel through
|
|
# Ubuntu's Microsoft-signed shim. Older iPXE has no shim command: the
|
|
# line fails harmlessly and the kernel boots directly (Secure Boot off).
|
|
shim http://${server}/blancco/shimx64.efi ||
|
|
boot || goto blancco_efi_grub
|
|
|
|
:blancco_efi
|
|
echo Loading Blancco UEFI (direct kernel)...
|
|
kernel http://${server}/blancco/vmlinuz-ubuntu-70 initrd=kexec-initrd-70.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-70.img http://${server}/blancco/kexec-initrd-70.img || goto blancco_efi_grub
|
|
# Secure Boot ON: iPXE 2.0 starts the Canonical-signed kernel through
|
|
# Ubuntu's Microsoft-signed shim. Older iPXE has no shim command: the
|
|
# line fails harmlessly and the kernel boots directly (Secure Boot off).
|
|
shim http://${server}/blancco/shimx64.efi ||
|
|
boot || goto blancco_efi_grub
|
|
:blancco_efi_grub
|
|
echo Direct kernel boot failed - trying GRUB chain fallback...
|
|
chain http://${server}/blancco/grubx64.efi || goto secureboot_warn
|
|
|
|
:boot_failed
|
|
echo
|
|
echo Download FAILED (see the error above). Check the PXE server and retry.
|
|
prompt Press any key to return to menu... && goto menu || goto menu
|
|
|
|
:secureboot_warn
|
|
echo
|
|
echo ======================================================
|
|
echo This option could not start with Secure Boot enabled.
|
|
echo
|
|
echo 1. Reboot this machine
|
|
echo 2. Press F2 / Del to enter BIOS Setup
|
|
echo 3. Disable Secure Boot
|
|
echo 4. Save and exit BIOS
|
|
echo 5. PXE boot again and select this option
|
|
echo
|
|
echo Re-enable Secure Boot after completing the task.
|
|
echo ======================================================
|
|
echo
|
|
prompt Press any key to return to menu...
|
|
goto menu
|
|
|
|
:reboot
|
|
reboot
|
|
|
|
:exit
|
|
exit
|