Created
September 8, 2021 00:57
-
-
Save gigawatts/0d1e3b713a22ce7850f29ed599bd03f4 to your computer and use it in GitHub Desktop.
Bitlocker encrypted VHD mount / un-mount scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ] | |
then | |
echo "No argument supplied" | |
exit 1 | |
fi | |
VHD=$1 | |
if [ ! -f "$VHD" ]; then | |
echo "${VHD} does not exists" | |
exit 1 | |
fi | |
## enable network block devices | |
sudo modprobe nbd max_part=8 | |
## mount VHD disk image to a nbd block device, optionally --read-only | |
sudo qemu-nbd --connect=/dev/nbd0 ${VHD} | |
## view partitions of disk image | |
sudo fdisk -l /dev/nbd0 | |
## create a decrypted block device from encrypted block device | |
sudo mkdir /mnt/blfile /mnt/bitlocker | |
sudo dislocker -v -V /dev/nbd0p2 -u -- /mnt/blfile | |
## mount the decrypted block device to a mount point | |
sudo mount -o loop /mnt/blfile/dislocker-file /mnt/bitlocker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo umount /mnt/bitlocker /mnt/blfile && sudo rmdir /mnt/bitlocker /mnt/blfile && sudo qemu-nbd --disconnect /dev/nbd0 && sudo rmmod nbd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment