How to mount VirtualBox VDI disk on Ubuntu 15.04

This tutorial will try to explain how to mount a VirtualBox disk image (VDI) on Ubuntu 15.04 or Ubunu 14.04. It is possible to mount VDI disk on Ubuntu 15.04 with a little tweak. But make sure the virtual disk (VDI) is not being used by other virtual machine.

OK lets get started

First, we will use “nbd” kernel module. On standard Ubuntu installation, the nbd is not included. You can install this kernel module using this command

sudo apt-get install qemu-kvm

Next, load the nbd kernel module

sudo modproble nbd

Now execute this command to access the VDI disk

qemu-nbd -c /dev/nbd0 /home/dhani/Downloads/ubuntu.vdi

Change /home/dhani/Downloads/ubuntu.vdi with your own vdi file. Now check the device with this command to see the partitions in the device

sudo fdisk -l /dev/nbd0

Output:

Disk /dev/nbd0: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0006a7cc

Device Boot Start End Sectors Size Id Type
/dev/nbd0p1 * 2048 1026047 1024000 500M 83 Linux
/dev/nbd0p2 1026048 41943039 40916992 19.5G 8e Linux LVM

Now mount the partition for example

sudo mount /dev/nbd0p1 /mnt

The command will mount the partition of the VDI disk /dev/nbd0p1 to /mnt. Now the content of the partition will be mounted on /mnt.

 

Admin

2 Comments

  1. After fdisk -l, i am getting disk … Doesn’t contain a valid partition table…

Leave a Reply

Your email address will not be published. Required fields are marked *