I'm currently trying to automate Debian 11 template creation through Packer for Nutanix environment and need some advices about preseeding/automating Debian installation.
First of all, after reading this bible https://www.debian.org/releases/stable/amd64/apbs02.fr.html I went into using preseed.cfg file.
I started with the preseed.cfg file provided by Debian then adapt some stuff to fit my needs. Finally, I validate the syntax using debconf-set-selections -c preseed.cfg
command => everything is fine.
Now, i saw there's 3 differents ways to use preseed.cfg :
- through initrd : seems quite difficult to me and didn't find an easy tutorial/documentation
- through network : not an option at this moment due to some firewall restriction
- through file : seems the easiest and best option at the moment
When Packer starts the VM creation, it loads debian ISO as a CD-ROM in 1st position, and an empty virtual disk in the second position. I tell packer to load my preseed.cfg scripts as a cd-rom, so from an hypervisor perspective, a second cd-rom drive is mounted in the 3rd position.
BUT, in this case, VM boot on ISO (cd-rom 1st position), it doesn't mount the second cd-rom drive that have the preseed.cfg file and i can't access it unless I go to the debian console then mount the 2nd drive.
I saw a forum about uploading preseed.cfg into my original debian.iso folder and modifying the /isolinux/txt.cfg file like this (and then recreates the iso with OSCDIMG) :
label install
menu label ^Install
kernel /install.amd/vmlinuz
append vga=788 initrd=/install.amd/initrd.gz preseed/file=/cdrom/preseed/preseed.cfg --- quiet
My question is : is it fair to act like this ? is there something i missed or something easier to make it work easily ?
EDIT : i tried the initrd method, the only remaining thing is that i have to manually select Automated Install. How to get rid of this action ?
EDIT2: 02-01-2023
- i tried 2 more different things, 1st having this line in isolinux/txt.cfg
append auto=true priority=critical vga=788 initrd=/install.amd/initrd.gz preseed/file=/cdrom/preseed.cfg --- quiet
=> NOK, it still boot on boot menu (but ok if i select automated install manually, so it means preseed.cfg works pretty well) - and 2nd, test with
prompt 1 timeout 1
in isolinux.cfg => goes directly to select language manually...
EDIT3: 03-01-2023 here's the preseed.cfg i use :
# SETUP AUTO MODE
d-i auto-install/enable boolean true
d-i debconf/priority select critical
# LANGUAGE & KEYMAP
d-i debian-installer/locale string fr_FR
d-i keyboard-configuration/xkb-keymap select fr(latin9)
# NETWORK
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string template-debian-11-x64
d-i netcfg/get_domain string my_domain.net
d-i netcfg/hostname string template-debian-11-x64
# MIRRORS
d-i mirror/http/hostname string http://deb.debian.org/debian/
d-i mirror/http/hostname string http://security.debian.org/debian-security
# ACCOUNTS
d-i passwd/root-password password mypassword!
d-i passwd/root-password-again password mypassword!
d-i passwd/user-fullname string user
d-i passwd/username string user
d-i passwd/user-password password mypassword!
d-i passwd/user-password-again password mypassword!
d-i passwd/user-uid string 1010
d-i passwd/user-default-groups string si audio cdrom video
# LVM PART
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-auto-lvm/guided_size string 95%
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/choose_recipe select multi
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
#APT
d-i apt-setup/cdrom/set-first boolean false
tasksel tasksel/first multiselect standard, ssh-server
# GRUB
d-i grub-installer/bootdev string /dev/sda
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
#FINAL
d-i finish-install/reboot_in_progress note
Thanks a lot
Gael
Use a
boot_command
in Packer, which will send keypresses to the VM and, basically, type things into it. What it'll "type" is up to you. This goes to the packer file (I named itbase.pkr.hcl
):This way, packer will both serve the preseed file to the VM via HTTP and effectively override the boot options that are built into ISO with ones that you supply within packer file. No need to do any changes to ISO.
I am using Qemu; this is a copy of what I end up with when I did that half of a year ago. It looks like Nutanix builder doesn't have this boot_command; however, you can try to build the system using e.g. Qemu or Virtualbox and then use it with Nutanix. I just don't know.
Regarding your first question, I don't think there's any easier way to enable automated install for
debian installer
in terms of passing the preseed file to it. Mounting a second image could be a good idea for your specific need, but AFAIKdebian installer
does not respect a second media for its preseed and there are no workarounds that I know of (FYI, ubuntu'ssubiquity
installer does support such input).To achieve a "no-hands" install, I'll explain 2 things that should be taken care of.
Debian installer config (preseed)
To make the
debian installer
go fully automatic, you'll need this in your preseed file:This will simply tell
debian installer
not to ask questions it can find an answer to. In addition to that, you need to enable the auto mode withd-i auto-install/enable boolean true
, but ignore this for now (I'll talk about auto mode in the next part). Fromauto mode
doc:P.S. You can pass some the question/answers as kernel parameters with
key=value
format, wherekey
is an alias. That requires changing boot parameters. See the full list:aliases useful with preseeding
Bootloader config
In addition to installer configuration, we need to make some changes to the bootloader too. For
isolinux
bootloader to work in an unattended install scenario, I make these 2 changes to its config files inside the iso:isolinux
auto-select the default entry in the menu.First change is done by adding
auto=true
to theappend
line of the default menu entry. For debian 11, I found "Graphical install" to be the default entry. Since the config for this entry is read fromisolinux/gtk.cfg
, this change should be applied in that file. e.g. you can change your example bootloader config append line to"append auto=true vga=..."
.Second goal is achieved by changing
timeout 0
totimeout 1
inisolinux/isolinux.cfg
(see this).Note 1: The
auto=true
kernel parameter is the alias ford-i auto-install/enable boolean true
preseed config. It turned out that it should be enabled by kernel parameters for some reasons. Putting its equivalent in preseed file still ends up in language selection prompt waiting for user's input (maybe by the time that the preseed file is read bydebian installer
it's too late to enable the auto mode?).Note 2: You don't need
prompt 1
in isolinux config. It will probably do the opposite of what you want, which is preventing automatic selection of default entry (see the last line of this section).Note 3: Changing bootloader config requires modifications in iso contents (and thus an iso rebuild).
Note 4: The
isolinux
bootloader is commonly used for BIOS (legacy) systems. In UEFI systems, you need to configure GRUB instead.