Comment 8 for bug 1684869

Revision history for this message
Scott Moser (smoser) wrote :

for xenial you need to download the '-uefi1.img' in order to get
a disk that is partitioned with a GPT table.

Given a small modification to get-proposed-cloudimg:

--- get-proposed-cloudimg.dist 2017-05-16 13:56:05.000000000 +0000
+++ get-proposed-cloudimg 2017-05-16 13:52:49.192688492 +0000
@@ -6,7 +6,8 @@
 fname=$rel-server-cloudimg-amd64.img
 ofname="$fname"
 case "$rel" in
- precise|trusty|xenial) ofname="$rel-server-cloudimg-amd64-disk1.img"
+ precise|trusty) ofname="$rel-server-cloudimg-amd64-disk1.img";;
+ xenial) ofname="$rel-server-cloudimg-amd64-uefi1.img"
 esac
 pfname="${fname%.img}-proposed.img"
 raw="${fname%.img}.raw"

Then, I just followed along with the script.

$ ls -l xenial-server-*
-rw-rw-r-- 1 smoser smoser 334823424 May 15 15:32 xenial-server-cloudimg-amd64.img
-rw-r--r-- 1 smoser smoser 102825984 May 16 13:53 xenial-server-cloudimg-amd64-proposed.img
-rw-r--r-- 1 smoser smoser 2361393152 May 16 13:53 xenial-server-cloudimg-amd64.raw

$ raw=xenial-server-cloudimg-amd64.raw
$ sfdisk --part-uuid $raw 1
7D8DBC14-97B9-4F0F-ADD0-F1E22F1DE4AD
$ ptuuid=$(sfdisk --part-uuid $raw 1)
$ ptuuid=$(echo "$ptuuid" | tr '[a-z]' '[A-Z]')
$ echo $ptuuid
7D8DBC14-97B9-4F0F-ADD0-F1E22F1DE4AD

$ printf "%s\n%s\n%s\n%s\n" "#cloud-config" "password: passw0rd" \
   "chpasswd: {expire: False}" "ssh_pwauth: True" > my-user-data
$ echo "instance-id: $(uuidgen || echo i-abcdefg)" > my-meta-data

$ sudo mount-image-callback $raw -- mchroot sh -xc 'cat /boot/vmlinu?-*' > kernel
+ cat /boot/vmlinuz-4.4.0-77-generic

$ qemu-img create -f qcow2 -b xenial-server-cloudimg-amd64-proposed.img disk.img 10G
Formatting 'disk.img', fmt=qcow2 size=10737418240 backing_file=xenial-server-cloudimg-amd64-proposed.img encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16

$ qemu-system-x86_64 -enable-kvm \
   -drive file=disk.img,if=ide,index=0 -drive file=my-seed.img,if=ide \
   -net nic -net user,hostfwd=tcp::2222-:22 \
   -snapshot -m 768 -nographic -echr 0x05 -snapshot \
   -kernel kernel \
   -append "root=PARTUUID=${ptuuid} ro console=tty1 console=ttyS0"

... <see attachment> ...

ubuntu@ubuntu:~$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/root 9.6G 963M 8.6G 10% /
ubuntu@ubuntu:~$ dpkg-query --show cloud-init
cloud-init 0.7.9-113-g513e99e0-0ubuntu1~16.04.1
ubuntu@ubuntu:~$ lsb_release -sc
xenial
ubuntu@ubuntu:~$ uname -r
4.4.0-77-generic
ubuntu@ubuntu:~$ cat /proc/cmdline
root=PARTUUID=7D8DBC14-97B9-4F0F-ADD0-F1E22F1DE4AD ro console=tty1 console=ttyS0