Created
March 25, 2022 01:34
-
-
Save naoki-mizuno/10ed5fe06ce04b0db28d9e6bea62710a to your computer and use it in GitHub Desktop.
Utility script for mounting BitLocker drives using dislocker
This file contains hidden or 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 | |
DEVICE="$1" | |
MOUNT_DIR="$2" | |
PASSWORD="$3" | |
MY_UID="$( id -u )" | |
MY_GID="$( id -g )" | |
TEMP_DIR="$( mktemp -d )" | |
sudo dislocker -V "$DEVICE" -u"$PASSWORD" -- "$TEMP_DIR" \ | |
&& sudo mount -o loop,uid=$MY_UID,gid=$MY_GID \ | |
"$TEMP_DIR/dislocker-file" \ | |
"$MOUNT_DIR" | |
echo "Press enter when you are ready to unmount" | |
while true; do | |
read USER_INPUT | |
if [[ -z $USER_INPUT ]]; then | |
break | |
fi | |
done | |
sudo umount "$MOUNT_DIR" \ | |
&& sudo umount "$TEMP_DIR" \ | |
&& rm -rf "$TEMP_DIR" | |
echo "Successfully unmounted $DEVICE from $MOUNT_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment