[Libguestfs] Bind mounts

Richard W.M. Jones rjones at redhat.com
Fri Sep 26 07:48:32 UTC 2014


The test program below demonstrates how to use bind mounts to mount a
subdirectory over the root directory.  It is using the debug backdoor,
but I guess we could consider adding a bind-mount API instead.

[Note that guestfs_mount_options doesn't work because it expects the
third argument to be a device, not a directory name.]

Rich.

----------------------------------------------------------------------

guestfish -N fs -m /dev/sda1 <<EOF
  mkdir /root
  touch /root/test

  # Use -o rbind if there are submounts.
  debug sh "mount -o bind /sysroot/root /sysroot"

  ls /
  # The above command prints "test" as expected.

  # Check that umount-all still works.
  umount-all
  debug sh "grep /sysroot /proc/mounts ||:"
EOF


-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list