#! /bin/bash -x # # This script helps creating a new LibVirt domain starting from a base image # # Run as root user # # TODO: fill in the variables below with proper values # ---------------------------------------------------- BASE_IMAGE= domain_name= cpus= disk_size= memory= mac= # ---------------------------------------------------- test -f /var/lib/libvirt/images/${domain_name}.qcow2 || cp -i ${BASE_IMAGE} /var/lib/libvirt/images/${domain_name}.qcow2 qemu-img resize /var/lib/libvirt/images/${domain_name}.qcow2 +${disk_size}G virt-install \ --name ${domain_name} \ --vcpus ${cpus} \ --memory ${memory} \ --network bridge=virbr0,mac=${mac}\ --graphics none\ --virt-type kvm\ --disk /var/lib/libvirt/images/${domain_name}.qcow2,size=${disk_size}\ --boot hd \ --osinfo detect=on,require=off --import