Skip to content

Instantly share code, notes, and snippets.

@incrazyboyy
Last active June 14, 2023 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save incrazyboyy/432bbf8c4baa582453bfdbc908969145 to your computer and use it in GitHub Desktop.
Save incrazyboyy/432bbf8c4baa582453bfdbc908969145 to your computer and use it in GitHub Desktop.
Mount a single bitlocker volume. Run it with sudo and without any arguments. If multiple bitlocker drives are connected, only the first one will be used.
#!/bin/bash
set -e
for dev in /dev/sd?1
do
if [[ $(blkid -o value -s TYPE $dev) == "BitLocker" ]]
then
dev_name=$(basename $dev)
mount_path="/media/$SUDO_USER/$dev_name"
dislocker_path="/media/bitlocker/$dev_name"
mkdir -p $dislocker_path
if [ -f $dislocker_path/dislocker-file ]
then
echo "$dev_name is already unlocked!"
continue
fi
mkdir -p $mount_path
dislocker -V $dev -u -- $dislocker_path
mount -o loop $dislocker_path/dislocker-file $mount_path
read -p "Mounted! Press ENTER when you're finished to umount the drive again."
umount $mount_path
umount $dislocker_path
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment