Skip to content

Instantly share code, notes, and snippets.

@klyr
Created March 10, 2017 09:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save klyr/75c9bf45e6d4cb613fd6a4d08d27f0e2 to your computer and use it in GitHub Desktop.
Save klyr/75c9bf45e6d4cb613fd6a4d08d27f0e2 to your computer and use it in GitHub Desktop.
Boot a qcow cloud-init image with kvm
img_url="http://cloud-images.ubuntu.com/releases/xenial/release"
img_url="${img_url}/ubuntu-16.04-server-cloudimg-amd64-disk1.img"
wget $img_url -O disk.img.dist
cat > my-user-data <<EOF
#cloud-config
password: changeme
chpasswd: { expire: False }
ssh_pwauth: True
EOF
## Convert the compressed qcow file downloaded to a uncompressed qcow2
qemu-img convert -O qcow2 disk.img.dist disk.img.orig
## create the disk with NoCloud data on it.
cloud-localds my-seed.img my-user-data
## Create a delta disk to keep our .orig file pristine
qemu-img create -f qcow2 -b disk.img.orig disk.img 20G
virt-install --import -n xenial --memory 4096 --os-type linux --vcpus 4 --disk path=/tmp/disk.img --disk path=/tmp/my-seed.img --network default --graphics none --console pty,target_type=serial --debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment