Mounting various image files in Linux

Hyper-v disk files, with extensions such as vhdx and vhd can be mounted under linux directly with the libguestfs-tools tool, mind you, many packages will be installed… mostly libraries relating to the formats it is capable of mounting

sudo apt-get install libguestfs-tools

Now, the following command should mount the disk inside the virtual machine

guestmount --add diskname.vhdx --inspector /mount/dir/name

If the system does not detect a system, you will need to tell guestmount what partition to mount, to explore the partitions, you will need ….

 virt-filesystems -a disk.vhdx

Once you know your partitions

guestmount --add disk_d.vhdx -m /dev/sda1  /hds/loop

If you would rather mount the disk as read only, you can add the –ro switch

guestmount --add yourVirtualDisk.vhdx --inspector --ro /mnt/anydirectory

To unmount, you will need to use the following command

guestunmount /mnt/anydirectory

Leave a Reply

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