HOWTO: Mount any VBox-compatible disk image on the host

Discussions related to using VirtualBox on Linux hosts.

HOWTO: Mount any VBox-compatible disk image on the host

Postby h2o » 11. May 2009, 06:10

This tutorial will show you how to mount any VDI, VMDK, or VHD disk file on the host system! Things you need to get started:
  • gcc version 4 or later
  • VirtualBox version 2 or later
  • development headers (apt-get install build-essential on Ubuntu / Debian)
  • fuse + fuse headers (apt-get install libfuse-dev)
  • VirtualBox source OR subversion
1. Get the VirtualBox headers.
If you don't have the virtualbox sources (see the VirtualBox Downloads page "Open Source Edition (OSE) Source code") and don't want the full sources then get them using subversion:
2. Download vdfuse and its builder.

vdfuse-v60.c
vdfuse source version 60, changes: unlock entiredisk and partitions when all file descriptors are closed (reread the partition table), give it a name in /proc/mounts, added notice about /etc/fuse.conf
(23.41 KiB) Downloaded 267 times

vdbuild.txt
vdfuse build script (this is a shell script but I had to add the txt extension because of the forum. Rename it back to vdbuild)
(1.33 KiB) Downloaded 219 times


3. Compile it.
    sh vdbuild /path/to/vbox/headers vdfuse.c
4. Run it!
Code: Select all   Expand viewCollapse view
$ ./vdfuse-v<version> -h
USAGE: ./vdfuse [options] -f image-file mountpoint
   -h   help
   -r   readonly
   -t   specify type (VDI, VMDK, VHD, or raw; default: auto)
   -f   VDimage file
   -a   allow all users to read disk
   -w   allow all users to read and write to disk
   -g   run in foreground
   -v   verbose
   -d   debug
$ ./vdfuse-v<version> -f image.vdi /mnt/vdi
$ mount -o loop /mnt/vdi/Partition1 /mnt/WindowsXP

Please note that whilst we use this program regularly, any use by you is at your own risk. If you don't trust this program, use the -r (readonly) flag.

This program presents a virtual disk as a Filesystem in User Space (FUSE). The separate partitions appear as block files Partition1, ... under the mount point. You can then mount any or all of the partitions as a Loop Device. If you use the readonly flag then these files are readonly and the partitions themselves can only be mounted readonly. If you want to understand more then follow the referenced links to the Wikipedia articles or read the source; you will see that the vdfuse application itself does very little other than glue the fuse handler to the VirtualBox Virtual Disk API.

Note that this is a restricted topic. If you want to discussion vdfuse then see the vdfuse discussion.
h2o
 
Posts: 34
Joined: 9. Feb 2009, 04:46

Return to VirtualBox on Linux Hosts

Who is online

Users browsing this forum: Ask Jeeves [Bot], huffring, Sasquatch and 10 guests