Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How to mount ext3, ext4 partition sitting on "Fixed-Size VDI" VirtualBox HardDisk ?

To be more specific, I ma interested in case when VM is not running.

share|improve this question
add comment

2 Answers

The package virtualbox-fuse installs the vdfuse command which can be used to mount either dynamic or fixed VDI files.

apt-get install virtualbox-fuse
mkdir /mnt/point
mkdir /mnt/p1
vdfuse -f file.vdi /mnt/point
mount /mnt/point/Partition1 /mnt/p1
share|improve this answer
add comment
up vote 1 down vote accepted

I've found very helpful answer on:

https://wiki.archlinux.org/index.php/VirtualBox#Mounting_.vdi_Images

The tip is to use offset option of ext4 mount (to be more specific, in back scenes it uses offset as option for loopback device losetup)

It's about

  • taking offData info from VDI image
  • adding magic number 32256
  • and using result as offset

Here is my way of automating it:

VDIfile=VirtData.vdi
mountingpoint=/mnt/VDI
offData=$( VBoxManage internalcommands dumphdinfo "$VDIfile" |grep offData | sed 's:.*offData=\([0-9]*\).*:\1:' )
offset=$(( $offData + 32256 ))
mount -t ext4 -o rw,noatime,noexec,loop,offset="$offset" "$VDIfile" "$mountingpoint"

For /etc/fstab you might like to add: (123456789 is counted previously offset)

/path/VirtData.vdi      /mnt/VDI        ext4 rw,noatime,noexec,loop,offset=123456789,user,noauto

Of course rw can be changed to ro or you might not need noatime or noexec - taylor them to your needs

Btw. if your path contains spaces there is a trick of changing spaces into \040 (source: https://wiki.archlinux.org/index.php/Fstab )

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.