====== Unattended Installation of Ubuntu Server 18.04 via PXE ======
===== Preface =====
export P=/ubuntu/18.04
export TFTPROOT=/var/lib/tftp
export WEBROOT=/var/lib/www/html
export HTTP_URL=http://192.168.1.1
===== Directory Structure =====
mkdir -p $TFTPROOT/$P
mkdir -p $WEBROOT/$P
===== Obtain necessary files =====
export URL=http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
wget -O $TFTPROOT/$P/initrd.gz $URL/initrd.gz
wget -O $TFTPROOT/$P/linux $URL/linux
===== Create pxelinux.cfg stanza =====
cat << EOF >> $TFTPROOT/pxelinux.cfg/default
LABEL ubuntu18.04
MENU LABEL Ubuntu 18.04 Installation x64
KERNEL $P/linux
IPAPPEND 1
APPEND initrd=$P/initrd.gz ksdevice=eth0 locale=en_US.UTF-8 keyboard-configuration/layoutcode=de interface=eth0 hostname=ubuntu18 url=$HTTP_URL/$P/preseed.cfg
EOF
===== Create sources.list =====
Because of the PXE installation, sources.list in the installed system is empty - thus a usable sources.list is downloaded in the final stage of the installation - see below.
cat << EOF > $WEBROOT/$P/sources.list
###### Ubuntu Main Repos
deb http://at.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
###### Ubuntu Update Repos
deb http://at.archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://at.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
EOF
===== Create preseed.cfg =====
cat << EOF > $WEBROOT/$P/preseed.cfg
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string de
d-i netcfg/choose_interface select eth0
d-i netcfg/get_hostname string ubuntu18
d-i netcfg/get_domain string test.local
d-i netcfg/wireless_wep string
d-i mirror/country string manual
d-i mirror/http/hostname string at.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
d-i clock-setup/utc boolean true
d-i time/zone string EU/Vienna
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string at.pool.ntp.org
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/device_remove_lvm_span boolean true
d-i partman-auto/purge_lvm_from_device 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 vg00
d-i partman-auto/expert_recipe string \\
standard :: \\
1024 1026 1024 ext3 \\
$primary{ } \\
$bootable{ } \\
method{ format } \\
format{ } \\
use_filesystem{ } \\
filesystem{ ext3 } \\
mountpoint{ /boot } \\
. \\
24576 60000 -1 ext4 \\
$lvmok{ } \\
method{ format } \\
format{ } \\
use_filesystem{ } \\
filesystem{ ext4 } \\
mountpoint{ / } \\
lv_name{ lvRoot } \\
. \\
2048 2049 300% linux-swap \\
$lvmok{ } \\
method{ swap } \\
format{ } \\
lv_name{ lvSwap } \\
.
d-i partman-auto/choose_recipe standard
d-i partman-auto-lvm/guided_size string max
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
d-i partman-auto/confirm boolean true
#d-i passwd/root-login boolean false
#d-i passwd/make-user boolean false
#d-i passwd/root-password password r00tme
#d-i passwd/root-password-again password r00tme
d-i passwd/user-fullname string Ubuntu
d-i passwd/username string ubuntu
d-i passwd/user-password password ChangeMe!
d-i passwd/user-password-again password ChangeMe!
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
d-i pkgsel/include string openssh-server update-motd
tasksel tasksel/first multiselect server, openssh-server
d-i pkgsel/update-policy select none
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i preseed/late_command string \\
wget $HTTP_URL/$P/sources.list -O /target/etc/apt/sources.list
d-i finish-install/reboot_in_progress note
EOF
Regarding Partman Priority Voodo read [[https://www.bishnet.net/tim/blog/2015/01/29/understanding-partman-autoexpert_recipe/]]
{{tag>kb linux pxe ubuntu}}