bin/darkdepths/make-vm
#!/bin/bash if [[ $1 == "" || $1 == "--help" || $1 == "-h" ]]; then echo "Usage: make-vm [vm-name] [options]" echo "some options:" echo " mem=<number-in-megabytes>" echo " cpu=<cores>" echo " disk=<gbytes>" echo " env=<public|private>" exit 1 fi name="$1" env="private" disk="8" # in gb mem="512" # in mb cpu="1" # in cores if [[ -e /vm/$name.xml || -e /dev/vg0/$name.disk ]]; then echo 'vm/disk already exists' exit 1 fi echo "Carving $disk GB lv in /dev/vg0/$name.disk" lvcreate -n "$name.disk" --size 8G vg0 echo "createing writing /vm/$name.xml" touch "/vm/$name.xml" virt-install -n $name -r 8192 \ $name $cpus $type $variant $disk $location $graphics $bus $network qemu-system-x86_64 -hda /vm/vdisk.img -m 1024 -enable-kvm -netdev user,id=user.0 -device e1000,netdev=user.0 -soundhw ac97 -no-acpi -daemonize -usb -usbdevice tablet