From afecebc9521775a3bf2cdd055035d3d0a3377554 Mon Sep 17 00:00:00 2001 From: subh Date: Wed, 15 Apr 2026 18:32:58 +0530 Subject: revamp --- stuff/luks-encryption.html | 213 ++++++++++++++++++++++++--------------------- 1 file changed, 115 insertions(+), 98 deletions(-) (limited to 'stuff/luks-encryption.html') diff --git a/stuff/luks-encryption.html b/stuff/luks-encryption.html index f292c63..4b1cf3a 100644 --- a/stuff/luks-encryption.html +++ b/stuff/luks-encryption.html @@ -3,138 +3,155 @@ - subh.space + LUKS Encryption - subh.space -

Encrypting a Drive with LUKS and cryptsetup

- -

1. Get the drive name

-
lsblk
-
- -

2. Install cryptsetup

-
sudo pacman -S cryptsetup
-
- -

3. Format the drive

- -
cfdisk /dev/sdaX
-
- -
mkfs.ext4 /dev/sdaX
-
- - -

4. Encrypt the created partition

- -
lsblk /dev/sdaX
-
- -
cryptsetup luksFormat /dev/sda[0-9]
-
- - -

5. Decrypt and create filesystem

- -
cryptsetup open /dev/sda[0-9] <name>
-
- -
mkfs.ext4 /dev/mapper/<name>
-
- -

6. Re-encrypt after usage

-
cryptsetup close <name>
-
+
+ home + git + github + notes + hackthebox +
+ +
+

Encrypting a Drive with LUKS and cryptsetup

+ +

1. Get the drive name

+
lsblk
+ +

2. Install cryptsetup

+
sudo pacman -S cryptsetup
+ +

3. Format the drive

+

To format the drive, you can use cfdisk or any other utility of your choice.

+
cfdisk /dev/sdaX
+

Now, delete all the signatures and partitions on the drive. Then, create a filesystem on the drive as follows:

+
mkfs.ext4 /dev/sdaX
+

After the FS has been created, create a partition on the drive with cfdisk. After the partition has been created, you can finally start encrypting the drive.

+ +

4. Encrypt the created partition

+

List the partition:

+
lsblk /dev/sdaX
+

Encrypt the partition:

+
cryptsetup luksFormat /dev/sda[0-9]
+

It will ask for a passphrase, make sure to provide a strong passphrase.

+ +

5. Decrypt and create filesystem

+

Decrypt the drive:

+
cryptsetup open /dev/sda[0-9] <name>
+

Make the FS:

+
mkfs.ext4 /dev/mapper/<name>
+ +

6. Re-encrypt after usage

+
cryptsetup close <name>
+
+ + -- cgit v1.2.3