Skip to content

Instantly share code, notes, and snippets.

@HateFindingNames
Created January 19, 2025 12:10
Show Gist options
  • Select an option

  • Save HateFindingNames/90c9e228190a147ba061e35859cdf2c2 to your computer and use it in GitHub Desktop.

Select an option

Save HateFindingNames/90c9e228190a147ba061e35859cdf2c2 to your computer and use it in GitHub Desktop.

Using WSL2

ID the Drive

In elevated PowerShell:

> wmic diskdrive list brief

Pick \\.\PHYSICALDRIVE<drive_num>

Now Mount that drive into WSL:

> wsl --mount \\.\PHYSICALDRIVE<drive_num> --bare

Inside WSL2, check device name:

$ dmesg | tail

Partitioning and configuring the Drive

Adding a partition label and partitioning using fdisk:

$ sudo fdisk /dev/sdX

Pick options:

  1. g: "create a new empty GPT partition table",
  2. n: "add a new partition" using all default settings and finally
  3. w: "write table to disk and exit".

Creating an encrypted Volume and format the encrypted partition

$ sudo cryptsetup luksFormat /dev/sdX1

After following the prompts, map the newly created encrypted partition:

$ sudo cryptsetup open /dev/sdX1 <some_name>

Format the mapped partition as ext4:

$ sudo mkfs.ext4 /dev/mapper/<some_name>

Done 🥳

Mount/Unmounting the drive

$ sudo mount /dev/mapper/<some_name> /mnt/<created_mountpoint>

or

$ sudo umount /mnt/<some_name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment