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
nice one. That will give good extra flexibility
hello there,
i just wonder what`s the difference between guestfs_mount and guestfs_mount_local. It seems to me the two just do the same stuff which is mounting the image on the local filesystem. Or is it not with the first one?
guestfs_mount mounts a filesystem inside the libguestfs backend appliance, whereas mount local is used to mount the whole libguestfs “file space” under a host mountpoint. Review the architecture diagram here.
Hi Rich,
Recently i deployed latest 1.17.40 on my rhel6.1.
When i ran a tiny program which was to test the function guestfs_mount_local() or those similar functions that mounts locally, Error prompted—undefined symbol guest_mount_local !
Why didn`t this undefined symbol error prompt when the program was first compiled,but when it was run?
Then i gave guestfish mount local a try in the shell, and found that ok.I thought it could not be something wrong with the installation.And then wierd happened—i ran the previous test program again,and it did mount the vm image on the host local directory! I doubted whether this was repeatable so i ran it again,and oops,it failed with the same error “undefined symbol guestfs_mount_local”.
Maybe you can help me out of this.
Thanks
L
Please ask on the mailing list, particularly including details of how you installed libguestfs 1.17.40 on RHEL 6.1.