#!/bin/bash # Some notes: # # Prior to running this script it is recommended to update the osinfo-db: # git clone https://gitlab.com/libosinfo/osinfo-db.git # apt install gettext osinfo-db-tools libosinfo-bin # cd osinfo-db # make && make install # osinfo-query os # # Some ISO images are not in the osinfo-db and therefore require initrd= and kernel= arguments provided to --location, for example: # --location $isoImage,initrd=install.amd/initrd.gz,kernel=install.amd/vmlinuz # # To find them in the ISO image use: # isoinfo -J -i -l | grep -e '(initrd|vmlinuz)' # and: # isoinfo -J -i -l | less # to find what directory they are in. `isoinfo` is provided by the `genisoimage` package. # # The --boot line below selects UEFI non-secure-boot and requires `ovmf` to be installed # # The --extra-args allows console access to the installation # # This script assumes you have a bridge named 'br0'. Otherwise you might want to use: # --network network:default machineName="deb12-gencld" diskImage="/mnt/e-lin/Downloads/ISO/debian-12-genericcloud-amd64.qcow2" machineMemory=2 # in GB cpuNumber=2 # run `osinfo-query os` to get the name of the OS variant osVariant="debian12" virt-install \ --connect qemu:///system \ --virt-type kvm \ --name "$machineName" \ --hvm \ --memory $(( $machineMemory * 1024 )) \ --boot loader=/usr/share/OVMF/OVMF_CODE.fd,loader.readonly=yes,loader.type=pflash,nvram.template=/usr/share/OVMF/OVMF_VARS.fd,loader_secure=no \ --disk ${diskImage},bus=virtio,format=qcow2 \ --import \ --vcpus $cpuNumber \ --cpu host \ --os-variant "$osVariant" \ --network bridge=br1 \ --graphics none \ --console pty,target_type=serial \ #--extra-args 'console=ttyS0,115200n8 --- console=ttyS0,115200n8'