My KVM tool makes use of kickstart files for automated installation of both CentOS and Ubuntu guests. There is a lot of documenation from different sources on kickstart files but it can seem like there is conflicting information, so I wanted to create my own notes.
Kickstart and preseed are not the same thing. I'm pretty sure you can't mix and match. I went down the line of just using kickstart files but one day I will probably have a post on preseed files.
Comments start with a
#and use them liberally as you are probably going to need them. Especially for easily switching out options.
packagesare sections that should start with
%. For example
%packages. I read that they should also end with
%endbut my kickstart file linked below works just fine without them and I really don't want to change it after finally getting a working version.
postare for scripts/commands you want to run before and after the installation respectively.
To be safe, specify the
presection before the
packagessection and the
packagessection before the
--nochroot, the filesystem is at /target (at least in ubuntu 16.04). For example
/target/root. I don't think CentOS is like this because I see that NixCraft is not using it in their kickstart file for CentOS.
I found the best way to log output of a post script was to use the following format (note that I had to use
/targetas mentioned in previous point):
%post --nochroot ( # script commands go here.... ) 1> /target/root/post_install.log 2>&1
- Packages use a
@symbol to specify a group/bundle of packages. Don't put this before every package name. To be safer, you may want to just specify a lot of packages manually than use the group. For example, the packages section below will install the
ubuntu-servergroup of packages, as well as the
%packages @ ubuntu-server openssh-server
- Read here about how to find what packages are in a group.
- Most other parameters are self explanatory.
Linking Kickstart Files
- I found that the easiest way to work with kickstart files was to host them on pastebin and use an http
rawlink. I believe others have managed to fetch them over an NFS but I haven't tried. I could not use a local file path.
Example Ubuntu 16.04 Kickstart File
The script below will install ubuntu 16.04 with the user
ubuntu that takes the password
# Ubuntu server 64bit example kickstart/seed that shuts down upon completion # and runs post install steps to fix console access # System language #lang en_US lang en_GB # Language modules to install #langsupport en_US langsupport en_GB # System keyboard keyboard us # System mouse mouse # System timezone #timezone America/Chicago timezone --utc America/Chicago # Root password rootpw --disabled # Initial user user ubuntu --fullname "" --password ubuntu preseed user-setup/allow-password-weak boolean true # pick only one of these actions to take after installation completed #reboot #shutdown #halt poweroff # Use text mode install text # Install OS instead of upgrade install # Use http installation media url --url http://archive.ubuntu.com/ubuntu # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr yes # Partition clearing information clearpart --all --initlabel # Partition setup part / --fstype ext4 --size 1 --grow #part /boot --fstype ext2 --size 200 --asprimary #part swap --size 1024 #part pv.01 --size 1 --grow #volgroup rootvg pv.01 #logvol / --fstype ext4 --vgname=rootvg --size=1 --grow --name=rootvol #preseed partman-lvm/confirm_nooverwrite boolean true # If you have swap commented out/not specified then you need to have this line. preseed --owner partman-basicfilesystems partman-basicfilesystems/no_swap boolean false # System authorization infomation auth --useshadow --enablemd5 # Firewall configuration firewall --disabled # Do not configure the X Window System skipx # Make sure to install the acpid package so that virsh commands such # as virsh shutdown will take effect # @ is for groups - http://landoflinux.com/linux_kickstart_keywords.html %packages @ ubuntu-server openssh-server acpid libpam-systemd dbus byobu vim # update grub after installation so that we can see the console later # The new filesystem is under /target. e.g. /root is now /target/root # and https://help.ubuntu.com/community/KickstartCompatibility %post --nochroot ( sed -i "s;quiet;quiet console=ttyS0;" /target/etc/default/grub sed -i "s;quiet;quiet console=ttyS0;g" /target/boot/grub/grub.cfg ) 1> /target/root/post_install.log 2>&1 %end