### --- Locale & Keyboard --- d-i debian-installer/locale string en_US.UTF-8 d-i debian-installer/country string {country} d-i debian-installer/language string en d-i localechooser/supported-locales multiselect en_US.UTF-8 d-i keyboard-configuration/xkb-keymap select us ### --- Network --- d-i netcfg/choose_interface select {primary_interface} d-i netcfg/get_hostname string {hostname} d-i netcfg/get_domain string {domain} d-i netcfg/disable_ipv6 boolean true d-i netcfg/wireless_wep string d-i netcfg/link_wait_timeout string 10 ### --- Mirror --- d-i mirror/country string manual d-i mirror/http/hostname string deb.debian.org d-i mirror/http/directory string /debian d-i mirror/http/proxy string ### --- Time --- d-i time/zone string {timezone} d-i clock-setup/utc boolean true d-i clock-setup/ntp boolean true ### --- Accounts --- d-i passwd/root-password-crypted password $6$.gvGPqrKa5NewXQh$DVlcXKmFdalflmdJ4/gFlRAzM0l6Ofnj26x9sVSCeFWoWc3eG5Q54A.YcpwrFMFSRjwPYbgEcg996GuFU8Nyv/ d-i passwd/user-fullname string ops d-i passwd/username string ops d-i passwd/user-password-crypted password $6$.gvGPqrKa5NewXQh$DVlcXKmFdalflmdJ4/gFlRAzM0l6Ofnj26x9sVSCeFWoWc3eG5Q54A.YcpwrFMFSRjwPYbgEcg996GuFU8Nyv/ d-i passwd/user-default-groups string sudo d-i passwd/user-uid string 1001 ### --- Clear existing partitions (Enhanced) --- d-i preseed/early_command string \ # Map serial IDs to device names and create mapping file \ DISK1_SERIAL="{disk1_serial}"; \ DISK2_SERIAL="{disk2_serial}"; \ DISK1_DEV=$(readlink -f /dev/disk/by-id/$DISK1_SERIAL | sed 's|.*/||'); \ DISK2_DEV=$(readlink -f /dev/disk/by-id/$DISK2_SERIAL | sed 's|.*/||'); \ echo "DISK1_SERIAL=$DISK1_SERIAL" > /tmp/disk_mapping; \ echo "DISK2_SERIAL=$DISK2_SERIAL" >> /tmp/disk_mapping; \ echo "DISK1_DEV=$DISK1_DEV" >> /tmp/disk_mapping; \ echo "DISK2_DEV=$DISK2_DEV" >> /tmp/disk_mapping; \ echo "Disk mapping: $DISK1_SERIAL -> /dev/$DISK1_DEV, $DISK2_SERIAL -> /dev/$DISK2_DEV"; \ # Wipe any existing RAID \ mdadm --stop --scan || true; \ wipefs -a /dev/$DISK1_DEV || true; \ wipefs -a /dev/$DISK2_DEV || true; \ dd if=/dev/zero of=/dev/$DISK1_DEV bs=1M count=100 || true; \ dd if=/dev/zero of=/dev/$DISK2_DEV bs=1M count=100 || true; \ dd if=/dev/zero of=/dev/$DISK1_DEV bs=1M seek=$(( $(blockdev --getsize64 /dev/$DISK1_DEV) / 1048576 - 100 )) count=100 || true; \ dd if=/dev/zero of=/dev/$DISK2_DEV bs=1M seek=$(( $(blockdev --getsize64 /dev/$DISK2_DEV) / 1048576 - 100 )) count=100 || true; \ # Create fresh partition tables \ parted -s /dev/$DISK1_DEV mklabel gpt || true; \ parted -s /dev/$DISK2_DEV mklabel gpt || true; \ # Wait to ensure changes are synchronized \ sync; \ sleep 5; \ echo "[*] Disk wiping complete for /dev/$DISK1_DEV and /dev/$DISK2_DEV"; # Complete removal of all existing metadata d-i partman/unmount_active boolean true d-i partman/filter_mounted boolean false d-i partman-md/device_remove_md boolean true d-i partman-lvm/device_remove_lvm boolean true d-i partman-lvm/device_remove_lvm_span boolean true d-i partman-md/confirm boolean true d-i partman-md/confirm_nooverwrite boolean true d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true ### --- Partitioning (RAID1 with proper recipe) --- d-i partman-auto/method string raid # Use short device names for partman-auto compatibility d-i partman-auto/disk string /dev/sda /dev/sdb # Fixed RAID recipe - separate EFI partitions, RAID for root only d-i partman-auto/expert_recipe string \ raid-boot :: \ 512 1024 1024 fat32 \ $primary{ } $bootable{ } \ method{ efi } format{ } \ . \ 8192 8192 8192 linux-swap \ $primary{ } method{ swap } format{ } \ . \ 1000 50000 1000000000 ext4 \ $primary{ } $raid{ } \ method{ raid } \ . # Use the custom recipe name d-i partman-auto/choose_recipe select raid-boot # RAID configuration - configure RAID1 for root partition only d-i partman-auto-raid/recipe string \ 1 2 0 ext4 / \ /dev/$DISK1_DEV#/dev/$DISK2_DEV \ . # RAID settings d-i partman-md/device_remove_md boolean true d-i partman-md/confirm boolean true d-i partman-md/confirm_nooverwrite boolean true # EFI and GPT configuration d-i partman-efi/non_efi_system boolean true d-i partman-partitioning/choose_label string gpt d-i partman-partitioning/default_label string gpt # Skip confirmation prompts d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true ### --- Kernel + base --- d-i base-installer/kernel/image string linux-image-amd64 d-i apt-setup/non-free boolean false d-i apt-setup/contrib boolean false ### --- Package selection --- tasksel tasksel/first multiselect standard d-i pkgsel/upgrade select full-upgrade ### --- Late commands (RAID setup) --- d-i preseed/late_command string \ echo "[*] Post-installation RAID setup for {hostname}"; \ # Source disk mapping \ . /tmp/disk_mapping || true; \ echo "Using disks: $DISK1_DEV and $DISK2_DEV"; \ in-target apt-get update; \ in-target apt-get install -y mdadm grub-efi-amd64 openssh-server; \ in-target mdadm --assemble --scan; \ in-target mdadm --detail --scan > /target/etc/mdadm/mdadm.conf; \ echo "md" >> /target/etc/initramfs-tools/modules; \ echo "raid1" >> /target/etc/initramfs-tools/modules; \ # Backup original fstab \ mv /target/etc/fstab /target/etc/fstab.backup; \ echo "# /etc/fstab generated by late_command" > /target/etc/fstab; \ # Add RAID root \ echo "UUID=$(blkid -s UUID -o value /dev/md0) / ext4 defaults 0 1" >> /target/etc/fstab; \ # Add EFI partitions using device names (will be converted to UUIDs) \ echo "UUID=$(blkid -s UUID -o value /dev/${DISK1_DEV}p1) /boot/efi vfat umask=0077 0 1" >> /target/etc/fstab; \ mkdir -p /target/boot/efi2; \ echo "UUID=$(blkid -s UUID -o value /dev/${DISK2_DEV}p1) /boot/efi2 vfat umask=0077 0 2" >> /target/etc/fstab; \ # Add swap partitions \ echo "UUID=$(blkid -s UUID -o value /dev/${DISK1_DEV}p2) none swap sw 0 0" >> /target/etc/fstab; \ echo "UUID=$(blkid -s UUID -o value /dev/${DISK2_DEV}p2) none swap sw 0 0" >> /target/etc/fstab; \ # Configure GRUB for RAID boot \ echo 'GRUB_DISABLE_OS_PROBER=true' >> /target/etc/default/grub; \ echo 'GRUB_CMDLINE_LINUX="rootdelay=10"' >> /target/etc/default/grub; \ # Install GRUB on both disks using device names \ in-target update-initramfs -u -k all; \ in-target grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=debian /dev/$DISK1_DEV; \ in-target grub-install --target=x86_64-efi --efi-directory=/boot/efi2 --bootloader-id=debian2 /dev/$DISK2_DEV; \ in-target update-grub; \ # Copy EFI boot files to backup partition for redundancy \ mount /dev/${DISK2_DEV}p1 /target/boot/efi2; \ mkdir -p /target/boot/efi2/EFI; \ cp -r /target/boot/efi/EFI/* /target/boot/efi2/EFI/ || true; \ umount /target/boot/efi2; \ echo "[*] Adding ops SSH Key"; \ mkdir -p /target/home/ops/.ssh; \ wget -O /target/home/ops/.ssh/authorized_keys http://controller:8088/files/authorized_keys.ops; \ chown -R ops:ops /target/home/ops/.ssh; \ chmod 700 /target/home/ops/.ssh; \ chmod 600 /target/home/ops/.ssh/authorized_keys; \ echo "[*] Configuring sudo for ops user"; \ wget -O /target/etc/sudoers.d/ops http://controller:8088/files/sudoers.ops; \ chmod 440 /target/etc/sudoers.d/ops; \ echo "[*] Create Hive User"; \ wget -O /target/tmp/setup-user.sh http://controller:8088/files/create-hive-user.sh; \ chmod +x /target/tmp/setup-user.sh; \ in-target bash /tmp/setup-user.sh; \ echo "[*] Updating APT sources"; \ wget -O /target/etc/apt/sources.list http://controller:8088/files/sources.list; \ wget -O /target/tmp/packages.txt http://controller:8088/files/packages.txt; \ in-target apt-get update; \ in-target apt-get upgrade -y; \ in-target xargs -a /tmp/packages.txt apt-get install -y; \ echo "[*] Modify Login Motd"; \ wget -O /target/etc/profile.d/motd.sh http://controller:8088/files/motd.txt; \ chmod +x /target/etc/profile.d/motd.sh; \ echo "[*] Setting up network"; \ mkdir -p /target/etc/network/interfaces.d; \ echo 'bonding' >> /target/etc/modules; ### --- Bootloader --- d-i grub-installer/bootdev string default d-i grub-installer/force-efi-extra-removable boolean true ### --- Final reboot --- d-i finish-install/reboot_in_progress note