Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is it possible to mount a VirtualBox drive image (.vdi) so the contents can be viewed in Nautilus etc.?

I have a windows 2000 .vdi which won't boot ("inaccessible boot device") after upgrading from VirtualBox 2.x to 3.1.6. I believe the IDE drive details have changed and that all I need to do is access the internal drive image and edit the Windows boot.ini to point to the new location.

share|improve this question
    
If your .vdi and then .img file contains more then 1 partition, this is very useful: browse-img-without-mounting –  user2689749 Mar 31 at 22:00
add comment

5 Answers

up vote 19 down vote accepted

You can convert into standard image and then mount it.

VBoxManage clonehd --format RAW ubuntu.vdi ubuntu.img

Then

mount -t ext3 -o loop,rw ./ubuntu.img /mnt

You will need to KNOW the type of file system, ext3 in this case. After it is mounted, go in and edit away with the editor of your choice. Don't confuse files inside the /mnt location with the running host, or it will be bad.

http://ubuntuforums.org/showthread.php?t=1511162

share|improve this answer
2  
Specilly useful in a situation like this. OP will be able to work on the copy keeping the original as backup. –  Javier Rivera Dec 30 '10 at 15:22
    
Careful doing this with dynamically sized .vdi files. Converting to .img will force the image file to be as big as the logical size of the disk, which is why this approach works, but it might be much larger than .vdi file was. Take a look at the output of VBoxManage showhdinfo [your vdi file] if you're not sure. –  Jack O'Connor Aug 25 '13 at 22:21
add comment

it looks like vdfuse is the tool you are looking for. It is in the Ubuntu repositories. If you want to compile yourself (2010 source) you can do that too.

However for most of us it boils down to a simple:

    sudo apt-get install virtualbox-fuse

It seems it now supports dynamic vdi as well.

And to mount the .vdi file in /mnt dir use the command:

   sudo vdfuse -a -f /path-to-vdi-file /mnt

The entire disk will be mounted with partitions Partition1 , Partition2 naming format. Then those files can be loop mounted. For example,

  sudo mount -o loop /mnt/Parition1 /mountpoint
share|improve this answer
    
Thanks for pitching in. vdfuse has already been provided as an answer though. Please improve that answer instead of adding a duplicate. –  matt wilkie May 7 '12 at 16:49
1  
@mattwilkie: The difference now: no manual compile required anymore –  stwissel May 9 '12 at 2:20
    
ok, with that edit this answer is now better than the previous 1 liner. –  matt wilkie May 9 '12 at 16:46
1  
You are welcome. Sitting at a propper screen/keyboard instead of pecking on glas made all the difference :-) –  stwissel May 10 '12 at 3:15
    
Advantage of vdfuse is that it does not complain about disk full etc. If you go with VBoxManage, you need to have additional space for mounting. –  Jack Sep 19 '13 at 3:31
add comment

Use qemu-nbd, the process is explained on serverfault and in this blog.

Basically, you'll have to install qemu if needed:

sudo apt-get install qemu

Then you'll need to load the network block device module:

sudo rmmod nbd
sudo modprobe nbd max_part=16

Attach the .vdi image to one of the nbd you just created:

sudo qemu-nbd -c /dev/nbd0 drive.vdi

Now you will get a /dev/nbd0 block device, along with several /dev/nbd0p* partition device nodes.

sudo mount /dev/nbd0p1 /mnt

Once you are done, unmount everything and disconnect the device:

sudo qemu-nbd -d /dev/nbd0
share|improve this answer
add comment

Set the disk as secondary master for another virtual OS, then boot into this (virtual) OS and you can mount it.

share|improve this answer
add comment

I didn't tested myself but there seems to be a fuse module to mount them (vfduse), check the following link: http://forums.virtualbox.org/viewtopic.php?f=26&t=33355

Please note that using it for write access is risky.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.