Mount a VHD or VDI in Linux with vdfuse

My old post on mounting VHDs in Linux is rather outdated. I don’t think it even works anymore. So revisiting this on a newer Ubuntu version now. These instructions are for Ubuntu 14.04, so for other OS installs. You’ll also need your compiler installed, so you may need to run sudo apt-get install build-essential to get them before proceeding.

First we need some prequisites, you’ll need the virtualbox and libfuse-dev packages to be installed.

NOTE: The following example commands reference a specific version of VirtualBox, if you download a different version, be sure to replace the version number in the following commands.

Now we need the includes folder from the source. Again, this uses VirtualBox 4.3.16, so replace with the current version number. (Instead of using wget, you can also download the source with your browser which removes the need to figure out what the current version of VirtualBox is. )

If all went well, you should now have an executable called vdfuse in your vdfuse folder. Optionally, you can now copy it to /usr/local/bin or /usr/bin so any user on the system can use it. We’re almost done, there’s one fuse configuration change that is required.

First, we make sure that users other than root can read /etc/fuse.conf

sudo chmod o+r /etc/fuse.conf

And then you need to edit /etc/fuse.conf to have a line that reads user_allow_other.

Once you have done that, you should now be able to actually run your vdfuse executable. The entire disk and it’s partions are exposed as regular files in the target mount point. These can be loopback mounted like any other file.