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

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 3 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, its builder, and optionally, vdautomount

vdfuse-v80.c
Changes: Support for snapshots through vdautomount
(24.32 KiB) Downloaded 8050 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 8060 times

vdautomount-0.1.txt
easy-to-use wrapper for vdfuse (this is a python script but the extension is txt for the same reason as above)
(3.63 KiB) Downloaded 14171 times


3. Compile it.
    sh vdbuild /path/to/vbox/headers vdfuse.c
4. Run it!

To mount an image directly using its filename:
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

To mount an machine disk (including snapshots)
Code: Select all   Expand viewCollapse view
$ ./vdautomount-0.1.txt --help
Usage: vdautomount [options] machine-name-or-uuid mountpoint

Options:
  --version   show program's version number and exit
  -h, --help  show this help message and exit
  -p vdfuse   path to vdfuse
  -r          readonly
  -g          run in foreground
  -v          verbose
  -d          debug
  -a          allow all users to read disk
  -w          allow all users to read and write to disk
  -m NUMBER   specify which disk to mount, required if machine has more than
              one disk
$ ./vdautomount-<version> -p /path/to/vdfuse WinXP /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.
Last edited by h2o on 28. Jun 2010, 01:47, edited 3 times in total.
h2o
 
Posts: 40
Joined: 9. Feb 2009, 04:46

Return to Linux Hosts

Who is online

Users browsing this forum: No registered users and 1 guest