Skip to content

Instantly share code, notes, and snippets.

@naoki-mizuno
Created March 25, 2022 01:34
Show Gist options
  • Save naoki-mizuno/10ed5fe06ce04b0db28d9e6bea62710a to your computer and use it in GitHub Desktop.
Save naoki-mizuno/10ed5fe06ce04b0db28d9e6bea62710a to your computer and use it in GitHub Desktop.
Utility script for mounting BitLocker drives using dislocker
#!/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