Introduction

As admin for Fog the departmental virtual machine host for experiments, from time to time users wish to access their files even when the vm doesn't work for one reason or another. So here is a fast way of exposing the partitions. Credit goes to Jeff Waugh for writing up this info.

Details

apt-get install qemu-utils
modprobe nbd max_part=16"
# absolute path of vdi is required.
qemu-nbd -c /dev/nbd0 <vdi-file>
mount /dev/nbd0p1 /tmp/p1
...
umount /tmp/p1
qemu-nbd -d /dev/nbd0