Last active
June 14, 2023 10:52
-
-
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.
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 | |
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