Skip to content

Instantly share code, notes, and snippets.

@khaosx
Last active March 23, 2020 23:12
Show Gist options
  • Save khaosx/159da8b5e7435db04eeeea9eeb9477f5 to your computer and use it in GitHub Desktop.
Save khaosx/159da8b5e7435db04eeeea9eeb9477f5 to your computer and use it in GitHub Desktop.
Example of preseed.cfg for unattended install of Ubuntu 18.04.4 - minimum disk size is 36864MB
###############################################################################
# preseed.cfg #
# #
# Applies to Ubuntu 18.04 (LTS) #
# Modified from: #
# https://help.ubuntu.com/lts/installation-guide/example-preseed.txt #
# #
# Configures install time choices for Ubuntu 18.04 (LTS) #
# - Partitioning is done in accordance with recommended layout from CIS #
# benchmarks (as of 01/03/2020, v2.0.1) #
# #
###############################################################################
### Unattended Installation
d-i auto-install/enable boolean true
d-i debconf/priority select critical
### Localization
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US
# Keyboard selection.
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/xkb-keymap select us
d-i keyboard-configuration/layoutcode string us
d-i keyboard-configuration/variantcode string
# 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
# 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 unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
# If you want to force a hostname, regardless of what either the DHCP
# server returns or what the reverse DNS entry for the IP is, uncomment
# and adjust the following line.
d-i netcfg/hostname string ubuntu
# Disable that annoying WEP key dialog.
d-i netcfg/wireless_wep string
### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
d-i mirror/country string manual
d-i mirror/http/hostname string archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
### Account setup
# Skip creation of a root account
d-i passwd/root-login boolean false
# Create Vagrant User
d-i passwd/user-fullname string Edwin Jarvis
d-i passwd/username string jarvis
d-i passwd/user-password-crypted password [PASSWORD HASH HERE]
d-i user-setup/encrypt-home boolean false
d-i user-setup/allow-password-weak boolean true
### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean false
# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string US/Eastern
# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean true
# NTP server to use. The default is almost always fine here.
d-i clock-setup/ntp-server string 0.ubuntu.pool.ntp.org
### Partitioning
# Use LVM, and wipe out anything that already exists
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-auto-lvm/guided_size string max
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto-lvm/new_vg_name string vg-root
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
### Disk layout
d-i partman-auto/expert_recipe string \
custom-lvm :: \
256 256 256 ext2 $primary{ } $bootable{ } \
mountpoint{ /boot } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext2 } \
. \
3072 3072 3072 linux-swap $lvmok{ } \
lv_name{ lv_swap } \
in_vg { vg-root } \
method{ swap } \
format{ } \
. \
10240 10240 -1 ext4 $lvmok{ } \
mountpoint{ / } \
lv_name{ lv_root } \
in_vg { vg-root } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
. \
10240 10240 10240 ext4 $lvmok{ } \
mountpoint{ /home } \
lv_name{ lv_home } \
in_vg { vg-root } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
options/nodev{ nodev } \
. \
3072 3072 3072 ext4 $lvmok{ } \
mountpoint{ /tmp } \
lv_name{ lv_tmp } \
in_vg { vg-root } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
options/nosuid{ nosuid } \
options/nodev{ nodev } \
options/noexec{ noexec } \
. \
6144 6144 6144 ext4 $lvmok{ } \
mountpoint{ /var } \
lv_name{ lv_var } \
in_vg { vg-root } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
. \
1024 1024 1024 ext4 $lvmok{ } \
mountpoint{ /var/tmp } \
lv_name{ lv_vartmp } \
in_vg { vg-root } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
options/nosuid{ nosuid } \
options/nodev{ nodev } \
options/noexec{ noexec } \
. \
1024 1024 1024 ext4 $lvmok{ } \
mountpoint{ /var/log } \
lv_name{ lv_log } \
in_vg { vg-root } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
. \
1024 1024 1024 ext4 $lvmok{ } \
mountpoint{ /var/log/audit } \
lv_name{ lv_audit } \
in_vg { vg-root } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
. \
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
### Package selection
tasksel tasksel/first multiselect none
# Individual additional packages to install
d-i pkgsel/include string openssh-server build-essential open-vm-tools software-properties-common update-notifier-common
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
d-i pkgsel/upgrade select full-upgrade
# 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 unattended-upgrades
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true
# This one makes grub-installer install to the MBR if it also finds some other
# OS, which is less safe as it might not be able to boot that other OS.
d-i grub-installer/with_other_os boolean true
# Set vagrant for passwordless sudo
d-i preseed/late_command string \
echo "%jarvis ALL=(ALL:ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/jarvis && chmod 0440 /target/etc/sudoers.d/jarvis
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment