Skip to content

Commit

Permalink
xvm: retooling for Rocky 9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-long committed May 18, 2024
1 parent 42f2c7c commit c3fc7ce
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 23 deletions.
10 changes: 10 additions & 0 deletions setup/xvm/_common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
rockyVersion=${rockyVersion:-9.4}
if [[ $(uname -p) == arm ]]; then
rockyArch=${rockyArch:-aarch64}
qemuArch=aarch64
else
rockyArch=${rockyArch:-x86_64}
qemuArch=x86_64
fi
export rockyVersion rockyArch qemuArch
21 changes: 14 additions & 7 deletions setup/xvm/build_vm_stage1.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
source ./_common.sh
set -x
if [[ -e ./output/xvm_stage1.qcow2 ]]; then
echo "Stage one image populated from cache. Skipping stage one."
Expand All @@ -15,7 +16,13 @@ fi
bash create_oemdrv.sh
bash download_rocky_iso.sh
bash download_firmware.sh
cp ./input/firmware/AAVMF_VARS.fd ./output/AAVMF_VARS.fd
if [[ $qemuArch == aarch64 ]]; then
cp ./input/firmware/AAVMF_VARS.fd ./output/firmware_vars.fd
cp ./input/firmware/AAVMF_CODE.fd ./output/firmware_code.fd
else
cp ./input/firmware/OVMF_VARS.fd ./output/firmware_vars.fd
cp ./input/firmware/OVMF_CODE.fd ./output/firmware_code.fd
fi
if [[ $(uname -p) == "arm" && $CI != "true" ]]; then
cpuType="host"
accelFlag=",highmem=on,accel=hvf:kvm"
Expand All @@ -24,23 +31,23 @@ else
accelFlag=""
fi
echo "Starting VM installation process..."
qemu-system-aarch64 \
qemu-system-${qemuArch} \
-name xvm \
-cdrom ./input/iso/Rocky-9.3-aarch64-minimal.iso \
-cdrom ./input/iso/Rocky-${rockyVersion}-${rockyArch}-minimal.iso \
-netdev user,id=user.0 \
-device virtio-keyboard-pci -device virtio-mouse-pci \
-smp 4 \
-machine type=virt$accelFlag \
-cpu $cpuType \
-drive if=pflash,format=raw,id=ovmf_code,readonly=on,file=./input/firmware/AAVMF_CODE.fd \
-drive if=pflash,format=raw,id=ovmf_vars,file=./output/AAVMF_VARS.fd \
-drive if=pflash,format=raw,id=ovmf_code,readonly=on,file=./output/firmware_code.fd \
-drive if=pflash,format=raw,id=ovmf_vars,file=./output/firmware_vars.fd \
-drive file=output/xvm.qcow2,format=qcow2 \
-drive file=input/oemdrv.qcow2,format=qcow2 \
-device virtio-gpu-pci \
-device virtio-net-pci,netdev=user.0 \
-boot c \
-m 8192M \
-display none \
|| exit 1
# -display none \
cp -v ./output/xvm.qcow2 ./output/xvm_stage1.qcow2
echo "Created VM and installed Rocky Linux 9.3 with KDE."
echo "Created VM and installed Rocky Linux"
7 changes: 4 additions & 3 deletions setup/xvm/create_oemdrv.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
mkdir -p input output
# copy kickstart files
cp -R ./kickstart ./input/
source ./_common.sh
mkdir -p input/kickstart output
# generate kickstart template
cat ./kickstart/ks.cfg.template | envsubst > ./input/kickstart/ks.cfg
cp ./output/xvm_key.pub ./input/kickstart/authorized_keys
rm -f ./input/oemdrv.{dmg,qcow2}
if [[ $(uname) == "Darwin" ]]; then
Expand Down
11 changes: 6 additions & 5 deletions setup/xvm/download_rocky_iso.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env bash
source ./_common.sh
mkdir -p ./input/iso
cd ./input/iso
if [[ ! -e Rocky-9.3-aarch64-minimal.iso ]]; then
curl -L https://download.rockylinux.org/pub/rocky/9/isos/aarch64/Rocky-9.3-aarch64-minimal.iso > Rocky-9.3-aarch64-minimal.iso.part
mv Rocky-9.3-aarch64-minimal.iso.part Rocky-9.3-aarch64-minimal.iso
if [[ ! -e Rocky-${rockyVersion}-${rockyArch}-minimal.iso ]]; then
curl -L https://download.rockylinux.org/pub/rocky/9/isos/${rockyArch}/Rocky-${rockyVersion}-${rockyArch}-minimal.iso > Rocky-${rockyVersion}-${rockyArch}-minimal.iso.part
mv Rocky-${rockyVersion}-${rockyArch}-minimal.iso.part Rocky-${rockyVersion}-${rockyArch}-minimal.iso
else
echo "Rocky Linux 9.3 aarch64 minimal ISO already downloaded."
fi
echo "Rocky Linux ${rockyArch} minimal ISO already downloaded."
fi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Inspired by https://github.com/canonical/packer-maas/blob/main/rocky9/http/rocky.ks.pkrtpl.hcl
repo --name=base --mirrorlist=https://mirrors.rockylinux.org/mirrorlist?repo=rocky-BaseOS-9.3&arch=aarch64
repo --name=appstream --mirrorlist=https://mirrors.rockylinux.org/mirrorlist?repo=rocky-AppStream-9.3&arch=aarch64
repo --name=crb --mirrorlist=https://mirrors.rockylinux.org/mirrorlist?repo=rocky-CRB-9.3&arch=aarch64
repo --name=epel --metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-9&arch=aarch64
repo --name=epel-cisco-openh264 --metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-cisco-openh264-9&arch=aarch64
repo --name=minimal --baseurl=file:///run/install/sources/mount-0000-cdrom/minimal
repo --name=base --mirrorlist=https://mirrors.rockylinux.org/mirrorlist?repo=rocky-BaseOS-${rockyVersion}&arch=${rockyArch}
repo --name=appstream --mirrorlist=https://mirrors.rockylinux.org/mirrorlist?repo=rocky-AppStream-${rockyVersion}&arch=${rockyArch}
repo --name=crb --mirrorlist=https://mirrors.rockylinux.org/mirrorlist?repo=rocky-CRB-${rockyVersion}&arch=${rockyArch}
repo --name=epel --metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-9&arch=${rockyArch}
repo --name=epel-cisco-openh264 --metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-cisco-openh264-9&arch=${rockyArch}

cdrom
graphical
Expand All @@ -16,14 +17,13 @@ firewall --enabled --service=ssh

# System language, keyboard and timezone
lang en_US.UTF-8
keyboard us
keyboard --xlayouts='us'
timezone UTC --utc

# Use CDROM installation media
cdrom

# Generated using Blivet version 3.6.0
# ignoredisk --only-use=vda
autopart
# Partition clearing information
clearpart --none --initlabel
Expand Down Expand Up @@ -95,7 +95,7 @@ dnf config-manager --set-enabled crb
%end

%packages
@^Minimal Install
@^minimal-environment
@kde-desktop
firefox
vim
Expand Down

0 comments on commit c3fc7ce

Please sign in to comment.