New in libguestfs ≥ 1.17.22 is the ability to mount the guest filesystem on a local mountpoint. Well, you can already do that using guestmount, but the new thing is that you can do it from the API (from any language).
Here is an example using guestfish:
$ guestfish --ro -a /dev/vg_pin/F16x64 -i Welcome to guestfish, the libguestfs filesystem interactive shell for editing virtual machine filesystems. Type: 'help' for help on commands 'man' to read the manual 'quit' to quit the shell Operating system: Fedora release 16 (Verne) /dev/vg_f16x64/lv_root mounted on / /dev/vda2 mounted on /boot ><fs> ! mkdir /tmp/mnt # creates a local directory ><fs> mount-local /tmp/mnt readonly:true ><fs> mount-local-run # the errors come from a GNOME daemon that # looks at all new mountpoints libguestfs: error: lstat: /.Trash: No such file or directory libguestfs: error: lstat: /.Trash-500: No such file or directory
Over in another terminal, we can see the filesystem mounted on the local directory /tmp/mnt:
$ ls /tmp/mnt bin dev home lib64 media opt root sbin srv tmp var boot etc lib lost+found mnt proc run selinux sys usr $ cat /tmp/mnt/etc/redhat-release Fedora release 16 (Verne)
Unmounting the filesystem causes the guestfish
mount-local-run command to return (since that command was actually serving the FUSE requests from the kernel).
$ fusermount -u /tmp/mnt