Mounting a VirtualBox dynamic size VDI Image

To work with a variable sized VDI file, you have to dump it to a dd file first (COPYDD); this will create a fixed size dump that then can be opened on a loop device. The variable sized file does not allow mounting as the fs driver needs to see the expected disk size.

So we proceed as follows:

~/.VirtualBox/VDI$ vditool COPYDD win.vdi dump
vditool    Copyright (c) 2008 Sun Microsystems, Inc.

Then we look where the partition starts, in my case this was a WinXP fat32 formatted filesystem:

~/.VirtualBox/VDI$ hexdump -C -v dump |head -n 30000 |grep -i dos
00007e00  eb 58 90 4d 53 44 4f 53  35 2e 30 00 02 10 24 00  |.X.MSDOS5.0...$.|
00008a00  eb 58 90 4d 53 44 4f 53  35 2e 30 00 02 10 24 00  |.X.MSDOS5.0...$.|
~/.VirtualBox/VDI$

Then we mount it:

~/.VirtualBox/VDI$ sudo mount -o loop,offset=0x7e00,umask=000 -o ro dump /mnt/
This entry was posted in linux and tagged , . Bookmark the permalink.

3 Responses to Mounting a VirtualBox dynamic size VDI Image

  1. sergi says:

    “So, we proceed as follows”… molt bó mussol! :)

  2. Vino says:

    wow, this is the tutorial I need.. but, I’m using NTFS for my VDI filesystem.. is there any different command for NTFS?

  3. Matt says:

    Vino,

    Probably a few months too late for you, but just replace “dos” with “ntfs” when you grep the hexdump – see below:

    ~/.VirtualBox/VDI$ hexdump -C -v dump |head -n 30000 |grep -i ntfs

    Another thing, vditool has been replaced by VBoxManage

    So what you should do is:

    VBoxManage clonehd win.vdi dump –variant Fixed

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>