Skip to content

Instantly share code, notes, and snippets.

@alexbartsch
Forked from srics/create-vm-from-iso.sh
Last active August 29, 2015 14:27
Show Gist options
  • Save alexbartsch/40d59b3be7534fc0dbd7 to your computer and use it in GitHub Desktop.
Save alexbartsch/40d59b3be7534fc0dbd7 to your computer and use it in GitHub Desktop.
Create KVM Virtual Machine using Ubuntu Trusty ISO image
#!/bin/bash -x
VM_NAME=_base_trusty64_openstack
VM_MEM=8192
VM_VCPUS=4
VM_DISK_ISO=/var/lib/libvirt/images/ubuntu-14.04.1-server-amd64.iso
VM_NETWORK="bridge=br-ext"
VM_PATH=/opt/vms/${VM_NAME}
VM_DISK=${VM_PATH}/${VM_NAME}_disk.qcow2
mkdir -p $VM_PATH
qemu-img create -f qcow2 ${VM_DISK} 32G
virt-install --virt-type=kvm --hvm --cpu host \
--name=$VM_NAME \
--ram=$VM_MEM --vcpus=$VM_VCPUS \
--cdrom=${VM_DISK_ISO} \
--disk path=$VM_DISK,format=qcow2 \
--network $VM_NETWORK \
--graphics vnc,listen=127.0.0.1 --noautoconsole \
--os-type=linux --os-variant=ubuntutrusty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment