Last active
December 6, 2017 13:49
-
-
Save ryands/929665f5d66f70468eb4 to your computer and use it in GitHub Desktop.
Debian KVM virt-install script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
INSTALL_MEDIA="http://cdimage.debian.org/cdimage/jessie_di_beta_2/amd64/iso-cd/debian-jessie-DI-b2-amd64-netinst.iso" | |
VMNAME="debian-jessie-vm" | |
[[ "x$1" != "x" ]] && VMNAME=$1 | |
echo | |
echo "Building VM: $VMNAME" | |
echo " Creating disk image" | |
rm ${VMNAME}.img | |
qemu-img create -f qcow2 ${VMNAME}.img 40G | |
if ! [[ -e installer.iso ]]; then | |
echo Fetching install media... | |
wget $INSTALL_MEDIA -O installer.iso | |
fi | |
echo " Starting virt-install" | |
virt-install \ | |
--connect qemu:///system \ | |
--hvm \ | |
--name $VMNAME \ | |
--ram 4096 \ | |
--noautoconsole \ | |
--vcpus=2 \ | |
--graphics vnc,listen=0.0.0.0 \ | |
--network bridge=br0,model=virtio \ | |
--disk ${VMNAME}.img,format=qcow2,bus=virtio \ | |
--cdrom installer.iso | |
echo virt-install started vnc on display $(virsh --connect qemu:///system vncdisplay $VMNAME) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment