Fully unattended USB install: patch GRUB and remove cloud-init
- build-usb.sh now patches the ISO's grub.cfg with xorriso to add 'autoinstall' kernel param (skips confirmation prompt) and reduces GRUB timeout from 30s to 5s - Disable and remove cloud-init on the installed system to prevent boot delays on air-gapped network - Fix ISO size calculation to use patched ISO for CIDATA partition offset Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
18
build-usb.sh
18
build-usb.sh
@@ -105,14 +105,28 @@ done
|
||||
|
||||
# --- Write ISO to USB ---
|
||||
echo "[2/6] Writing Ubuntu ISO to $USB_DEV (this may take several minutes)..."
|
||||
dd if="$ISO_PATH" of="$USB_DEV" bs=4M status=progress oflag=sync
|
||||
|
||||
# Patch ISO to add 'autoinstall' kernel parameter (skips confirmation prompt)
|
||||
PATCHED_ISO=$(mktemp /tmp/ubuntu-autoinstall-XXXXXX.iso)
|
||||
cp "$ISO_PATH" "$PATCHED_ISO"
|
||||
PATCHED_GRUB=$(mktemp /tmp/grub-XXXXXX.cfg)
|
||||
xorriso -osirrox on -indev "$ISO_PATH" -extract /boot/grub/grub.cfg "$PATCHED_GRUB" 2>/dev/null
|
||||
sed -i 's|linux\t/casper/vmlinuz ---|linux\t/casper/vmlinuz autoinstall ---|' "$PATCHED_GRUB"
|
||||
sed -i 's/^set timeout=30/set timeout=5/' "$PATCHED_GRUB"
|
||||
xorriso -indev "$PATCHED_ISO" -outdev "$PATCHED_ISO" \
|
||||
-map "$PATCHED_GRUB" /boot/grub/grub.cfg \
|
||||
-boot_image any replay 2>/dev/null
|
||||
echo " Patched GRUB: added 'autoinstall' kernel param, reduced timeout to 5s"
|
||||
|
||||
ISO_SIZE=$(stat -c%s "$PATCHED_ISO")
|
||||
dd if="$PATCHED_ISO" of="$USB_DEV" bs=4M status=progress oflag=sync
|
||||
sync
|
||||
rm -f "$PATCHED_ISO" "$PATCHED_GRUB"
|
||||
|
||||
# --- Find the end of the ISO to create CIDATA partition ---
|
||||
echo "[3/6] Creating CIDATA partition after ISO data..."
|
||||
|
||||
# Get ISO size in bytes and calculate the start sector for the new partition
|
||||
ISO_SIZE=$(stat -c%s "$ISO_PATH")
|
||||
SECTOR_SIZE=512
|
||||
# Start the CIDATA partition 1MB after the ISO ends (alignment)
|
||||
START_SECTOR=$(( (ISO_SIZE / SECTOR_SIZE) + 2048 ))
|
||||
|
||||
Reference in New Issue
Block a user