mount virtual disk in Linux

22 September 2018

 

sudo apt-get install qemu-utils

unload NBD module

sudo rmmod nbd

reload

sudo modprobe nbd max_part=8

Attach whole file (disk)

sudo qemu-nbd -c /dev/nbd0 drive.vdi

Mount partition  from /dev/nbd0.  it can be several disk /dev/nbd0p*

sudo mount /dev/nbd0p1 /media/vdi

----------------------

Umount & cleanup

sudo umount /dev/nbd0p1
sudo qemu-nbd -d /dev/nbd0
sudo rmmod nbd