Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mount vhdx in linux
#!/bin/bash
# install qemu utils
sudo apt install qemu-utils
# install nbd client
sudo apt install nbd-client
#!/bin/bash
VHDX_IMG="$1"
MOUNT_POINT="$2"
# [ubuntu] How do you mount a VHD image
# https://ubuntuforums.org/showthread.php?t=2299701
#
# Load the nbd kernel module.
sudo rmmod nbd;sudo modprobe nbd max_part=16
# mount block device
sudo qemu-nbd -c /dev/nbd0 "$VHDX_IMG"
# reload partition table
sudo partprobe /dev/nbd0
# mount partition
sudo mount -o rw,nouser /dev/nbd0p1 "$MOUNT_POINT"
#!/bin/bash
MOUNT_POINT="$1"
#unmount & remove nbd module
sudo umount "$MOUNT_POINT" && sudo qemu-nbd -d /dev/nbd0 && sudo rmmod nbd
@balazsbotond

This comment has been minimized.

Copy link

@balazsbotond balazsbotond commented Dec 7, 2020

This has just saved me. Thank you!

@balazsbotond

This comment has been minimized.

Copy link

@balazsbotond balazsbotond commented Dec 10, 2020

On Arch and Manjaro, you will need the following packages:

  • qemu-headless
  • nbd

To install them:

sudo pacman -S qemu-headless nbd
@jackowski626

This comment has been minimized.

Copy link

@jackowski626 jackowski626 commented Apr 28, 2021

Thank you very much, worked perfectly on artix.
If you are mounting a win10 backup, be sure to select the good file and partiton (often nbd0p2), multiple vhdx are generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment