<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Encryption &#8211; bablick.de</title>
	<atom:link href="https://bablick.de/tag/encryption/feed/" rel="self" type="application/rss+xml" />
	<link>https://bablick.de</link>
	<description>Writing About Clusters, Curiosity, and Everything in Between.</description>
	<lastBuildDate>Sat, 20 Sep 2025 22:53:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://bablick.de/wp-content/uploads/2025/08/cropped-BablickLogo-1-32x32.png</url>
	<title>Encryption &#8211; bablick.de</title>
	<link>https://bablick.de</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Additional LUKS Encrypted Devices on Encryped Debian Trixie</title>
		<link>https://bablick.de/additional-luks-encrypted-devices-on-encryped-debian-trixie/</link>
		
		<dc:creator><![CDATA[ernst.bablick]]></dc:creator>
		<pubDate>Sun, 24 Aug 2025 13:15:11 +0000</pubDate>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[LUKS]]></category>
		<guid isPermaLink="false">https://bablick.de/?p=80</guid>

					<description><![CDATA[My notebook runs a fully encrypted version of Debian 13 (including the root filesystem and SWAP). Now it&#8217;s time to activate a second NVMe device. This should also be encrypted, but I don&#8217;t want to have to specify the passphrase for that device every time I reboot. Instead, the key file should be located on...]]></description>
										<content:encoded><![CDATA[
<p>My notebook runs a fully encrypted version of Debian 13 (including the root filesystem and SWAP). Now it&#8217;s time to activate a second NVMe device. This should also be encrypted, but I don&#8217;t want to have to specify the passphrase for that device every time I reboot. Instead, the key file should be located on the root partition of the first device.</p>



<h1 class="wp-block-heading">Setup Steps</h1>



<h2 class="wp-block-heading">Preparing the Device (Repartitioning)</h2>



<ul class="wp-block-list">
<li>The NVMe device name can change during a reboot of a Linux system. For example, what was previously <strong>/dev/nvme1n1</strong> could now be <strong>/dev/nvme0n1</strong>, or vice versa. The <strong>lsblk -f</strong> command is useful for distinguishing between devices that have already been used and those that have just been added.</li>
</ul>



<ul class="wp-block-list">
<li><strong>wipefs</strong> removes old partitions/signatures for a device</li>
</ul>



<pre class="wp-block-code has-small-font-size"><code><strong>sudo wipefs -a /dev/nvme1n1</strong>
/dev/nvme1n1: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
/dev/nvme1n1: 8 bytes were erased at offset 0xe8e0db5e00 (gpt): 45 46 49 20 50 41 52 54
/dev/nvme1n1: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
/dev/nvme1n1: calling ioctl to re-read partition table: Success</code></pre>



<ul class="wp-block-list">
<li>Although there are other tools that can manipulate partition tables, I still use <strong>fdisk</strong> to create a single large partition on the disk. The <strong>fdisk</strong> suggestions help to create a partition with the correct alignment, which prevents performance issues or error messages in the subsequent steps. The (g) command creates a new GPT. (p) prints the partition table. (n) triggers the creation of a new partition. (t) allows you to specify a partition type, and (w) makes the data persistent by writing the information to the disk.</li>
</ul>



<pre class="wp-block-code has-small-font-size"><code><strong>sudo fdisk /dev/nvme1n1</strong>
Command (m for help): <strong>g</strong>
Created a new GPT disklabel (GUID: AC0EB50D-4E46-46C7-892D-BEE19E49E76F).

Command (m for help): <strong>p</strong>
Disk /dev/nvme1n1: 931,51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Samsung SSD 990 EVO 1TB                 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: AC0EB50D-4E46-46C7-892D-BEE19E49E76F

Command (m for help): <strong>n</strong>
Partition number (1-128, default 1):
Partition number (1-128, default 1): 
First sector (2048-1953525134, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1953525134, default 1953523711): 
Created a new partition 1 of type 'Linux filesystem' and of size 931,5 GiB.

Command (m for help): <strong>p</strong>
Disk /dev/nvme1n1: 931,51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Samsung SSD 990 EVO 1TB                 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: AC0EB50D-4E46-46C7-892D-BEE19E49E76F
Device         Start        End    Sectors   Size Type
/dev/nvme1n1p1  2048 1953523711 1953521664 931,5G Linux filesystem

Command (m for help): <strong>w</strong>
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.</code></pre>



<h2 class="wp-block-heading">Encryption with LUKS/LUKS2</h2>



<ul class="wp-block-list">
<li>The new partition should be LUKS-encrypted. Rather than using device names such as /dev/nvme…, I would like to identify the partition by a UUID. To this end, I will generate a new ID with <strong>uuidgen</strong> to pass to <strong>cryptsetup</strong>. The passphrase for the encryption must be specified, and <strong>lsblk</strong> can be used to verify the result.</li>
</ul>



<pre class="wp-block-code has-small-font-size"><code><strong>uuidgen</strong>
168b9568-0540-40b8-b939-882be97eb6bb

<strong>cryptsetup luksFormat -q --type luks --sector-size 4096 --cipher aes-xts-plain64 --key-size 256 --uuid 168b9568-0540-40b8-b939-882be97eb6bb --pbkdf argon2i /dev/nvme1n1p1</strong>

<strong>lsblk -f</strong>
...</code></pre>



<ul class="wp-block-list">
<li>The partition can now be opened. I chose the <strong>/dev/disk/by-uuid/…</strong> path for the device, and the device name will also later be available by the name <strong>UUID</strong>, prefixed by &#8216;<strong>luks-</strong>&#8216;, as with the other partitions initially created by the Debian installer. The <strong>ls</strong> command on <strong>/dev/mapper</strong> shows that the partition is available after entering the correct passphrase.</li>
</ul>



<pre class="wp-block-code has-small-font-size"><code><strong>sudo cryptsetup luksOpen --persistent --allow-discards --perf-no_write_workqueue --perf-no_read_workqueue /dev/disk/by-uuid/168b9568-0540-40b8-b939-882be97eb6bb luks-168b9568-0540-40b8-b939-882be97eb6bb</strong>
Enter passphrase for /dev/disk/by-uuid/168b9568-0540-40b8-b939-882be97eb6bb:

<strong>ls -la /dev/mapper/</strong>
...
lrwxrwxrwx  1 root root       7 24. Aug 00:56 luks-168b9568-0540-40b8-b939-882be97eb6bb -&gt; ../dm-2
</code></pre>



<h2 class="wp-block-heading">Opening/Mounting the Device</h2>



<ul class="wp-block-list">
<li>Once a partition has been encrypted, it must be activated/opened during the boot process so that it can be used. For the root partition and SWAP of a Debian system, this is done early by GRUB, even before the OS is running. For other partitions, such as our new one, <strong>systemd</strong> will perform this task. This step must be enabled by installing the necessary package.</li>
</ul>



<pre class="wp-block-code"><code><strong>sudo apt install systemd-cryptsetup</strong></code></pre>



<ul class="wp-block-list">
<li>Systemd also asks for a passphrase during the boot process, but I want a separate key file that <strong>systemd</strong> can automatically use to open the encrypted device.</li>



<li><strong>dd</strong> creates a key file containing random data. Access permissions for this file are restricted using the <strong>chmod</strong> command. The key is then added to the list of authorized keys that can access the device, which requires entering the initial passphrase. Finally, the status is dumped so that it can be verified.</li>
</ul>



<pre class="wp-block-code has-small-font-size"><code><strong>sudo dd if=/dev/urandom of=/crypto_keyfile_home.bin bs=512 count=8</strong>
<strong>
sudo chmod 600 /crypto_keyfile_home.bin</strong>
<strong>
sudo cryptsetup luksAddKey /dev/nvme1n1p1 /crypto_keyfile_home.bin</strong>
<strong>
sudo cryptsetup luksDump /dev/nvme1n1p1</strong></code></pre>



<ul class="wp-block-list">
<li>In order for <strong>systemd</strong> to recognize the new device, the <strong>/etc/crypttab</strong> file must be updated with a new entry (in one line).</li>
</ul>



<pre class="wp-block-code" style="font-size:13px"><code><strong>sudo vi /etc/crypttab</strong>
...
luks-168b9568-0540-40b8-b939-882be97eb6bb UUID=168b9568-0540-40b8-b939-882be97eb6bb	/crypto_keyfile_home.bin luks,discard,keyscript=/bin/cat</code></pre>



<ul class="wp-block-list">
<li>After rebooting, the <strong>ls</strong> command should show that all three encrypted devices are ready.</li>
</ul>



<pre class="wp-block-code has-small-font-size"><code><strong>ls -la /dev/mapper/</strong>
....
lrwxrwxrwx  1 root root       7 23. Aug 16:29 luks-011bd881-8ec3-4a12-91df-52e1928539fb -&gt; ../dm-1
lrwxrwxrwx  1 root root       7 24. Aug 00:56 luks-168b9568-0540-40b8-b939-882be97eb6bb -&gt; ../dm-2
lrwxrwxrwx  1 root root       7 23. Aug 16:29 luks-45cabb59-0bb5-4737-b6c9-6007657d7a27 -&gt; ../dm-0</code></pre>



<ul class="wp-block-list">
<li>The device can now be formatted and mounted …</li>
</ul>



<p></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
