Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions doc/rtd/topics/datasources/nocloud.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,35 +61,42 @@ You may also optionally provide a vendor-data file in the following format.

/vendor-data

Given a disk ubuntu 12.04 cloud image in 'disk.img', you can create a
Given a disk ubuntu cloud image in 'disk.img', you can create a
sufficient disk by following the example below.

::

## create user-data and meta-data files that will be used
## 1) create user-data and meta-data files that will be used
## to modify image on first boot
$ { echo instance-id: iid-local01; echo local-hostname: cloudimg; } > meta-data
$ echo "instance-id: iid-local01\nlocal-hostname: cloudimg" > meta-data
$ echo "#cloud-config\npassword: passw0rd\nchpasswd: { expire: False }\nssh_pwauth: True\n" > user-data

$ printf "#cloud-config\npassword: passw0rd\nchpasswd: { expire: False }\nssh_pwauth: True\n" > user-data

## create a disk to attach with some user-data and meta-data
## 2a) create a disk to attach with some user-data and meta-data
$ genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data

## alternatively, create a vfat filesystem with same files
## $ truncate --size 2M seed.img
## $ mkfs.vfat -n cidata seed.img
## $ mcopy -oi seed.img user-data meta-data ::
## 2b) alternatively, create a vfat filesystem with same files
## $ truncate --size 2M seed.iso
## $ mkfs.vfat -n cidata seed.iso

## 2b) option 1: mount and copy files
## $ sudo mount -t vfat seed.iso /mnt
## $ sudo cp user-data meta-data /mnt
## $ sudo umount /mnt

## 2b) option 2: the mtools package provides mcopy, which can access vfat
## filesystems without mounting them
## $ mcopy -oi seed.iso user-data meta-data

## create a new qcow image to boot, backed by your original image
$ qemu-img create -f qcow2 -b disk.img boot-disk.img
## 3) create a new qcow image to boot, backed by your original image
$ qemu-img create -f qcow2 -b disk.img -F qcow2 boot-disk.img

## boot the image and login as 'ubuntu' with password 'passw0rd'
## 4) boot the image and login as 'ubuntu' with password 'passw0rd'
## note, passw0rd was set as password through the user-data above,
## there is no password set on these images.
$ kvm -m 256 \
-net nic -net user,hostfwd=tcp::2222-:22 \
-drive file=boot-disk.img,if=virtio \
-drive file=seed.iso,if=virtio
-drive driver=raw,file=seed.iso,if=virtio
Comment thread
holmanb marked this conversation as resolved.

**Note:** that the instance-id provided (``iid-local01`` above) is what is used
to determine if this is "first boot". So if you are making updates to
Expand Down