diff --git a/setup/xvm/_common.sh b/setup/xvm/_common.sh new file mode 100644 index 000000000..6dae07fe3 --- /dev/null +++ b/setup/xvm/_common.sh @@ -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 \ No newline at end of file diff --git a/setup/xvm/build_vm_stage1.sh b/setup/xvm/build_vm_stage1.sh index cd682365a..eb49d8814 100644 --- a/setup/xvm/build_vm_stage1.sh +++ b/setup/xvm/build_vm_stage1.sh @@ -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." @@ -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" @@ -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" diff --git a/setup/xvm/create_oemdrv.sh b/setup/xvm/create_oemdrv.sh index 51183a1fe..af77b4a8b 100644 --- a/setup/xvm/create_oemdrv.sh +++ b/setup/xvm/create_oemdrv.sh @@ -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 diff --git a/setup/xvm/download_rocky_iso.sh b/setup/xvm/download_rocky_iso.sh index dcc852053..2fe98e11e 100644 --- a/setup/xvm/download_rocky_iso.sh +++ b/setup/xvm/download_rocky_iso.sh @@ -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 \ No newline at end of file + echo "Rocky Linux ${rockyArch} minimal ISO already downloaded." +fi diff --git a/setup/xvm/kickstart/ks.cfg b/setup/xvm/kickstart/ks.cfg.template similarity index 87% rename from setup/xvm/kickstart/ks.cfg rename to setup/xvm/kickstart/ks.cfg.template index 66ab249c1..74ec27b90 100644 --- a/setup/xvm/kickstart/ks.cfg +++ b/setup/xvm/kickstart/ks.cfg.template @@ -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 @@ -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 @@ -95,7 +95,7 @@ dnf config-manager --set-enabled crb %end %packages -@^Minimal Install +@^minimal-environment @kde-desktop firefox vim