Last active
May 5, 2020 14:04
-
-
Save suhrmann/358ee5ca1fbfecb5bbec560b7657098a to your computer and use it in GitHub Desktop.
Mount a BitLocker encrypted (Windows) drive using 'dislocker' - Created and tested on Ubuntu 20.04
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
# Mount a BitLocker encrypted (Windows) partition | |
### SET THESE VALUES | |
# Set either(!) BITLOCKER_RECOVERY_KEY or BITLOCKER_USER_PASSWORD used to unlock drive | |
BITLOCKER_USER_PASSWORD= | |
BITLOCKER_RECOVERY_KEY= # e.g. 123456-123456-123456-123456-123456-123456-123456-123456 | |
# The drive to mount (where Windows is located) | |
WINDOWS_PARTITION=/dev/nvme0n1p4 # Or /dev/sda4 | |
### END: VALUES | |
### Mount points | |
BITLOCKER_MOUNT=/media/bitlocker # Temp mount point for `dislocker` | |
WINDOWS_MOUNT=/media/windows # Mount point of unlocked Windows partition | |
### Assert setup | |
# Assert dislocker is installed | |
if ! hash dislocker 2>/dev/null; then | |
echo "ERROR: dislocker not found. Install on Ubuntu with 'sudo apt install dislocker'" | |
exit | |
fi | |
# Assert either BitLocker recovery key or user password is set | |
if ! [ "$BITLOCKER_RECOVERY_KEY" ] && ! [ "$BITLOCKER_USER_PASSWORD" ]; then | |
echo "ERROR: Neither BITLOCKER_RECOVERY_KEY nor BITLOCKER_USER_PASSWORD is set." | |
exit | |
fi | |
### Preparation | |
# Elevate to root | |
if [ ! $EUID = 0 ]; then | |
sudo "$0" "$@" | |
exit $? | |
fi | |
# Check if dirs / mount points exist | |
if [ ! -d "$BITLOCKER_MOUNT" ]; then | |
echo "Creating dir of moint point for BitLocker" | |
mkdir --parents $BITLOCKER_MOUNT | |
fi | |
if [ ! -d "$WINDOWS_MOUNT" ]; then | |
echo "Creating dir of moint point for Windows" | |
mkdir --parents $WINDOWS_MOUNT | |
fi | |
### Mount | |
# 1. Mount BitLocker to file (with recovery key) | |
if [ $BITLOCKER_RECOVERY_KEY ]; then | |
echo "Mounting BitLocker unlocked with BITLOCKER_USER_PASSWORD..." | |
sudo dislocker -r -V $WINDOWS_PARTITION --recovery-password=$BITLOCKER_RECOVERY_KEY -- /media/bitlocker | |
elif [ $BITLOCKER_USER_PASSWORD ]; then | |
echo "Mounting BitLocker unlocked with BITLOCKER_USER_PASSWORD..." | |
sudo dislocker -r -V $WINDOWS_PARTITION --user-password==$BITLOCKER_USER_PASSWORD -- /media/bitlocker | |
else | |
echo "Neither BITLOCKER_RECOVERY_KEY nor BITLOCKER_USER_PASSWORD is set." | |
exit | |
fi | |
# 2. Mount BitLocker file to Linux drive | |
echo "Mounting Windows..." | |
sudo mount -r -o loop /media/bitlocker/dislocker-file /media/windows/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See Open Bitlocker Drive on Linux >> Step 6 – Creating a Script to automatically Mount the locked Drive [Ceos3c.com] how to auto-mount the BitLocked drive at startup