added 2026-09-24 07:19:52
This commit is contained in:
@@ -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$\<DistroName>\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.
|
||||||
Reference in New Issue
Block a user