Linux: mounting VirtualBox VDI disk using qemu

PHOTO EMBED

Sun Aug 28 2022 01:46:30 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #bash

#install tools qemu-kvm (debian based distros)
$ sudo apt-get install qemu-kvm

#load module
$ sudo modprobe nbd

#create loopback dev for the image
$ sudo qemu-nbd -c /dev/nbd0 <path to virtual disk>.vdi

#mount the partitions, that are exposed as /dev/nbd0pXXX
$ sudo mount  -o noatime,noexec /dev/nbd0p1 /tmp/vdi/

#in the end unmount && shutdown the ndb
$ sudo umount /tmp/vdi/
$ sudo qemu-nbd -d /dev/nbd0
content_copyCOPY

Script used for mounting VDI format VirtualBox virtual disk. It uses qemu-kvm tool and was tested with ubuntu distros.