Skip to content

Instantly share code, notes, and snippets.

@gtirloni
Created May 2, 2022 12:44
Show Gist options
  • Save gtirloni/5b62ad835a06da21a6bd11aa78d3f7c4 to your computer and use it in GitHub Desktop.
Save gtirloni/5b62ad835a06da21a6bd11aa78d3f7c4 to your computer and use it in GitHub Desktop.
Windows WSL2 and LUKS

If you have a LUKS-encrypted partition on another disk, it's easy to mount it inside WSL.

List your disks:

> wmic diskdrive list brief

Mount the whole disk inside WSL (using --bare so WSL doesn't attempt to mount it automatically):

> wsl --mount \\.\PHYSICALDRIVE1 --bare

Now inside WSL, check the device name of the mounted disk (something like /dev/sd*):

$ dmesg | tail

Open the LUKS device (it'll prompt for your passphrase):

$ sudo cryptsetup luksOpen /dev/sdd3 my-encrypted-disk

And mount it somewhere:

$ sudo mount /dev/mapper/my-encrypted-disk /somewhere

Avoid mounting on /mnt because that's usually used by WSL itself to mount your C: drive.

@gtirloni
Copy link
Author

gtirloni commented May 26, 2024

Where does /somewhere inside the WSL end up in windows explorer?

@nextgenthemes In the latest Windows 11, there is a Linux icon where This PC and Network are. You can access the WSL filesystem there.

So /somewhere inside WSL would be \\wsl.localhost\Ubuntu\somewhere (if you're using the default Ubuntu distro).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment