Skip to content

Instantly share code, notes, and snippets.

@philroche
Forked from rcj4747/mk-userdata-nocloud.sh
Created October 13, 2017 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philroche/00f9de887a873b6c0bce3bde64e242ce to your computer and use it in GitHub Desktop.
Save philroche/00f9de887a873b6c0bce3bde64e242ce to your computer and use it in GitHub Desktop.
#!/bin/bash
cat <<EOF > meta-data
instance-id: iid-local01
local-hostname: cloudimg
EOF
cat <<EOF > user-data
#cloud-config
ssh_import_id: [ yourlaunchpadid ]
system_info:
default_user:
lock_passwd: false
plain_text_passwd: passw0rd
ssh_pwauth: true
users:
- default
EOF
genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data
rm user-data meta-data
echo "
Create a disk backed by the image:
qemu-img create -f qcow2 -b <orig-disk>.img boot-disk.img
Launch the instance with:
kvm -m 256 -net nic -net user,hostfwd=tcp::2222-:22 \
-drive file=boot-disk.img,if=virtio \
-drive file=seed.iso,if=virtio,media=cdrom"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment