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.
sudo apt-get install virtualbox libfuse-dev
Now you should get vdfuse for the newer versions of VirtualBox. It’s available in this github repo here: https://github.com/Thorsten-Sick/vdfuse
If you have git, simply run this command:
git clone https://github.com/Thorsten-Sick/vdfuse.git
Next change directory into vdfuse (e.g.
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. )
wget http://download.virtualbox.org/virtualbox/4.3.16/VirtualBox-4.3.16.tar.bz2 tar xvjf VirtualBox-4.3.16.tar.bz2 VirtualBox-4.3.16/include
Now, we build vdfuse.
sh vdbuild_new VirtualBox-4.3.16/include vdfuse.c
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
sudo chmod o+r /etc/fuse.conf
And then you need to edit
/etc/fuse.conf to have a line that reads
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.
An example from my machine:
vdfuse -f "~/VirtualBox VMs/Test/Test.vdi" ~/Test ls -l ~/Test -rw------- 1 1001 1001 144570624 Sep 14 12:18 EntireDisk -rw------- 1 1001 1001 93214208 Sep 14 12:18 Partition1 -rw------- 1 1001 1001 51323392 Sep 14 12:18 Partition2