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.
Use
qemu-nbd
, the process is explained on serverfault and in this blog.Basically, you'll have to install
qemu
if needed:Then you'll need to load the network block device module:
Attach the .vdi image to one of the nbd you just created:
Now you will get a /dev/nbd0 block device, along with several /dev/nbd0p* partition device nodes.
Once you are done, unmount everything and disconnect the device:
You can convert into standard image and then mount it.
Then
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.To check details about your VDI file, run:
VBoxManage showhdinfo ubuntu.vdi
.Source: [SOLVED] Open .vdi with archive manager? - ubuntuforums.org
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:
It seems it now supports dynamic vdi as well.
And to mount the
.vdi
file in/mnt
dir use the command:The entire disk will be mounted with partitions
Partition1
,Partition2
naming format. Then those files can be loop mounted. For example,Set the disk as secondary master for another virtual OS, then boot into this (virtual) OS and you can mount it.
Step 1: Assuming you have a virtual os(say Ubuntu 16.04) already installed in Virtual box, add a new storage from settings of that virtual os.
Step 2: Browse the Vdi file you want to access and select it.
Step 3: Logon to the virtual OS.
Step 4: The virtual disk will probably be available inside the OS. If not, follow step 5
Step 5: Inside the virtual OS, use Gparted and check the disks. and ensure the disk is of type which is accessible by the virtual OS. If it is not, you may have to edit the disk, but then you will lose the existing contents.
I haven't tested myself but there is a fuse module to mount them (
vdfuse
), check the following page:Please note that using it for write access is risky.
Usage:
To mount an image directly using its filename:
To mount an machine disk (including snapshots):
As Vojtech Trefny mentioned above,
1) first convert your VDI -> IMG
2) Then mount the IMG
3) However, as I got this error message:
and dmesg said:
you need to check out the partition structure of the .img:
4) As you can see, the main partition is starting at bytes 16775168. However, note that the sector size is 512 bytes, so you need to multiply the results 16775168 x 512 = 8588886016 so you need to offset the mount like this:
5) Actually this didn't work for me in case where the filesystem was dirty after resize. In this case I further did this:
You can use
vboximg-mount
program which is a part of the VirtualBox's command line tools.Not what you requested, but if it's just a matter of getting files off of the vdi, and you want a very quick solution:
apt-get install openssh-server && service ssh restart
)sftp hostuser@hostip
)put
as many files to the host as you need.P7Zip will open VDI files
Install P7Zip - Desktop from Ubuntu Software from this link or by running:
Launch P7Zip Desktop and navigate to the folder containing the
.vdi
file (probably underVirtualBox VMs
in your home directory)Double click the VDI file in the P7Zip window.
View or extract files as you like.
Make
VirtualBox
disk images available to the host by using vboximg-mount utility:Open VDI
Output Example
Mount Disk
Unmount