Creating VM on KVM hosts with kickstart file
virt-install can be used to provision kickstart while installing, this provides an answer file to all the settings required to install OS. The kickstart file will have the information of partition layout, username, password, etc.
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use text mode install
text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=vda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts=''
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=eth0 --ipv6=auto --no-activate
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$pufROlQv24BRI6uK$...
# System timezone
timezone Asia/Kolkata --isUtc
user --groups=wheel --name=cipher --password=...
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=vda
autopart --type=thinp
# Partition clearing information
clearpart --all --initlabel --drives=vda
$ virt-install \
--name linux2 \
--ram 512 \
--disk path=/dev/store/linux2 \
--vcpus 2 \
--os-type linux \
--os-variant rhel7 \
--network network=default \
--graphics none \
--console pty,target_type=serial \
--location '/home/cipher/CentOS-7-x86_64-Minimal-1708.iso' \
--initrd-inject '/var/www/html/pub/ks.cfg' \
--extra-args 'console=ttyS0,115200n8 serial' \
--extra-args 'ks=file:/ks.cfg' \
--accelerate
The kickstart file is injected via --initrd-inject and referenced with ks=file:/ks.cfg in the kernel command line, allowing fully automated installation.
Related Articles
Creating VM on KVM hosts with kickstart file
virt-install can be used to provision kickstart while installing, this provides an answer file to all the settings required to install OS.
How We Set Up Our KVM Hypervisor: From Bare Metal to Production-Ready VM Host
Detailed walkthrough of building a dedicated KVM/libvirt hypervisor with XFS tuning, hugepages, 10GbE tuning, and automation.
Building a Predictable KVM Infrastructure: From Chaos to Control
How to engineer a predictable KVM-based infrastructure focusing on repeatability, observability, and operational safety.