Search This Blog

Thursday, June 27, 2013

Mounting VHD Image file in Linux

Back again,

So i have been playing around with so called VHD based image for a while. Here came the requirement, where i needed to mount this image and push in some keys... This is the solution i found

Step 1: Install the virtualbox fuse package which is required to open up this vhd image into its raw form

# apt-get install virtualbox-fuse

Step 2: Open up VHD image

# vdfuse -w -f <path to vhd image> <path to mount point>

Step 3: Check the extracted Files

# ls <path to mount point>

Here it could list either 

# EntireDisk

Lets mark this CASE 1

     (or)

# EntireDisk Partition1 Partion2 . ...

Depending on the number of partitions made on the Disk while creating and lets mark this as CASE 2

Step 4: Mount the extracted RAW image

# mount <path to vhd image>/EntireDisk <path to one more new mount point path>

In case of CASE 1

     (or)

# mount <path to vhd image>/Partition1 <path to one more new mount point>

In case of CASE 2
Partition here could be the one you wanted to mount

Step 5: unmounting the IMG and VHD after usage

# umount <path to mounted IMG partition>

# umount <path to vhd image>

Hope this is useful for all of you who see this :)

5 comments:

  1. Thanks for this information! I'm woundering, would it be possible to dd Partition1 onto a partition on a physical disk? I.e.
    # dd if=/Partition1 of=/dev/sdb2 bs=1M

    ?

    Thanks.

    ReplyDelete
    Replies
    1. I know its a very late reply.... Yes you can copy the contents of Partition1 to a physical device provided the disk has enough space in it

      Delete
  2. on my system it didn't work until I installed another package. For example I didn't have a /etc/fuse.conf

    After installing ntfsprogs everything worked fine

    apt-get install ntfsprogs

    ReplyDelete
  3. virtualbox-fuse isn't available anymore in Ubuntu 16.04.
    But there is a new way to mount a VHD:

    sudo apt-get install libguestfs-tools

    Check the VHD first, to get information about the partitions in the image.
    virt-filesystems --long --filesystems -a FreeDOS_1.2.vhd

    Make a mount point in userspace f.i. /home/username/vhd

    Mount it:
    guestmount -a FreeDOS_1.2.vhd -m /dev/sda1 /home/username/vhd

    Afterwards unmount it with:
    guestunmount /home/username/vhd

    ReplyDelete
  4. Works for me, thanks!

    ReplyDelete