Mounting VirtualBox images (Dynamic VDI) on GNU/Linux
Published by Jack on Tue, 20/04/2010 - 01:21
Sometimes it can be necessary mount a VirtualBox image, VDI type with dynamically expanding storage, on a GNU/Linux system. A use case, it could be that we have to modify some system file on a MS Windows system (NTFS file system format) and we cannot do it on a booted system.
When using a Fixed-size storage VDI partition it becomes easier to mount and debug partitions, but with dynamically expanding storage partitions the only method that worked for me was the one explained below.
Just to mention that vditool it's no more available to dump partition metadata, now can be done using the following command:
$ VBoxManage internalcommands dumphdinfo ~/.VirtualBox/VDI/partition.vdi
We used VirtualBox 3.1.6 to perform the following actions:
- Convert dynamic VDI partition to a RAW type partition:
$ VBoxManage internalcommands converttoraw windows.vdi windows.raw
That takes a while...
- Once finishes the conversion process, we can mount the RAW partition as a loop device specifying a hardcoded offset, that's the reason for converting the partition type, using VDI partition type the offset does not remain always the same.
$ mount -o loop,offset=32256 ~/.VirtualBox/VDI/windows.raw /mnt/disc
- We check that the partition was properly mounted:
$ mount | grep loop /dev/loop0 on /mnt/disc type ntfs (rw,offset=32256)
Undefined