This is an overview of setting up a KVM virtualization environment and creating virtual machines using automated installation with Kickstart. Additionally, it covers creating virtual machines via the internet or from local ISO files.
First, install the necessary packages for KVM operation (qemu-kvm
, libvirt
, virt-install
) and enable and start the libvirtd
service.
dnf -y install qemu-kvm libvirt virt-install
systemctl enable --now libvirtd
You can stop or delete virtual machines using the following commands.
virsh shutdown guest1-rhx
virsh destroy guest1-rhx
virsh undefine guest1-rhx --remove-all-storage
Kickstart
The Kickstart file saved at /tmp/ks.cfg
predefines settings such as keyboard layout, language, network, partitioning, timezone, and root password.
The virtual disk is specified as vda
to match the characteristics of the KVM environment.
cat << 'KICKSTART' > /tmp/ks.cfg
text
reboot
cdrom
keyboard --vckeymap=jp106 --xlayouts='jp','us'
# keyboard --vckeymap=us --xlayouts='us','jp'
lang en_US.UTF-8
network --bootproto=dhcp --ipv6=auto --activate --hostname=localhost
zerombr
%packages
@core
%end
ignoredisk --only-use=vda
autopart
clearpart --all --initlabel
timezone Asia/Tokyo --utc
rootpw --iscrypted --allow-ssh $6$EkGHWaJKwbybILqx$DwIwbw5NOGm2LpNlaCIRCeckcOlHACxMMfsyYijZ0uEKmGTHmDSqQhs4ndUGpme5uZl7zg/aJyam8j9N6wWRG.
KICKSTART
From the Internet
The AlmaLinux installation image is retrieved from a repository specified by a URL, and the installation is automated using Kickstart.
virt-install \
--name guest1-rhx \
--memory 4096 \
--vcpus 4 \
--network default \
--disk size=20 \
--location http://ftp.riken.jp/Linux/almalinux/10.0/BaseOS/x86_64/os/ \
--os-variant rhel9.4 \
--graphics none \
--accelerate \
--initrd-inject /tmp/ks.cfg \
--extra-args "console=tty0 console=ttyS0,115200n8 inst.ks=file:/ks.cfg"
From a Local File
This method creates a virtual machine by specifying a local ISO file that has been downloaded in advance.
isouri='https://repo.almalinux.org/almalinux/10/isos/x86_64/AlmaLinux-10.0-x86_64-minimal.iso'
curl -O "${isouri}"
isofile=$(basename ${isouri})
virt-install \
--name guest1-rhx \
--memory 4096 \
--vcpus 4 \
--network default \
--disk size=20 \
--location "${isofile}" \
--os-variant rhel9.4 \
--graphics none \
--accelerate \
--initrd-inject /tmp/ks.cfg \
--extra-args "console=tty0 console=ttyS0,115200n8 inst.ks=file:/ks.cfg"
Vagrant
As of May 31, 2025, there is no official Vagrant repository for AlmaLinux 10, so it is currently not possible to easily set up an environment using Vagrant.