Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is it possible to mount a virtual hard disk (VHD, HDD, VDI, VMDK) on Ubuntu? How can this be done?

share|improve this question
1  
Have you searched Google? It abounds with guides on mounting VMDK, VDI, VHD, and raw disk image files on Ubuntu. –  SirCharlo Oct 18 '12 at 17:53
2  
I have searched google, but I did not find like your result. Thanks :) –  Snow Leopard Oct 19 '12 at 2:16

2 Answers 2

According to this article:

Linux and other Unix-like hosts can mount images created with the raw format type using a loopback device. From a root login (or using sudo), mount a loopback with an offset of 32,256.

mount -o loop,offset=32256 /path/to/image.img /mnt/mountpoint

For other types of qemu images, you can use qemu-nbd

modprobe nbd max_part=16
qemu-nbd -c /dev/nbd0 image.qcow2
partprobe /dev/nbd0
mount /dev/nbd0p1 /mnt/image

Plus, usually, you can convert image from one format to another.

raw - (default) the raw format is a plain binary image of the disc 
       image, and is very portable. 
       On filesystems that support sparse files, 
       images in this format only use the 
       space actually used by the data recorded in them.
cloop -     Compressed Loop format, mainly used for reading Knoppix 
       and similar live CD image formats
cow - copy-on-write format, supported for historical reasons only and
       not available to QEMU on Windows
qcow - the old QEMU copy-on-write format, supported for 
       historical reasons and superseded by qcow2
qcow2 - QEMU copy-on-write format with a range of special features, 
       including the ability to take multiple snapshots, smaller 
       images on filesystems that don't support sparse files, 
       optional AES encryption, and optional zlib compression
vmdk - VMware 3 & 4, or 6 image format, for exchanging images 
       with that product
vdi - VirtualBox 1.1 compatible image format, for exchanging 
       images with VirtualBox.

Try to google, I'm found solution for (VirtualBox) .VDI in one second:

modprobe nbd max_part=16
qemu-nbd -c /dev/nbd0 /path/to/some.vdi
mount -o loop /dev/nbd0p1 /mnt
# do stuff
umount /mnt
qemu-nbd -d /dev/nbd0
rmmod nbd

The same as "Qemu's way" commands. No borders!

share|improve this answer

I've founded this video that show how to use the tool libvhdi.

Video link: http://youtu.be/inxoqsH9TxI

Library video: https://code.google.com/p/libvhdi/

share|improve this answer
1  
Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Eric Carvalho Oct 25 '13 at 10:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.