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.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityRunning 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
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
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.
...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
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