How to mount a vdi file in ubuntu 13.10?

30,887

Solution 1

virtualbox-fuse was deleted from apt repository. You can download it from Launchpad, and install it. Once you download it, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, navigate to where the file was downloaded, and run the command(s) below:

sudo dpkg -i <package_name>.deb

Once installed, you can mount the vdi by typing

sudo vdfuse -f /home/user/file.vdi /home/user/mountpoint

Note: virtualbox-fuse depends on virtualbox 4.1.18, and will not work with 4.2. Thanks to Marius.

Solution 2

Running Ubuntu 14.04 with Virtualbox 4.3.10 I installed the package by forcing dpkg.

sudo dpkg -i --force-depends virtualbox-fuse_4.1.18-dfsg-1ubuntu1_amd64.deb

Everything worked just fine after that.

When you mount the vdi file it just gives you access to the partitions, but you need to then mount the partition somewhere. For example:

mkdir ~/vdisk
mkdir ~/part1
sudo vdfuse -f Machine.vdi ~/vdisk
sudo mount ~/vdisk/Partition1 ~/part1

Solution 3

Based on @gavenkoa's answer, but for mounting an existing image instead of creating a new one::

$ sudo apt-get install qemu-utils
$ sudo modprobe nbd max_part=16
$ sudo qemu-nbd -c /dev/nbd0 ~/path/to/my.vdi
$ sudo partprobe /dev/nbd0
$ sudo mount /dev/nbd0p1 /mount-target

If you have more than one partition, you can access them by number — nbd0p1 is partition 1, nbd0p2 would be partition 2, and so on.

After you finished your investigation, you should unmount VDI image from the network device.

$ sudo qemu-nbd -d /dev/nbd0

Solution 4

...For those of you that use 4.2, you should downgrade if you wish to use this software ...

This is not correct! The 4.1-version of "vbfuse" is compatible to the 4.x line of the official virtualbox versions.

Just download the virtualbox-fuse package, but don't install it with:

sudo apt-get install -d virtualbox-fuse

Instead, simply copy the package to a (temporary) directory, extract is and copy the "vdfuse" binary over to your system:

mkdir /tmp/vboxfuse
cd /tmp/vboxfuse
mv /var/cache/apt/archives/virtualbox-fuse*.deb .
dpkg -x virtualbox-fuse*.deb .
cp -av usr/bin/vdfuse /usr/bin/.
cd /tmp
rm -rf vboxfuse

You will need root privileges to execute some of the above commands depending on the permissions of /usr and /var in your system.

This way you don't have to uninstall your virtualbox-4.x. Tested under Ubuntu 12.04, but also should work on other versions.

See: https://wiki.blue-it.org/VirtualBox#Mount_a_vmdk_file_in_linux

Solution 5

Prepare working environment::

$ mkdir ~/devel/lfs
$ VBoxManage createhd --filename ~/devel/lfs/lfs.vdi --size 2000 --format VDI

Get required packages::

$ sudo apt-get install qemu-utils
$ sudo modprobe nbd max_part=16

Without max_part=16 I get error on Debian for later commands::

$ sudo partprobe /dev/nbd0                                                                                                                
Error: Error informing the kernel about modifications to partition /dev/nbd0p1 -- Invalid argument.
This means Linux won't know about any changes you made to /dev/nbd0p1 until you reboot -- so you shouldn't mount it or use it in any
way before rebooting.                                                                               
Error: Failed to add partition 1 (Invalid argument)

Make partitions and format::

$ sudo qemu-nbd -c /dev/nbd0 ~/devel/lfs/lfs.vdi
$ { echo mklabel msdos; echo mkpart primary ext2 0s -1s; echo quit; } | sudo parted /dev/nbd0
$ sudo partprobe /dev/nbd0
$ sudo mkfs.ext3 /dev/nbd0p1

and mount image::

$ mkdir ~/devel/lfs/image
$ sudo mount /dev/nbd0p1 ~/devel/lfs/image

After you finished your investigation, you should unmount VDI image from the network device.

$ sudo qemu-nbd -d /dev/nbd0
Share:
30,887

Related videos on Youtube

marius-nyxpoint
Author by

marius-nyxpoint

Updated on September 18, 2022

Comments

  • marius-nyxpoint
    marius-nyxpoint over 1 year

    I'm trying to mount a vdi file in ubuntu 13.10. I tried to

    sudo apt-get install virtualbox-fuse
    

    but it complains about not finding the package.

    Converting it to raw is not really an option for me, I don't have enough free space.

  • marius-nyxpoint
    marius-nyxpoint over 10 years
    This is the correct answer however should be pointed out that there is no virtualbox-fuse for virtualbox 4.2. For those of you that use 4.2, you should downgrade if you wish to use this software
  • Ken Sharp
    Ken Sharp about 10 years
    This doesn't work with .vdi files.
  • David Baucum
    David Baucum over 9 years
    It is worth mentioning that this method will make apt angry until the package is uninstalled. Given that I was just trying to copy data off of a virtual machine that was refusing to boot, I just uninstalled the package when I was done.
  • Ken Sharp
    Ken Sharp almost 9 years
    That's great but he only wants to mount the image, not destroy all the data on it.
  • diyism
    diyism almost 9 years
    sudo dpkg -i --force-depends virtualbox-fuse_4.1.22-dfsg-0ubuntu2_amd64.deb
  • lalomartins
    lalomartins almost 9 years
    follow exactly the same instructions but skip the parted and mkfs lines to mount an existing image (and obviously also the createhd)