How to mount a VirtualBox .vdi disk on Linux?
Solution 1
You can mount it as a loopback device. Tools you can use are just 'mount' or 'losetup'. The trick is knowing the required offset. For that you need 'vditool' or 'vdiinfo'.
Here is a nice article that explains it well:
http://muralipiyer.blogspot.com/2008/02/mounting-virtualbox-vdi-disk-authentic.html
Solution 2
OpenSuse here, vdfuse works just fine for me both fixed and dynamic images. Download the rpm from : http://download.opensuse.org/repositories/Virtualization/openSUSE_Factory/x86_64/vdfuse-8.2a-5.54.x86_64.rpm
- install (ignore file checksum by pressing i when prompted)
- create a dir for first mount point
- run
sudo vdfuse -f "/home/sys1.vdi" /VBMount
- create a dir for second mount point
- run
sudo mount /VBMount/Partition1 /VBMountPart1/
Related videos on Youtube
mmonem
Updated on September 17, 2022Comments
-
mmonem over 1 year
I am running Fedora on a VirtualBox. Sometimes to allow for performing some real hardware testing, I need to run my development environment on a physical machine. So I need the hard disk of the virtual machine (the .vdi file) to be interchangeably working on both the virtual machine itself and my physical PC by booting a bootable image, mounting the vdi file, and then chrooting to it.
I thought this was easy to achieve but it seems not. I hope to find an answer here.
-
Scott Szretter almost 13 yearsIs this for fixed drives only, or will it work for expanding type VDI's (has anyone tried?)
-
Goyuix almost 13 yearsThis is for fixed disks only. This method will not work with dynamic disks.
-
Anton Samsonov about 8 yearsIf neither
vditool
norvdiinfo
is available, find the offset manually by opening hex editor and searching for55AA
pattern which should be located at0x*****1FE
— that is last 2 bytes in 16-column view, preceded by0000
at0x*****1FE
. If that disk contains MBR code, you will also see “GRUB”, “LILO” or other relevant substrings before that, mixed with machine code. In case of GPT it will contain zeroes though, but “EFI PART” right after, at0x*****200
. Other partitioning schemes have their own recognizable signatures as well.