Ring 0 · Core

Try Fedora 45

Cover Image for Try Fedora 45
Tomas
Tomas

The first article on this site installed Fedora 32 on a virtual machine without a single prompt. This is the same idea on Fedora 45: a kickstart file describes the install, one virt-install command runs it, and the machine comes up ready to log in. A few things have changed since 2020, mostly for the better, and they're noted along the way.

This VM, f45-min, is also where the rest of the series starts: it becomes the hypervisor that the whole lab runs inside. So it's worth getting right.

What you need

A Linux machine with KVM, and libvirt, QEMU, virt-install and passt installed. On Fedora, the virtualization group has all of them:

$ sudo dnf install @virtualization

On other distributions the package names differ, but the tools are the same.

Everything below runs as a normal user, against your own libvirt session (qemu:///session). No root, no system-wide network setup.

The kickstart file

A kickstart file answers every question the installer would otherwise ask. This one installs a minimal Fedora 45:

#version=DEVEL

# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'

# Use text mode install
text

# System language
lang en_US.UTF-8

# System timezone
timezone UTC --utc

# Network information
network  --hostname=fedora-min --bootproto=dhcp --device=link --activate

# Firewall configuration
firewall --enabled --service=ssh

# Do not configure the X Window System
skipx

# System services
services --enabled=sshd,chronyd

# Disable root account
rootpw --lock

# Regular user, password locked, ssh key login only
user --name=fedora --groups=wheel --lock
sshkey --username=fedora "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPEBEPdH4p6zFVxm/Sajh3i3VDlYiMXQ4ePYFyg2HgHq fedora@try-fedora"

# Only use vda disk
ignoredisk --only-use=vda

# Partition clearing information
clearpart --all --initlabel --drives=vda

# System bootloader configuration
bootloader --location=mbr --boot-drive=vda --append="net.ifnames=0 biosdevname=0"

# Auto partition table
autopart --type=plain

# Use net install
url --url="https://download.fedoraproject.org/pub/fedora/linux/releases/45/Everything/x86_64/os/"

# Enable repos
repo --name=updates --baseurl="https://download.fedoraproject.org/pub/fedora/linux/updates/45/Everything/x86_64/"

# Packages
%packages
@^custom-environment
xfsprogs
%end

# Passwordless sudo for the key-only user
%post
echo "fedora ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/fedora
chmod 0440 /etc/sudoers.d/fedora
%end

# Power off after installation
poweroff

What changed since the 2020 version:

The root account is locked. Instead there's a user called fedora, with a locked password and an SSH key, so the only way in is with that key. The key in the file above is a demo key, published on purpose so the recordings below work. Make your own with ssh-keygen -t ed25519 -f id_ed25519 and put the contents of id_ed25519.pub on the sshkey line instead.

The fedora user can use sudo without a password. That's set in the %post section, which runs inside the new system at the end of the install.

xfsprogs is in the package list. The minimal environment doesn't include the XFS tools, and the next posts format f45-min's VM storage as XFS.

The install ends with poweroff rather than halt. halt leaves the installer waiting at "Press ENTER to quit", which isn't what you want from an unattended install.

The timezone line uses --utc. The old --isUtc option is deprecated.

The disk

f45-min's disk is a raw image, created before the install with its space reserved up front:

$ qemu-img create -f raw -o preallocation=falloc f45-min.vda.raw 7G

A raw image is the disk byte for byte, with no format layer between the VM and the file. preallocation=falloc asks the filesystem for all 7 GB now, so no write inside the VM ever waits for the host to find space. Keep it on a filesystem that suits VM images: VM storage for etcd measures why that should be XFS, and why this matters once Kubernetes runs inside.

Running the install

virt-install creates the VM, fetches the installer from the Fedora mirror network, hands it the kickstart file and boots it:

$ virt-install \
--name f45-min \
--memory 14336 \
--vcpus 12 \
--cpu host-passthrough \
--os-variant fedora-unknown \
--graphics none \
--noreboot \
--network passt,portForward=2222:22 \
--disk=./f45-min.vda.raw,bus=virtio,format=raw,cache=none,io=native \
--location \
https://download.fedoraproject.org/pub/fedora/linux/releases/45/Everything/x86_64/os/ \
--initrd-inject ./ks-min.cfg \
--extra-args="inst.ks=file:/ks-min.cfg console=ttyS0 net.ifnames=0 biosdevname=0"

What the options do:

--memory 14336 --vcpus 12: what f45-min needs later in the series, when it runs two lab machines and a five-node cluster. The install itself needs 3 GB: the installer unpacks its own image into memory, about 860 MB of it.

--cpu host-passthrough: f45-min sees the host's real CPU, including its virtualization extensions, so it can run VMs of its own.

--os-variant fedora-unknown: virt-install picks good defaults per operating system, and fedora-unknown is the newest Fedora it knows. The old --os-type option is gone.

--noreboot: when the kickstart powers the machine off, virt-install simply returns, instead of booting straight into the new system.

--network passt,portForward=2222:22: passt gives the VM networking without root, and forwards port 2222 on your machine to the VM's SSH port. That's how you'll log in.

cache=none,io=native on the disk: the VM's writes go straight to the image, bypassing the host's page cache, and a flush inside the VM is exactly one flush on the host. The storage post shows what that's worth.

The install runs by itself. The kernel and installer image download first, then the installer starts, reads the kickstart file and gets on with it:

First boot

Start the VM with its console attached, to watch it boot:

$ virsh start f45-min --console

At the login prompt there's nothing to type: the password is locked. Leave the console with Ctrl+], and log in over SSH with the key instead:

$ ssh -i id_ed25519 -p 2222 fedora@localhost

Fedora 45 comes up on a 7.2 kernel. The 7 GB raw disk holds a 2 GB /boot and a 4.9 GB ext4 root with 2.9 GB free. There's no swap partition: Fedora swaps to compressed memory (zram) instead. NetworkManager has eth0 up through passt, and sudo dnf update -y brings in what has changed since the release: 99 packages in this recording, the newer kernel among them. The -y answers both of its questions, the transaction and, on a first update, importing Fedora's signing key.

When you're done, sudo poweroff shuts it down, and virsh start f45-min brings it back.

Further reading

Getting started with virtualization is a good libvirt and KVM reference, and the Fedora documentation covers everyday tasks on Fedora systems.

Next, VM storage for etcd: where f45-min's disks should live, and how they should be attached, before it becomes a hypervisor of its own.

back