-
Find and mount the partition in PowerShell as admin
GET-CimInstance -query "SELECT * from Win32_DiskDrive"Example output:
DeviceID Caption Partitions Size Model -------- ------- ---------- ---- ----- \\.\PHYSICALDRIVE2 WD My Passport 2626 USB Device 0 5000945564160 WD My Passport 2626 USB Device \\.\PHYSICALDRIVE1 SAMSUNG MZVPV512HDGL-00000 2 512105932800 SAMSUNG MZVPV512HDGL-00000 \\.\PHYSICALDRIVE0 SAMSUNG MZVL21T0HCLR-00B00 4 1024203640320 SAMSUNG MZVL21T0HCLR-00B00In this case,
\\.\PHYSICALDRIVE1is the DeviceID we are looking for.Make it available to WSL:
wsl --mount \\.\PHYSICALDRIVE1 --bare -
Find encrypted partition
Runlsblkto determine partition we want to unlock.Example output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 363.1M 1 disk sdb 8:16 0 16G 0 disk [SWAP] sdc 8:32 0 1T 0 disk /mnt/wslg/distro / sdd 8:48 0 476.9G 0 disk ├─sdd1 8:49 0 384M 0 part └─sdd2 8:50 0 476.6G 0 partIn this case,
sdd2is the partition we are looking for. -
Open the encrypted partition using cryptsetup (provided by
cryptsetup-binpackage)sudo cryptsetup open /dev/sdd2 my_crypt(The mapped name
my_cryptis arbitrary IIUC.) -
(optional) Ensure logical volume is active
Runsudo lvscan. Example result:ACTIVE '/dev/$YOUR_VOL_GROUP_NAME/swap' [32.00 GiB] inherit ACTIVE '/dev/$YOUR_VOL_GROUP_NAME/root' [<444.55 GiB] inheritIf the logical volume is not active, run
vgchange -ayto activate it. -
(optional) Determine dm number and mount
If the root logical volume is not available at/dev/mapper/$YOUR_VOL_GROUP_NAME-root, you may need to mount using one of the dm devices. Find which here:dmsetup lsExample output:
$YOUR_VOL_GROUP_NAME-root (252:2) $YOUR_VOL_GROUP_NAME-swap (252:1) my_crypt (252:0)The volume group ID number for root is
252:2, so/dev/dm-2corresponds to the root volume. (If we were interested in the swap volume, it would be252:1, and thus/dev/dm-1.) -
Mount the volume
If the volume group is showing under/dev/mapper(may need a restart), you can simply run:sudo mount /dev/mapper/$YOUR_VOL_GROUP_NAME-root /mnt/aOtherwise, using the
/dev/dm-2determined in optional step 5, run:sudo mount /dev/dm-2 /mnt/a
Mount a LUKS-encrypted partition in WSL Ubuntu
Published inDevelopment

Be First to Comment