diff --git a/mount-luks-drive-to-windwos-subsystem-for-linux-bare.sh b/mount-luks-drive-to-windwos-subsystem-for-linux-bare.sh new file mode 100644 index 0000000..c98be59 --- /dev/null +++ b/mount-luks-drive-to-windwos-subsystem-for-linux-bare.sh @@ -0,0 +1,34 @@ +# Mount LUKS drive to Windows Subsystem for Linux Bare + +To mount a **LUKS** encrypted drive using **WSL 2** with the `--bare` flag, you must run PowerShell as an administrator, identify the physical drive, and attach it to WSL before unlocking it within the Linux environment. + +**1. Identify and Mount the Drive in PowerShell** +First, list connected disks to find the correct `DeviceID` (e.g., `\\.\PHYSICALDRIVE1`): +```powershell +Get-CimInstance -query "SELECT * from Win32_DiskDrive" +``` +Then, mount the entire disk to WSL without automatically mounting the filesystem: +```powershell +wsl --mount \\.\PHYSICALDRIVE1 --bare +``` + +**2. Decrypt and Mount in WSL** +Open your WSL distribution (e.g., Ubuntu) and install `cryptsetup` if not present: +```bash +sudo apt install cryptsetup +``` +Identify the partition using `lsblk` or `dmesg`, then unlock the LUKS volume: +```bash +sudo cryptsetup luksOpen /dev/sdX1 my-encrypted-disk +``` +Finally, mount the decrypted mapper device to a directory: +```bash +sudo mkdir -p /mnt/luks-drive +sudo mount /dev/mapper/my-encrypted-disk /mnt/luks-drive +``` +The files are now accessible via Windows Explorer at `\\wsl$\\mnt\luks-drive`. + +**Important Constraints:** +* **Administrator Privileges:** The `wsl --mount` command requires elevated PowerShell rights. +* **Disk Availability:** You can only mount **offline** or external disks. If the LUKS partition is on the same physical disk as Windows (e.g., the C: drive), you cannot detach it from Windows to mount it in WSL. +* **WSL 2 Required:** This feature is only supported in WSL 2 on Windows 10 (Build 20211+) or Windows 11.