## This uses qemu and a maas image to easily test bcache of a root disk
## on a vm. Originally put together for bug 1515780
## It does:
## * downloads a maas image, kernel and initramfs
## * and makes a disk with 1M in front for the bcache header (root.img)
## * creates a disk for cache image (cache0.img)
## * puts a bcache header on the root.img pointing to cache disk by cset uuid
## * boots system with uuid of root filesystem
##
## once booted you can login with 'ubuntu:passw0rd' (from the user-data above)
## suspend with:
## sudo systemctl suspend
## unsuspend with:
## 'system_wakeup'
## to issue system_wakeup you need to get to qemu monitor.
## in nographic mode you you toggle between console and qemu monitor with
## the provided 'escape char' (-echr) and 'c'
## This uses qemu and a maas image to easily test bcache of a root disk
## on a vm. Originally put together for bug 1515780
## It does:
## * downloads a maas image, kernel and initramfs
## * and makes a disk with 1M in front for the bcache header (root.img)
## * creates a disk for cache image (cache0.img)
## * puts a bcache header on the root.img pointing to cache disk by cset uuid
## * boots system with uuid of root filesystem
##
## once booted you can login with 'ubuntu:passw0rd' (from the user-data above)
## suspend with:
## sudo systemctl suspend
## unsuspend with:
## 'system_wakeup'
## to issue system_wakeup you need to get to qemu monitor.
## in nographic mode you you toggle between console and qemu monitor with
## the provided 'escape char' (-echr) and 'c'
$ wget http:// images. maas.io/ ephemeral- v2/daily/ xenial/ amd64/20160509/ root-image. gz images. maas.io/ ephemeral- v2/daily/ xenial/ amd64/20160509/ xenial/ generic/ boot-initrd images. maas.io/ ephemeral- v2/daily/ xenial/ amd64/20160509/ xenial/ generic/ boot-kernel
$ wget http://
$ wget http://
$ sudo apt-get install bcache-tools
## set up the cache disk 9065-40e1- 93cc-d020861e20 70 4d73-40d6- 9a09-c9192bf6ae d2 $(bcache- super-show cache0.img | awk '$1 == "cset.uuid" { print $2 }') 4d73-40d6- 9a09-c9192bf6ae d2
$ truncate --size 500M cache0.img
$ make-bcache --cache --writeback cache0.img
UUID: 48320c10-
Set UUID: 1d997f00-
version: 0
nbuckets: 1000
block_size: 8
bucket_size: 1024
nr_in_set: 1
nr_this_dev: 0
first_bucket: 1
$ cset_uuid=
$ echo $cset_uuid
1d997f00-
## setup primary disk
$ truncate --size=1M root.img
$ zcat root-image.gz >> root.img
# 2048 is 1M / 512B sectors uuid=${ cset_uuid} " root.img
$ make-bcache --bdev --data-offset=2048 "--cset-
# 1M here is same as our truncate. get the UUID of the filesystem.
$ uuid=$(blkid -p -o export -O 1M root.img | awk -F= '$1 == "UUID" { print $2 }')
## set up a seed disk
$ cat > user-data <<EOF
#cloud-config
password: passw0rd
chpasswd: { expire: False}
EOF
$ cloud-localds -v seed.img user-data
## boot it net-pci, netdev= net00 -netdev type=user,id=net00 \ file=root. img,format= raw \ file=cache0. img,format= raw \ file=seed. img,format= raw \
$ qemu-system-x86_64 -enable-kvm \
-device virtio-
-drive if=virtio,
-drive if=virtio,
-drive if=virtio,
-nographic \
-kernel boot-kernel -initrd boot-initrd \
-append "root=UUID=${uuid} console=ttyS0" -m 1024 -echr 0x05 -snapshot