Tip
If you want to bootstrap Ubuntu systems, you can look at my Ubuntu autoinstall setup.
This is a script for building a new installer for Debian "trixie" using a technique called a "preseeding". By using a "preseed" script we tell the installer the answer to a lot of routine questions to give ourselves a standard environment for new hosts. The script in this repository does the following:
- Creates a "paul" user with an SSH
authorized_keysfile and a known good environment. - Prompts you for a disk configuration but chooses
xfsinstead ofext4for the primary disk partition. - Enables "security" and "updates" repositories but does not enable backports, sources or automatic updates.
- Fixes the systemd timesync configuration.
- Fixes the /etc/resolv.conf file.
- Installs standard system utilities and an SSH server.
- Installs some additional basic, common software.
When using the installer there are still several questions that you must answer. These include:
- If there are multiple active interfaces you must choose one.
- What IP address and host name to use for this new host.
- Which disk to use for the installation. WARNING! This disk will be erased.
- Which disk will receive the master boot record.
Otherwise this will create an entirely automated installation.
Follow these steps to run this script:
- Get on a Debian host!
- Download an netinstall image from the Debian website.
- Clone this repository.
- Install these libraries:
apt-get install -y --no-install-recommends xorriso isolinux pwgen - Run the build script:
./build /path/to/debian-13.x.x-amd64-netinst.iso /path/to/preseed-debian-13.x.x-amd64-netinst.iso - Use the new ISO file to build your host.
Note that the preseed.cfg file has no password for logging in as the "paul" user. You can set a password or just use SSH keys. You can change the password by following these steps:
- Put the new password in a text file. Call it something like "newpassword.txt".
- Generate the new password:
cat newpassword.txt | mkpasswd -s -m sha-512 -S "$(pwgen -ns 16 1)" - Place that new password in the preseed.cfg file.
- Remove newpassword.txt and definitely do not put it into source control.
Use this ISO just like you would any other install ISO. A preseeded ISO file can build baremetal systems or virtual machines. It is only useful for on-premise instances and is not useful for cloud instances.
It's pretty simple:
- Run
diskutil listto find the thumb drive. It'll be labeled something like "/dev/disk6 (external, physical)" - Run
diskutil unmount /dev/disk6or whatever the disk is called, to unmount any volume that it might already have. - Run
sudo dd if=mydebian.iso of=/dev/disk6 bs=1Mto erase the disk and install the ISO.
Your thumb drive is now bootable.
I'm also always having to look this up so here are the steps.
- Attach the USB disk. Use
lsblkto see what the device label is that the USB disk has received. - Write the ISO file to your USB disk:
sudo dd bs=4M if=preseed.iso of=/dev/XXX conv=fdatasync
These links are where I got most of the information for building this preseed script.
- https://wiki.debian.org/DebianInstaller/Preseed
- https://wiki.debian.org/DebianInstaller/Preseed/EditIso
- https://github.com/pin/debian-vm-install
- https://www.debian.org/releases/squeeze/example-preseed.txt
- https://serverfault.com/questions/722021/preseeding-debian-install-efi
- https://github.com/dsgnr/ubuntu-16.04-unattended-install/blob/master/preseed.cfg