Linux/Ubuntu/Automated Installation

From Omnia
< Linux‎ | Ubuntu
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Get Preseed

Install debconf:

apt install debconf-utils

find out all of the current preseed settings from your current install, you would run:

debconf-get-selections --installer > install-options.cfg

To dump the entire debconf database containing these values:

debconf-get-selections > alloptions.cfg

debconf pulls these options from:

/var/log/installer/cdebconf/questions.dat

Ref:

Make Fully

src: https://askubuntu.com/questions/806820/how-do-i-create-a-completely-unattended-install-of-ubuntu-desktop-16-04-1-lts

Current Solution I have currently created an unattended install, but am not sure if it is correct - meaning that I should have edited the isolinux/isolinux.cfg

There were many differences between the post I linked and the Ubuntu Desktop image. Here is my solution:

Step 1

Mounted Ubuntu ISO so that I can copy the contents to another directory and then edit the pertinent files.

mkdir -p /mnt/iso
mount -o loop ubuntu.iso /mnt/iso

Step 2

I then copied the ISO files to another directory for editing.

mkdir -p /opt/ubuntuiso
cp -rT /mnt/iso /opt/ubuntuiso

Step 3

I edited the isolinux/isolinux.cfg file and replaced everything inside with the following:

default live-install
label live-install
  menu label ^Install Ubuntu
  kernel /casper/vmlinuz.efi
  append  file=/cdrom/ks.preseed auto=true priority=critical debian-installer/locale=en_US keyboard-configuration/layoutcode=us ubiquity/reboot=true languagechooser/language-name=English countrychooser/shortlist=US localechooser/supported-locales=en_US.UTF-8 boot=casper automatic-ubiquity initrd=/casper/initrd.lz quiet splash noprompt noshell ---

The append line is very long so for easy reading, here are all the options I used:

file=/cdrom/ks.preseed 
auto=true 
priority=critical 
debian-installer/locale=en_US 
keyboard-configuration/layoutcode=us 
ubiquity/reboot=true 
languagechooser/language-name=English 
countrychooser/shortlist=US 
localechooser/supported-locales=en_US.UTF-8 
boot=casper 
automatic-ubiquity 
initrd=/casper/initrd.lz 
quiet 
splash 
noprompt 
noshell

I found that all these boot parameters were needed to get a completely unattended install. For Ubuntu Server, it may be different.

Step 4

I tried using and creating many preseed files, but I found the more complex, the more chance for errors. This is currently my simple preseed file that works with the above isolinux.cfg file.

### Partitioning
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-auto/choose_recipe select atomic

# This makes partman automatically partition without confirmation
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

# Locale
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us

# Network
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/choose_interface select auto

# Clock
d-i clock-setup/utc-auto boolean true
d-i clock-setup/utc boolean true
d-i time/zone string US/Pacific
d-i clock-setup/ntp boolean true

# Packages, Mirrors, Image
d-i base-installer/kernel/override-image string linux-server
d-i base-installer/kernel/override-image string linux-image-amd64
d-i mirror/country string US
d-i mirror/http/proxy string
d-i apt-setup/restricted boolean true
d-i apt-setup/universe boolean true
d-i pkgsel/install-language-support boolean false
tasksel tasksel/first multiselect ubuntu-desktop

# Users
d-i passwd/user-fullname string Liason
d-i passwd/username string liason
d-i passwd/user-password-crypted password [crpyt 3]
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password [crypt 3]
d-i user-setup/allow-password-weak boolean true

# Grub
d-i grub-installer/grub2_instead_of_grub_legacy boolean true
d-i grub-installer/only_debian boolean true
d-i finish-install/reboot_in_progress note

# Custom Commands

I didn't include my encrypted passwords so if you try this preseed file, please change them to an encrypted password. Here is 3 ways to make the password.

Step 5

I created the new ISO from the the /opt/ubuntuiso/ directory.

mkisofs -D -r -V ATTENDLESS_UBUNTU -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /opt/autoinstall.iso /opt/ubuntuiso

Step 6

I finally tested it with Virtualbox and it created a completely unattended install.

Script on Ubuntu 18

https://stackoverflow.com/questions/42145522/debconf-get-selections-installer-output-empty

mail script:

$ cat mail
set -x
# x=mail; cd /var/tmp; wget http://gw/ks/post/ub/$x -O $x; sh ./$x
#
# ref: http://blog.delgurth.com/2009/01/19/pre-loading-debconf-values-for-easy-installation/

d=`grep search /etc/resolv.conf | sed 's/search //'`
hostname=`hostname`
fqdn=$hostname.$d

cat<<EOF | debconf-set-selections
postfix postfix/main_mailer_type        select  Internet with smarthost
postfix postfix/recipient_delim string  +
postfix postfix/mailname        string  $fqdn
postfix postfix/chattr  boolean false
postfix postfix/destinations    string  $fqdn, \$myhostname, $hostname, localhost.localdomain, localhost
postfix postfix/relayhost       string  mailhost.foobar.com
postfix postfix/procmail        boolean true
postfix postfix/compat_conversion_warning       boolean true
postfix postfix/mynetworks      string  127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
postfix postfix/mailbox_limit   string  0
postfix postfix/rfc1035_violation       boolean false
postfix postfix/protocols       select  all
postfix postfix/main_cf_conversion_warning      boolean true
postfix postfix/root_address    string
EOF

debconf-get-selections | grep postfix

apt-get -qq -y install postfix

here is the %post section of the kickstart with that mail script:

%post --interpreter=/bin/bash

exec > /root/post.log 2>&1
set -x
scripts="
autofs
rootssh
users
sudo
mail
"
for x in $scripts; do
wget http://gw/ks/post/ub/$x -O $x; sh ./$x
done

Ubuntu 16.04.6 Preseed

See Linux/Ubuntu/Automated Installation/Ubuntu 16.04.6

Ubuntu 18.04.1 Preseed

See Linux/Ubuntu/Automated Installation/Ubuntu 18.04.1

Ubuntu 18.04.2 Preseed

See Linux/Ubuntu/Automated Installation/Ubuntu 18.04.2

Ubuntu 18.10 Preseed

See Linux/Ubuntu/Automated Installation/Ubuntu 18.10