Installing Virtual Machines over a Serial Line - Again!
Linux Installers and Serial Connections
This is an update of a previous post where I argued for the importance of being able to control virtual machines using serial lines as an out-of-band tool. I still think that this is an important thing to do and this post gathers some updated examples.
UEFI Boot and Mirrored Disks - almalinux
This example is a test-bed for a physical (non-VM) install I needed to do on
a system which uses UEFI and where we wanted RAID1 support. The virt-install
command specifies --boot uefi
and two --disk
elements. These appear as
vda
and vdb
and the associated kickstart file builds RAID1 filesystems on
top. We have small partitions for /boot
and /boot/efi
and the rest of the
space is given to LVM. We configure LVs for /
, swap
and /home
.
We will be installing almalinux but with trivial changes the same process should work for any RHEL8 clone.
$ sudo virt-install --boot uefi --name alma8u --ram 2048 \
--disk path=/var/lib/libvirt/images/alma81.qcow2,size=30,format=qcow2,bus=virtio \
--disk path=/var/lib/libvirt/images/alma82.qcow2,size=30,format=qcow2,bus=virtio \
--os-type linux --os-variant rhel8-unknown \
--network network=default \
--graphics=none \
--console pty,target_type=serial \
--location 'https://yum.tamu.edu/alma/8.3/BaseOS/x86_64/kickstart/'
--initrd-inject=/home/iana/alma8-2disk.ks \
--extra-args="console=ttyS0 inst.ks=file:/alma8-2disk.ks inst.text"
Here is the associated kickstart
text
url --url=https://repo.almalinux.org/almalinux/8/BaseOS/x86_64/kickstart/
repo --name="BaseOS" --mirrorlist=https://mirrors.almalinux.org/mirrorlist/8/baseos
repo --name="AppStream" --mirrorlist=https://mirrors.almalinux.org/mirrorlist/8/appstream
keyboard --vckeymap=us --xlayouts=''
lang en_US.UTF-8
# Disks and partitions - EFI Layout
ignoredisk --only-use=vda,vdb
# Partition clearing information
clearpart --none --initlabel
zerombr
## /boot
part raid.00 --fstype="mdmember" --ondisk=vda --size=1024
part raid.10 --fstype="mdmember" --ondisk=vdb --size=1024
## /boot/efi
part raid.01 --fstype="mdmember" --ondisk=vda --size=256
part raid.11 --fstype="mdmember" --ondisk=vdb --size=256
## /
part raid.02 --fstype="mdmember" --ondisk=vda --size=8192 --grow
part raid.12 --fstype="mdmember" --ondisk=vdb --size=8192 --grow
raid /boot --device=boot --fstype="xfs" --level=RAID1 raid.00 raid.10
raid /boot/efi --device=boot_efi --fstype="efi" --level=RAID1 --fsoptions="umask=0077,shortname=winnt" raid.01 raid.11
raid pv.01 --device=pv.01 --fstype="lvmpv" --level=RAID1 raid.02 raid.12
volgroup rhelvg pv.01
logvol / --fstype="xfs" --size=6144 --name=root --vgname=rhelvg
logvol swap --fstype="swap" --size=1024 --name=swap --vgname=rhelvg
logvol /home --fstype="xfs" --size=1 --name=home --vgname=rhelvg --grow
# Network information
network --bootproto=dhcp --device=ens2 --ipv6=auto --activate
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted ### GENERATE A PW WITH `openssl passwd -6 ###
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
skipx
# System services
services --enabled="chronyd"
# System timezone
timezone America/New_York --isUtc
user --groups=wheel --name=myuser --password=### GENERATE A PW WITH `openssl passwd -6 ### --iscrypted --gecos="ptty2u"
%packages
@^minimal-environment
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
reboot