## 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 $ wget http://images.maas.io/ephemeral-v2/daily/xenial/amd64/20160509/xenial/generic/boot-initrd $ wget http://images.maas.io/ephemeral-v2/daily/xenial/amd64/20160509/xenial/generic/boot-kernel $ sudo apt-get install bcache-tools ## set up the cache disk $ truncate --size 500M cache0.img $ make-bcache --cache --writeback cache0.img UUID: 48320c10-9065-40e1-93cc-d020861e2070 Set UUID: 1d997f00-4d73-40d6-9a09-c9192bf6aed2 version: 0 nbuckets: 1000 block_size: 8 bucket_size: 1024 nr_in_set: 1 nr_this_dev: 0 first_bucket: 1 $ cset_uuid=$(bcache-super-show cache0.img | awk '$1 == "cset.uuid" { print $2 }') $ echo $cset_uuid 1d997f00-4d73-40d6-9a09-c9192bf6aed2 ## setup primary disk $ truncate --size=1M root.img $ zcat root-image.gz >> root.img # 2048 is 1M / 512B sectors $ make-bcache --bdev --data-offset=2048 "--cset-uuid=${cset_uuid}" root.img # 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 $ qemu-system-x86_64 -enable-kvm \ -device virtio-net-pci,netdev=net00 -netdev type=user,id=net00 \ -drive if=virtio,file=root.img,format=raw \ -drive if=virtio,file=cache0.img,format=raw \ -drive if=virtio,file=seed.img,format=raw \ -nographic \ -kernel boot-kernel -initrd boot-initrd \ -append "root=UUID=${uuid} console=ttyS0" -m 1024 -echr 0x05 -snapshot -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1515780 Title: bcache does not work with suspend To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bcache-tools/+bug/1515780/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
