Home > Linux > Mount VDI file

Mount VDI file


Hey!

Well as a part of my studies we learn assembly under Dos (crap >.<). Anyway to ged rid of Windows I decided to install a Virtual Machine with FreeDOS. The problem was that its pretty hard to transfer files between Linux and the virtual drive, and I couldn’t setup network transfer (I wonder if its possible at all with FreeDOS). So I decided to mount my VDI file and be able to read/write to it as it was a directory on my filesystem. I googled for “mount vdi” and found this link

http://forums.virtualbox.org/viewtopic.php?t=52&start=0&postdays=0&postorder=asc&highlight=

So lets start 🙂

Tools:

1. Linux :p

2. VDI file – Create new partition with Virtual Box, I used fixed size of 90MB and Installed FreeDOS on it.

3. khexedit – sudo apt-get install khexedit

The moves:

khexedit .VirtualBox/VDI/FreeDOS.vdi

Note: You should use decimal instead of hex, View->Offest as decimal

Now is the hard part: you should look for the beginning of the partition

Mine looks like this:

0000033216 ……………………………………………………….
0000033280 �<.FRDOS4.1……….��.?…?…a�..�.)..p$FREEDOS    FAT16
0000033344 1�.ؽ.|��..�.�.��..���^|�…`..�.�.f��.~$�u..V$�F�..�F�…^��FĠ
0000033408 c.v..~..v..�..v�.~�.F..�f..�.�.v�.~�.^.�.��.F.1���P.�.�..v�.~�.F
0000033472 �.V�_�^Z�..�~Z�..��}W��_&.E.t..� &.=.u�reP�^Z.~..F�.V��g.X…^\�

As you can see before offset 33216 there are almost nothing, and the partition starts at offset 33280.

So now we know the start offset of the partiton lets mount it:

sudo mkdir /mnt/vdifs

sudo mount -o loop,offset=33280,umask=000 .VirtualBox/VDI/FreeDOS.vdi /mnt/vdifs

And we done 🙂

To understand what loop, offset and umask stands for read this

http://forums.virtualbox.org/viewtopic.php?t=52&start=0&postdays=0&postorder=asc&highlight=

Better then I can explain 🙂

Now you can read/write files from your partition like it was part of your system 🙂

To un mount it use:

sudo umount /mnt/vdifs

Enjoy 🙂

Categories: Linux Tags: , , ,
  1. May 8, 2009 at 12:01 am

    I made a stand-alone portable package to automate all this stuff. It takes a vdi file, a mountpoint and the number (1-4) of primary partition to mount, and mounts it.
    If it’s not formatted, it all the same gives you a loop device upon which you will find raw partition, and a separate loop device pointing at the hard disk.
    It fully works only on static VDIs (you decide that upon creation); however there is some apparent amount of reading success with dynamic VDIs as well, for sure you can ls their partitions.

    It’s gpl for linux.
    See my page.

  1. No trackbacks yet.

Leave a comment