| #!/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 | |
On Arch and Manjaro, you will need the following packages:
qemu-headlessnbd
To install them:
sudo pacman -S qemu-headless nbd
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.
Thank you. This allowed me to mount WSL2 partitions from native linux after running into errors with libguestfs.
Simmilar to @stewSquared I mounted a WSL2 partion aswell. The only thing I had to change was the last command of the mount script, because in my case there were no partitions just /dev/nbd0 so I my command was:
sudo mount -o rw,nouser /dev/nbd0 "$MOUNT_POINT" (notice the missing p1)
Thank you very much! @allenyllee ! Is it also possible with VHDX configured with Bitlocker encryption?
Anyway to resize the image please @allenyllee
This has just saved me. Thank you!