Skip to content

Instantly share code, notes, and snippets.

@cgwalters
Created November 22, 2014 22:06
Show Gist options
  • Save cgwalters/a366c14b2fc58e0f7367 to your computer and use it in GitHub Desktop.
Save cgwalters/a366c14b2fc58e0f7367 to your computer and use it in GitHub Desktop.
create-cloud-vm.sh
!/bin/sh
# Clone a copy-on-write "gold" cloud image, resize it to the target, and
# use virt-install to create a VM, attaching a cloud-init metadata ISO.
# Run in /var/lib/libvirt/images
img=$1
shift
name=$1
shift
size=$1
shift
set -e
set -x
disk=$(pwd)/$name.qcow2
qemu-img create -f qcow2 -o "backing_file=$img" "$disk" $size
exec virt-install --force --noautoconsole --name "$name" --ram 1024 --import --disk=${disk} --disk=$(pwd)/gold/insecure-vagrant-userdata.iso,device=cdrom "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment