Skip to content

Instantly share code, notes, and snippets.

@enoch85
Last active September 26, 2023 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save enoch85/0ba00af7bc62b26b5b4b6251ca7c4913 to your computer and use it in GitHub Desktop.
Save enoch85/0ba00af7bc62b26b5b4b6251ca7c4913 to your computer and use it in GitHub Desktop.
# USER: ubuntu
# PASS: Elefant09
# People should live in Sweden
d-i debian-installer/country string SE
# Computers should speak English
d-i debian-installer/language string en
d-i debian-installer/locale string en_US.UTF-8
d-i localechooser/preferred-locale string en_US.UTF-8
d-i localechooser/supported-locales en_US.UTF-8
# But keyboards are Swedish
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layout select Swedish
d-i keyboard-configuration/variant select Swedish
d-i keyboard-configuration/modelcode string pc105
d-i keyboard-configuration/layoutcode string se
d-i keyboard-configuration/xkb-keypam select se
### Network configuration
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto
# Just in case our DHCP server is busy.
d-i netcfg/dhcp_timeout string 60
# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/get_hostname string ubuntu
d-i netcfg/get_domain string local
# Root login?
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password $6$oBv4Cms4KvzM9eeQ$909ezy7UUgjizJ263LzV9etY1xfMcexgPnJll1OdmmtqtQMpMG7uOYQjEWVnFhMpV301NpVc6HSbR.7cl1VYs.
# User (non sudo)
d-i passwd/user-uid string
d-i passwd/user-fullname string Ubuntu User
d-i passwd/username string ubuntu
d-i passwd/user-password-crypted password $6$oBv4Cms4KvzM9eeQ$909ezy7UUgjizJ263LzV9etY1xfMcexgPnJll1OdmmtqtQMpMG7uOYQjEWVnFhMpV301NpVc6HSbR.7cl1VYs.
d-i user-setup/allow-password-weak boolean false
d-i user-setup/encrypt-home boolean false
d-i passwd/user-default-groups string adm cdrom dialout lpadmin plugdev sambashare sudo
# Set root password
d-i passwd/root-password-again password Elefant09
d-i passwd/root-password password Elefant09
# We've got all the time in the world
d-i time/zone string Europe/Stockholm
d-i clock-setup/utc boolean true
d-i clock-setup/ntp-server string 1.se.pool.ntp.org
# Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string se.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
# No proxy, please
d-i mirror/http/proxy string
#####################################################################################
# Disk Partitioning
# Find disk devices
# Unmount any hd partition that is mounted
d-i partman/early_command string \
USBDEV=$(list-devices usb-partition | sed "s/\(.*\)./\1/");\
BOOTDEV=$(list-devices disk | grep -v "$USBDEV" | head -1);\
debconf-set partman-auto/disk $BOOTDEV;\
debconf-set grub-installer/bootdev $BOOTDEV; \
umount /media;
# Use LVM, and wipe out anything that already exists
# d-i partman/early_command string vgs -separator=: -noheadings | cut -f1 -d: | while read vg ; do vgchange -an \$vg ; done ; pvs -separator=: -noheadings | cut -f1 -d: | while read pv ; do pvremove -ff -y \$pv ; done
# Write zeros to existing disks
#d-i partman/early_command \
# string /bin/dd if=/dev/zero of=/dev/sda bs=4K count=1
#d-i partman/early_command \
# string /bin/dd if=/dev/zero of=/dev/sdb bs=4K count=1
# Use mkfs to wipe the disks
d-i partman/early_command \
string /sbin/wipefs -a -f /dev/sda
d-i partman/early_command \
string /sbin/wipefs -a -f /dev/sdb
# Remove LVM ad MD.
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
# GPT Optionsd-i partman-basicfilesystems/choose_label string gpt
d-i partman-basicfilesystems/default_label string gpt
d-i partman-partitioning/choose_label string gpt
d-i partman-partitioning/default_label string gpt
d-i partman/choose_label string gpt
d-i partman/default_label string gpt
partman-partitioning partman-partitioning/choose_label select gpt
# LVM Options
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-auto-lvm/new_vg_name string volgroup0
d-i partman-auto-lvm/guided_size string max
# Set up Raid 1 - MDRAID
d-i partman-auto/method string raid
d-i partman-auto/disk string /dev/sda /dev/sdb
partman-auto/choose_recipe select multiraid
d-i partman-auto/alignment string optimal
# Set up partitioning, first two are for MDRAID then we build LVM partitions on top of this
# <raidtype> <devcount> <sparecount> <fstype> <mountpoint> <devices> <sparedevices>
d-i partman-auto-raid/recipe string \
1 2 0 ext4 /boot raidid=1 . \
1 2 0 lvm - raidid=2 .
# SWAP = 4096 MB
# BOOT = 2048 MB
# RAID = 100% of available size
# LVM = 100% of available size
# https://www.bishnet.net/tim/blog/2015/01/29/understanding-partman-autoexpert_recipe/
# https://github.com/xobs/debian-installer/blob/master/doc/devel/partman-auto-recipe.txt
# minimum size | priority | actual size (-1 = full)
d-i partman-auto/expert_recipe string \
multiraid :: \
2048 2048 2048 raid \
$gptonly{ } \
$primary{ } \
$lvmignore{ } \
$bootable{ } \
$bios_boot{ } \
method{ biosgrub } \
raidid{ 1 } \
. \
4096 10000 -1 raid \
$gptonly{ } \
$primary{ } \
$lvmignore{ } \
method{ raid } \
raidid{ 2 } \
. \
4096 10000 -1 ext4 \
$gptonly{ } \
$defaultignore $lvmok{ } lv_name{ root } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
. \
4096 4096 4096 linux-swap linux-swap \
$gptonly{ } \
$defaultignore $lvmok{ } lv_name{ swap } \
method{ swap } format{ } \
. \
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman-md/confirm_nooverwrite boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-md/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/confirm boolean true
d-i mdadm/boot_degraded boolean true
#####################################################################################
# Only install the standard system and language packs.
tasksel tasksel/first multiselect standard, ubuntu-server
d-i preseed/early_command string . /usr/share/debconf/confmodule; db_get debconf/priority; case $RET in low|medium) db_fset tasksel/first seen false; echo 'tasksel tasksel/first seen false' >>/var/lib/preseed/log ;; esac
d-i pkgsel/language-pack-patterns string
# Other extra packages
d-i pkgsel/include string nano openssh-server htop curl
# Kernel
d-i base-installer/kernel/image string linux-server
# APT
d-i apt-setup/services-select multiselect security
d-i apt-setup/security_host string security.ubuntu.com
d-i apt-setup/security_path string /ubuntu
d-i debian-installer/allow_unauthenticated string false
d-i pkgsel/upgrade select full-upgrade
d-i pkgsel/language-packs multiselect
d-i pkgsel/update-policy select none
d-i pkgsel/updatedb boolean true
# Policy for applying updates. May be "none" (no automatic updates),
# "unattended-upgrades" (install security updates automatically), or
# "landscape" (manage system with Landscape).
d-i pkgsel/update-policy select none
# Other stuff
d-i grub-installer/skip boolean false
d-i lilo-installer/skip boolean false
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean false
d-i finish-install/keep-consoles boolean false
d-i finish-install/reboot_in_progress note
d-i cdrom-detect/eject boolean true
d-i debian-installer/exit/halt boolean false
d-i debian-installer/exit/poweroff boolean false
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
# Provision script till exempel?
#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment