From bd3c8e934e438631dc48cad87dd3aaa5062cbe89 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 24 Jan 2022 15:38:44 +0100 Subject: [PATCH] add new post-install scripts --- .../create-generic-vm-virtio-spice.sh | 38 +++++++++++++++++++ .../create-system-vms.sh | 16 ++++---- post-first-startup-scripts/create-user-vms.sh | 6 ++- ...y-minimal-server_1vCPU_2GB-RAM_5GB-disk.sh | 35 +++++++++++++++++ ...mal-workstation_2vCPU_4GB-RAM_10GB-disk.sh | 35 +++++++++++++++++ ...hyllome-desktop_4vCPU_8GB-RAM_20GB-disk.sh | 35 +++++++++++++++++ .../virtualization-tweaks-root-needed.sh | 2 +- 7 files changed, 155 insertions(+), 12 deletions(-) create mode 100644 post-first-startup-scripts/create-generic-vm-virtio-spice.sh create mode 100644 post-first-startup-scripts/deploy-minimal-server_1vCPU_2GB-RAM_5GB-disk.sh create mode 100644 post-first-startup-scripts/deploy-minimal-workstation_2vCPU_4GB-RAM_10GB-disk.sh create mode 100644 post-first-startup-scripts/deploy-phyllome-desktop_4vCPU_8GB-RAM_20GB-disk.sh diff --git a/post-first-startup-scripts/create-generic-vm-virtio-spice.sh b/post-first-startup-scripts/create-generic-vm-virtio-spice.sh new file mode 100644 index 0000000..b8e7824 --- /dev/null +++ b/post-first-startup-scripts/create-generic-vm-virtio-spice.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# This script has be run as root. + +# Create and run a diskless virtual machine with `virt-install`. Spice and OpenGL are enabled. +# GPU agnostic configuration. Does expect an EFI-based Linux guest. +# The netboot.xyz ISO is attached to this virtual machine, allowing the user to pick an operating system to be installed. + +virt-install \ + --connect qemu:///system \ + --metadata description="Spice with OpenGL. Requires an EFI-based guest, ideally with support for virtio-gpu, such as Fedora Workstation." \ + --os-variant detect=off \ + --virt-type kvm \ + --arch x86_64 \ + --machine q35 \ + --name generic \ + --boot uefi \ + --cpu host-model,topology.sockets=1,topology.cores=1,topology.threads=1 \ + --vcpus 1 \ + --memory 2048 \ + --video virtio \ + --graphics spice,gl.enable=yes,listen=none \ + --channel spicevmc \ + --channel unix,target.type=virtio,target.name=org.qemu.guest_agent.0 \ + --autoconsole none \ + --console pty,target.type=virtio \ + --sound none \ + --network type=default,model=virtio \ + --controller type=virtio-serial \ + --controller type=usb,model=none \ + --controller type=scsi,model=virtio-scsi \ + --input type=keyboard,bus=virtio \ + --input type=tablet,bus=virtio \ + --cdrom /var/lib/libvirt/iso/netboot.xyz.iso \ + --memballoon none \ + --rng /dev/urandom,model=virtio \ + --disk none \ + --install no_install=yes \ No newline at end of file diff --git a/post-first-startup-scripts/create-system-vms.sh b/post-first-startup-scripts/create-system-vms.sh index 8453328..cc5ac0e 100644 --- a/post-first-startup-scripts/create-system-vms.sh +++ b/post-first-startup-scripts/create-system-vms.sh @@ -1,10 +1,11 @@ #!/bin/bash -# This script can be run as a root user. +# Attention please: will soon be deprecated in favor of a more generic VM model -# Create then shutdown a diskless virtual machine with qemu-system, without any emulated display, using virt-install. -# It is designed for vfio-pci (pci-passthrough) in mind, and will work any guest systems that has drivers for the passthroughed GPU as well as paravirtualized drivers (Windows, or Linux). -# The ISO that contains paravirtualized drivers for Windows is attached to this virtual machine. The user has to manually add the Windows ISO. +# This script has be run as root. + +# Create and run a diskless virtual machine with `virt-install`, without any display. +# For Windows, the user has to manually add the Windows ISO as well as the ISO that contains paravirtualized drivers for Windows. virt-install \ --connect qemu:///system \ @@ -13,7 +14,7 @@ virt-install \ --virt-type kvm \ --arch x86_64 \ --machine q35 \ - --name system-windows-vfio-pci \ + --name vfio-pci \ --boot uefi \ --cpu host-model,topology.sockets=1,topology.cores=1,topology.threads=1 \ --vcpus 1 \ @@ -31,8 +32,5 @@ virt-install \ --input type=keyboard,bus=virtio \ --input type=tablet,bus=virtio \ --rng /dev/urandom,model=virtio \ - --cdrom /usr/share/virtio-win/virtio-win-0.1.171.iso \ --disk none \ - --install no_install=yes - -virsh destroy system-windows-vfio-pci \ No newline at end of file + --install no_install=yes \ No newline at end of file diff --git a/post-first-startup-scripts/create-user-vms.sh b/post-first-startup-scripts/create-user-vms.sh index b4d08b2..3a9fa6c 100644 --- a/post-first-startup-scripts/create-user-vms.sh +++ b/post-first-startup-scripts/create-user-vms.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Attention please: will soon be deprecated in favor of a more generic VM model + # This script can be run as a normal user. # Make sure qemu-session is available as an URI in virt-manager running the following in your terminal: # gsettings set org.virt-manager.virt-manager.connections uris "['qemu:///system', 'qemu:///session']" @@ -113,9 +115,9 @@ virt-install \ virsh destroy user-linux-egl-headless-gl -# Create then shutdown a diskless virtual machine with qemu-sesssion, SDL and OpenGL enabled, using virt-install. +# Create and run a diskless virtual machine with `virt-install`. Spice and OpenGL are enabled. # Should work with all GPUs on the host including Nvidia's and does expect an EFI-based Linux guest. -# No ISO is attached to this virtual machine. The user have to manually add one. +# No ISO is attached to this virtual machine. The user has to manually add one. virt-install \ --connect qemu:///session \ diff --git a/post-first-startup-scripts/deploy-minimal-server_1vCPU_2GB-RAM_5GB-disk.sh b/post-first-startup-scripts/deploy-minimal-server_1vCPU_2GB-RAM_5GB-disk.sh new file mode 100644 index 0000000..bb1af71 --- /dev/null +++ b/post-first-startup-scripts/deploy-minimal-server_1vCPU_2GB-RAM_5GB-disk.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Deploy a virtual machine with `virt-install` and automatically install a minimal shell environment on a 5G disk. +# GPU and CPU agnostic configuration. + +virt-install \ + --connect qemu:///system \ + --metadata description="Spice with OpenGL. OS shipping with a minimal server environment. Based on Fedora Server 35" \ + --os-variant detect=off \ + --virt-type kvm \ + --arch x86_64 \ + --machine q35 \ + --name minimal-workstation \ + --boot uefi \ + --cpu host-model,topology.sockets=1,topology.cores=1,topology.threads=1 \ + --vcpus 1 \ + --memory 2048 \ + --video virtio \ + --graphics spice,gl.enable=yes,listen=none \ + --channel spicevmc \ + --channel unix,target.type=virtio,target.name=org.qemu.guest_agent.0 \ + --autoconsole none \ + --console pty,target.type=virtio \ + --sound none \ + --network type=default,model=virtio \ + --controller type=virtio-serial \ + --controller type=usb,model=none \ + --controller type=scsi,model=virtio-scsi \ + --input type=keyboard,bus=virtio \ + --input type=tablet,bus=virtio \ + --memballoon none \ + --rng /dev/urandom,model=virtio \ + --disk path=/var/lib/libvirt/images/virtual-desktop.img,format=raw,bus=virtio,cache=writeback,size=5 \ + --location=https://download.fedoraproject.org/pub/fedora/linux/releases/35/Everything/x86_64/os/ \ + --extra-args="inst.ks=https://raw.githubusercontent.com/PhyllomeOS/phyllomeos/main/dishes/virtual-server.cfg" \ No newline at end of file diff --git a/post-first-startup-scripts/deploy-minimal-workstation_2vCPU_4GB-RAM_10GB-disk.sh b/post-first-startup-scripts/deploy-minimal-workstation_2vCPU_4GB-RAM_10GB-disk.sh new file mode 100644 index 0000000..83c33b1 --- /dev/null +++ b/post-first-startup-scripts/deploy-minimal-workstation_2vCPU_4GB-RAM_10GB-disk.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Deploy a virtual machine with `virt-install` and automatically install a minimal GNOME Shell desktop environment on a 10G disk. +# GPU and CPU agnostic configuration. + +virt-install \ + --connect qemu:///system \ + --metadata description="Spice with OpenGL. OS shipping with a minimal GNOME Shell environment. Based on Fedora Server 35" \ + --os-variant detect=off \ + --virt-type kvm \ + --arch x86_64 \ + --machine q35 \ + --name minimal-workstation \ + --boot uefi \ + --cpu host-passthrough,topology.sockets=1,topology.cores=1,topology.threads=1 \ + --vcpus 1 \ + --memory 2048 \ + --video virtio \ + --graphics spice,gl.enable=yes,listen=none \ + --channel spicevmc \ + --channel unix,target.type=virtio,target.name=org.qemu.guest_agent.0 \ + --autoconsole none \ + --console pty,target.type=virtio \ + --sound none \ + --network type=default,model=virtio \ + --controller type=virtio-serial \ + --controller type=usb,model=none \ + --controller type=scsi,model=virtio-scsi \ + --input type=keyboard,bus=virtio \ + --input type=tablet,bus=virtio \ + --memballoon none \ + --rng /dev/urandom,model=virtio \ + --disk path=/var/lib/libvirt/images/virtual-desktop.img,format=raw,bus=virtio,cache=writeback,size=10 \ + --location=https://download.fedoraproject.org/pub/fedora/linux/releases/35/Everything/x86_64/os/ \ + --extra-args="inst.ks=https://raw.githubusercontent.com/PhyllomeOS/phyllomeos/main/dishes/virtual-desktop.cfg" \ No newline at end of file diff --git a/post-first-startup-scripts/deploy-phyllome-desktop_4vCPU_8GB-RAM_20GB-disk.sh b/post-first-startup-scripts/deploy-phyllome-desktop_4vCPU_8GB-RAM_20GB-disk.sh new file mode 100644 index 0000000..000969c --- /dev/null +++ b/post-first-startup-scripts/deploy-phyllome-desktop_4vCPU_8GB-RAM_20GB-disk.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Deploy Phyllome OS Desktop generic edition with `virt-install` on a 20G disk, with 4vCPU, 8G of RAM. +# GPU and CPU agnostic configuration. + +virt-install \ + --connect qemu:///system \ + --metadata description="Spice with OpenGL. Phyllome OS Desktop edition." \ + --os-variant detect=off \ + --virt-type kvm \ + --arch x86_64 \ + --machine q35 \ + --name virtual-phyllome-os \ + --boot uefi \ + --cpu host-model,topology.sockets=1,topology.cores=2,topology.threads=2 \ + --vcpus 1 \ + --memory 8192 \ + --video virtio \ + --graphics spice,gl.enable=yes,listen=none \ + --channel spicevmc \ + --channel unix,target.type=virtio,target.name=org.qemu.guest_agent.0 \ + --autoconsole none \ + --console pty,target.type=virtio \ + --sound none \ + --network type=default,model=virtio \ + --controller type=virtio-serial \ + --controller type=usb,model=none \ + --controller type=scsi,model=virtio-scsi \ + --input type=keyboard,bus=virtio \ + --input type=tablet,bus=virtio \ + --memballoon none \ + --rng /dev/urandom,model=virtio \ + --disk path=/var/lib/libvirt/images/virtual-desktop.img,format=raw,bus=virtio,cache=writeback,size=20 \ + --location=https://download.fedoraproject.org/pub/fedora/linux/releases/35/Everything/x86_64/os/ \ + --extra-args="inst.ks=https://raw.githubusercontent.com/PhyllomeOS/phyllomeos/main/dishes/virtual-phyllome-desktop.cfg" \ No newline at end of file diff --git a/post-first-startup-scripts/virtualization-tweaks-root-needed.sh b/post-first-startup-scripts/virtualization-tweaks-root-needed.sh index 8d72cbb..024a5e4 100644 --- a/post-first-startup-scripts/virtualization-tweaks-root-needed.sh +++ b/post-first-startup-scripts/virtualization-tweaks-root-needed.sh @@ -1,6 +1,6 @@ #!/bin/bash -# usermod -a -G libvirt $(whoami) # add current user to the libvirt group +# usermod -a -G libvirt kvm $(whoami) # add current user to the libvirt and kvm groups # virsh commands fail in a kickstart environment (chroot or not it seems). would need to fetch a script and execute post-launch with a delay, for example using a systemd unit virsh pool-define-as iso dir - - - - /var/lib/libvirt/iso/ # Make libvirt aware of this new directory by creating a so-called 'pool'.