summaryrefslogtreecommitdiff
path: root/stuff/luks-encryption.html
diff options
context:
space:
mode:
authorsubh <subh@subh.space>2026-04-14 04:09:09 +0530
committersubh <subh@subh.space>2026-04-14 04:09:09 +0530
commit660786784719f83bbba835fb494c3d17ab898c36 (patch)
treecda1331c2cfe1f84fc7e55ed46b57972359d5f4f /stuff/luks-encryption.html
parent3d41c3cd8bf5a0cc68a6be8b28ea46bca91ce7bb (diff)
changes
Diffstat (limited to 'stuff/luks-encryption.html')
-rw-r--r--stuff/luks-encryption.html140
1 files changed, 140 insertions, 0 deletions
diff --git a/stuff/luks-encryption.html b/stuff/luks-encryption.html
new file mode 100644
index 0000000..1b83385
--- /dev/null
+++ b/stuff/luks-encryption.html
@@ -0,0 +1,140 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Encrypted Drive Guide</title>
+ <style>
+ :root {
+ --bg0: #282828;
+ --bg1: #3c3836;
+ --fg: #ebdbb2;
+ --gray: #928374;
+ --yellow: #fabd2f;
+ --green: #b8bb26;
+ --orange: #fe8019;
+ --aqua: #8ec07c;
+ }
+
+ body {
+ font-family: 'Iosevka Nerd Font Propo';
+ line-height: 1.7;
+ color: var(--fg);
+ background-color: var(--bg0);
+ max-width: 780px;
+ margin: 40px auto;
+ padding: 0 20px;
+ -webkit-font-smoothing: antialiased;
+ }
+
+ h1 {
+ font-size: 2.2em;
+ color: var(--yellow);
+ border-bottom: 2px solid var(--bg1);
+ padding-bottom: 15px;
+ margin-bottom: 30px;
+ }
+
+ h2 {
+ font-size: 1.5em;
+ color: var(--aqua);
+ margin-top: 35px;
+ margin-bottom: 15px;
+ font-weight: 600;
+ }
+
+ p { margin-bottom: 1.2em; }
+
+ code {
+ font-family: 'Fira Code', 'JetBrains Mono', 'Courier New', monospace;
+ background-color: var(--bg1);
+ color: var(--orange);
+ padding: 3px 6px;
+ border-radius: 4px;
+ font-size: 0.9em;
+ }
+
+ pre {
+ background-color: #1d2021;
+ padding: 20px;
+ border-radius: 8px;
+ overflow-x: auto;
+ border: 1px solid var(--bg1);
+ margin-bottom: 1.5em;
+ }
+
+ pre code {
+ background-color: transparent;
+ padding: 0;
+ color: var(--fg);
+ color-scheme: dark;
+ }
+
+ ol, ul { margin-bottom: 1.5em; padding-left: 25px; }
+ li { margin-bottom: 0.8em; }
+ li pre { margin-top: 10px; margin-bottom: 10px; }
+
+ </style>
+</head>
+<body>
+
+<h1>Encrypting a Drive with LUKS and cryptsetup</h1>
+
+<h2>1. Get the drive name</h2>
+<pre><code class="language-shell">lsblk
+</code></pre>
+
+<h2>2. Install cryptsetup</h2>
+<pre><code class="language-shell">sudo pacman -S cryptsetup
+</code></pre>
+
+<h2>3. Format the drive</h2>
+<ul>
+ <li>To format the drive, you can use <code>cfdisk</code> or any other utility of your choice.</li>
+</ul>
+<pre><code class="language-shell">cfdisk /dev/sdaX
+</code></pre>
+<ul>
+ <li>Now, delete all the signatures and partitions on the drive</li>
+ <li>Then, create a filesystem on the drive as follows:</li>
+</ul>
+<pre><code class="language-shell">mkfs.ext4 /dev/sdaX
+</code></pre>
+<ul>
+ <li>After the FS has been created, create a partition on the drive with <code>cfdisk</code></li>
+ <li>After the partition has been created, you can finally start encrypting the drive</li>
+</ul>
+
+<h2>4. Encrypt the created partition</h2>
+<ul>
+ <li>List the partition</li>
+</ul>
+<pre><code class="language-shell">lsblk /dev/sdaX
+</code></pre>
+<ul>
+ <li>Encrypt the partition</li>
+</ul>
+<pre><code class="language-shell">cryptsetup luksFormat /dev/sda[0-9]
+</code></pre>
+<ul>
+ <li>It will ask for a passphrase, make sure to provide a strong passphrase</li>
+</ul>
+
+<h2>5. Decrypt and create filesystem</h2>
+<ul>
+ <li>Decrypt the drive</li>
+</ul>
+<pre><code class="language-shell">cryptsetup open /dev/sda[0-9] &lt;name&gt;
+</code></pre>
+<ul>
+ <li>Make the FS</li>
+</ul>
+<pre><code class="language-shell">mkfs.ext4 /dev/mapper/&lt;name&gt;
+</code></pre>
+
+<h2>6. Re-encrypt after usage</h2>
+<pre><code class="language-shell">cryptsetup close &lt;name&gt;
+</code></pre>
+
+</body>
+</html>