How To Use A Local Kickstart File For KVM

Using a local kickstart file can be tricky at first without knowing the proper method. Many guides just copy and paste using vsftp. Here’s how to do it locally.

If you’re using virt-install, you can include it right in the command line:

--initrd-inject=/root/anaconda-ks.cfg
--extra-args 'ks=file:/anaconda-ks.cfg'

The magic happens with the initrd-inject, the same as if you specified it manually to the kernel via TAB at the install screen of a fresh install. With this method, you don’t have to setup any FTP services and it makes scripting the command easier.

Here’s a working example:

virt-install \
--name centos7.0-dev \
--ram 512 \
--disk path=/var/lib/libvirt/images/centos7.0-dev.qcow2,size=10 \
--initrd-inject=/root/anaconda-ks.cfg \
--vcpus 1 \
--os-type linux \
--os-variant centos7.0 \
--network bridge=br0 \
--graphics none \
--location '/var/lib/libvirt/images/iso/CentOS-7.0-1406-x86_64-Minimal.iso' \
--extra-args 'ks=file:/anaconda-ks.cfg console=tty0 console=ttyS0,115200'
Linux 

See also