Kickstart install Centos 7 using virt-install


sudo qemu-img create -f qcow2 /var/lib/libvirt/images/centos7.qcow2 15G

sudo iptables -t nat -A POSTROUTING -j MASQUERADE
or
firewall-cmd --zone=external --add-masquerade --permanent
firewall-cmd --reload

This helps avoid errors like: dracut-initqueue[688]: Warning: unknown network kickstart URL: ...

mkdir kick && mkdir kick

vim centos7.cfg

#version=RHEL7
install

auth --enableshadow --passalgo=sha512
repo --name="EPEL" --baseurl=http://dl.fedoraproject.org/pub/epel/7/x86_64
eula --agreed
reboot
url --url="http://mirror.litnet.lt/centos/7/os/x86_64/"
firstboot --enable
ignoredisk --only-use=vda
keyboard --vckeymap=en --xlayouts='en'
lang en_US.UTF-8

network --bootproto=dhcp --device=enp0s3 --noipv6 --activate
network --hostname=centos7.test.local
rootpw mypassword
services --enabled=NetworkManager,sshd,chronyd
timezone Europe/Vilnius --isUtc --ntpservers=0.centos.pool.ntp.org,1.centos.pool.ntp.org,2.centos.pool.ntp.org,3.centos.pool.ntp.org
user --groups=wheel --homedir=/home/monit --name=monit --password=password --iscrypted --gecos="monit"
bootloader --location=mbr --boot-drive=vda
autopart --type=lvm
zerombr
clearpart --all --drives=vda
selinux --permissive

%packages
@base
@core
chrony
yum-cron
%end

python -m SimpleHTTPServer 1111
Serving HTTP on 0.0.0.0 port 1111 ...
or
python3 -m http.server 1111
Serving HTTP on 0.0.0.0 port 1111 (http://0.0.0.0:1111/) ...

sudo virt-install --connect=qemu:///system --network=bridge:virbr0 --extra-args="ks=http://192.168.0.101:1111/centos7.cfg console=tty0 console=ttyS0,115200" --name=centos7 --disk /var/lib/libvirt/images/centos7.qcow2,size=15,device=disk,bus=virtio,format=qcow2 --ram 1500 --vcpus=1 --check-cpu --accelerate --hvm --location=http://mirror.litnet.lt/centos/7/os/x86_64/ --nographics

CentOS Linux 7 (Core)
Kernel 3.10.0-862.el7.x86_64 on an x86_64

centos7 login:

2 thoughts on “Kickstart install Centos 7 using virt-install

  1. Sergey

    Hello. I’m trying to make it as in the example, but it doesn’t work. KS file doesn’t download from my local machine. Do you know why?
    I’m using Fedora 30 as the hypervisor.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *