Tuesday, January 2, 2024

Mounting VirtualBox VDI files on Linux

The following commands, will mount a VirtualBox VDI file on Linux. First make the directory where you'll mount the virtual partition files inside the VDI (that's the best description I can give you of this, you'll know what I mean when you later see the contents of the directory):

sudo mkdir -p /mnt/vdi/expanded

Now mount the VDI file:

sudo vboximg-mount -i <path-to-vdi> -o allow_other /mnt/vdi/expanded

Then make a directory for the volume you want form inside the VDI: (you probably want vol1 but it depends on your case)

sudo mkdir /mnt/vdi/vol1

Then mount the volume onto the directory: 

sudo mount /mnt/vdi/expanded/vol1 /mnt/vdi/vol1

When you are done, you can unmount everything with:

cd /mnt
sudo umount /mnt/vdi/vol1
sudo umount /mnt/vdi/expanded
sudo rm -rf /mnt/vdi

Be careful with that last command.

No comments:

Post a Comment

Popular Posts