<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>LUKS on Ivon's Blog</title><link>https://ivonblog.com/en-us/tags/luks/</link><description>Recent content in LUKS on Ivon's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</managingEditor><webMaster>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</webMaster><copyright>You are welcome to share articles from Ivon's blog (ivonblog.com). Please cite the source article URL when sharing. All article content is licensed under a Creative Commons Attribution-ShareAlike 4.0 license, unless otherwise stated. For commercial use, please contact me first.</copyright><lastBuildDate>Wed, 17 Aug 2022 01:52:46 +0800</lastBuildDate><atom:link href="https://ivonblog.com/en-us/tags/luks/index.xml" rel="self" type="application/rss+xml"/><follow_challenge><feedId>56005902658351104</feedId><userId>1132431067563556864</userId></follow_challenge><item><title>Use LUKS Disk Encryption to Protect PinePhone Data</title><link>https://ivonblog.com/en-us/posts/pinephone-luks-disk-encryption/</link><pubDate>Wed, 17 Aug 2022 01:52:46 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/pinephone-luks-disk-encryption/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;Some PinePhone Linux distributions already provide Full Disk Encryption in their installers. This can protect your phone data from being read out, but it also increases system complexity.&lt;/p&gt;
&lt;p&gt;The technology used is &amp;ldquo;LUKS&amp;rdquo; encryption. The &lt;a href="https://ivonblog.com/en-us/posts/linux-mobile-distros/" target="_blank" rel="noreferrer"&gt;mobile Linux distributions&lt;/a&gt; that currently have this feature and make it easy to configure are postmarketOS and Mobian. Arch Linux ARM and Manjaro ARM also provide a &lt;a href="https://github.com/dreemurrs-embedded/archarm-mobile-fde-installer" target="_blank" rel="noreferrer"&gt;script&lt;/a&gt; for installation.&lt;/p&gt;
&lt;p&gt;(Images are from &lt;a href="https://gitlab.com/cryptsetup/cryptsetup" target="_blank" rel="noreferrer"&gt;Gitlab&lt;/a&gt; and the official &lt;a href="https://www.pine64.org/pinephone/" target="_blank" rel="noreferrer"&gt;PinePhone&lt;/a&gt; website.)&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://i.imgur.com/hXg549X.jpg"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/unable-to-load-the-image-pepe.webp'"
 &gt;&lt;/figure&gt;
&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Background
 &lt;div id="1-background" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#1-background" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;By default, the PinePhone boots from an SD card. If you insert an SD card with &lt;a href="https://github.com/dreemurrs-embedded/Jumpdrive" target="_blank" rel="noreferrer"&gt;Jumpdrive&lt;/a&gt; and boot from it, the phone&amp;rsquo;s internal partition data is laid bare. Jumpdrive is meant to make system installation easy, and most distributions do not encrypt partitions by default. Convenient, yes. Secure, not really.&lt;/p&gt;</description><content:encoded>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;Some PinePhone Linux distributions already provide Full Disk Encryption in their installers. This can protect your phone data from being read out, but it also increases system complexity.&lt;/p&gt;
&lt;p&gt;The technology used is &amp;ldquo;LUKS&amp;rdquo; encryption. The &lt;a href="https://ivonblog.com/en-us/posts/linux-mobile-distros/" target="_blank" rel="noreferrer"&gt;mobile Linux distributions&lt;/a&gt; that currently have this feature and make it easy to configure are postmarketOS and Mobian. Arch Linux ARM and Manjaro ARM also provide a &lt;a href="https://github.com/dreemurrs-embedded/archarm-mobile-fde-installer" target="_blank" rel="noreferrer"&gt;script&lt;/a&gt; for installation.&lt;/p&gt;
&lt;p&gt;(Images are from &lt;a href="https://gitlab.com/cryptsetup/cryptsetup" target="_blank" rel="noreferrer"&gt;Gitlab&lt;/a&gt; and the official &lt;a href="https://www.pine64.org/pinephone/" target="_blank" rel="noreferrer"&gt;PinePhone&lt;/a&gt; website.)&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://i.imgur.com/hXg549X.jpg"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/unable-to-load-the-image-pepe.webp'"
 &gt;&lt;/figure&gt;
&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Background
 &lt;div id="1-background" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#1-background" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;By default, the PinePhone boots from an SD card. If you insert an SD card with &lt;a href="https://github.com/dreemurrs-embedded/Jumpdrive" target="_blank" rel="noreferrer"&gt;Jumpdrive&lt;/a&gt; and boot from it, the phone&amp;rsquo;s internal partition data is laid bare. Jumpdrive is meant to make system installation easy, and most distributions do not encrypt partitions by default. Convenient, yes. Secure, not really.&lt;/p&gt;
&lt;p&gt;So the only way to get protection is to make sure the phone data remains encrypted even when the phone is plugged into a computer and can be read.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Introduction to LUKS Encryption
 &lt;div id="2-introduction-to-luks-encryption" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#2-introduction-to-luks-encryption" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;According to Red Hat&amp;rsquo;s &lt;a href="https://access.redhat.com/documentation/zh-tw/red_hat_enterprise_linux/6/html/installation_guide/apcs02" target="_blank" rel="noreferrer"&gt;introduction&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Linux Unified Key Setup (LUKS) is a specification for block device encryption. It defines an on-disk format for data and a password/key management policy. LUKS uses the kernel device-mapper subsystem through the dm-crypt module. This provides a low-level mapping layer that can handle encryption and decryption of device data. User-level operations, such as creating and accessing encrypted devices, are performed with the cryptsetup tool.&lt;/p&gt;
&lt;/blockquote&gt;&lt;p&gt;Users can encrypt the current disk. When accessing the disk, the user must enter a password before the disk data can be read as plaintext. The disk can still be decrypted on another computer.&lt;/p&gt;

&lt;h2 class="relative group"&gt;3. Enable Disk Encryption on postmarketOS
 &lt;div id="3-enable-disk-encryption-on-postmarketos" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#3-enable-disk-encryption-on-postmarketos" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;postmarketOS can be installed in two ways: with pmbootstrap, or with an officially built image. The main encrypted partition is &lt;code&gt;pmOS_root&lt;/code&gt;. After disk encryption is enabled, you need to enter the decryption password during boot.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Android phones other than the PinePhone are not guaranteed to support disk encryption. Check the &lt;a href="https://wiki.postmarketos.org/wiki/All_devices" target="_blank" rel="noreferrer"&gt;Devices&lt;/a&gt; table to confirm.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 class="relative group"&gt;3.1. Method One: Build the system files with pmbootstrap
 &lt;div id="31-method-one-build-the-system-files-with-pmbootstrap" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#31-method-one-build-the-system-files-with-pmbootstrap" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;First refer to: &lt;a href="https://ivonblog.com/en-us/posts/postmarketos-general-installation/" target="_blank" rel="noreferrer"&gt;postmarketOS General Installation Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When flashing, add the &lt;code&gt;--fde&lt;/code&gt; option to the command. This enables disk encryption when flashing to the phone:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap install --sdcard&lt;span class="o"&gt;=&lt;/span&gt;/dev/sdb --fde&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 class="relative group"&gt;3.2. Method Two: Flash the official prebuilt Installer
 &lt;div id="32-method-two-flash-the-official-prebuilt-installer" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#32-method-two-flash-the-official-prebuilt-installer" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;First refer to: &lt;a href="https://ivonblog.com/en-us/posts/pinephone-os-installation/" target="_blank" rel="noreferrer"&gt;PinePhone System Installation Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://postmarketos.org/download/" target="_blank" rel="noreferrer"&gt;Download&lt;/a&gt; the image file and choose the installer image.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://i.postimg.cc/gJwtfW7C/Screenshot-2022-04-18-at-23-17-27-v21-12-pine64-pinephone-phosh-20220413-0535-postmarket-OS-Offi.jpg"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/unable-to-load-the-image-pepe.webp'"
 &gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;ol start="2"&gt;
&lt;li&gt;
&lt;p&gt;After flashing, boot the phone, select `Enable Full disk encrpytion``, enter a custom 8-digit password, and install the system.
&lt;img src="https://i.postimg.cc/x8T1WZdH/DSC-0001.jpg" width=200&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From now on, before entering the system during boot, you need to enter the disk password once.
&lt;img src="https://i.postimg.cc/mZ8DQTdS/DSC-0003.jpg" width=200&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 class="relative group"&gt;4. Enable Disk Encryption on Mobian
 &lt;div id="4-enable-disk-encryption-on-mobian" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#4-enable-disk-encryption-on-mobian" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Mobian&amp;rsquo;s installer now provides a disk encryption option.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;First refer to: &lt;a href="https://ivonblog.com/en-us/posts/pinephone-os-installation/" target="_blank" rel="noreferrer"&gt;PinePhone System Installation Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://wiki.mobian.org/doku.php?id=install-linux" target="_blank" rel="noreferrer"&gt;Download&lt;/a&gt; the system image and choose the Installer.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://i.postimg.cc/X7Tjhjzb/Screenshot-2022-04-18-at-23-22-50-install-linux-Mobian-Wiki.png"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/unable-to-load-the-image-pepe.webp'"
 &gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;ol start="2"&gt;
&lt;li&gt;
&lt;p&gt;Flash it. After booting, tap &lt;code&gt;Enable Full disk encrpytion&lt;/code&gt; and set an 8-digit password.
&lt;img src="https://i.postimg.cc/Wpq7fpKs/DSC-0004.jpg" width=200&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After that, you need to enter the disk decryption password at boot.
&lt;img src="https://i.postimg.cc/wTJ03xcw/DSC-0005-2.jpg" width=200&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 class="relative group"&gt;5. How to Remove LUKS Disk Encryption
 &lt;div id="5-how-to-remove-luks-disk-encryption" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#5-how-to-remove-luks-disk-encryption" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Decrypting the partition requires formatting the disk.&lt;/p&gt;
&lt;p&gt;Tow-Boot currently does not support encrypted partitions, so you need to boot with Jumpdrive before the computer can read them. If the computer runs Ubuntu, after plugging in the phone it should prompt for the partition password. After decrypting and mounting it, you can browse the data inside.
&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://i.imgur.com/3Q7xY2h.png"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/unable-to-load-the-image-pepe.webp'"
 &gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;You can confirm the encrypted partition (crypt) with the &lt;code&gt;lsblk&lt;/code&gt; command:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sdc 8:32 &lt;span class="m"&gt;1&lt;/span&gt; 28.9G &lt;span class="m"&gt;0&lt;/span&gt; disk
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├─sdc1 8:33 &lt;span class="m"&gt;1&lt;/span&gt; 243M &lt;span class="m"&gt;0&lt;/span&gt; part /media/ivon/pmOS_boot
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;└─sdc2 8:34 &lt;span class="m"&gt;1&lt;/span&gt; 28.7G &lt;span class="m"&gt;0&lt;/span&gt; part
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; └─luks-55a4bb3f-165b-44ce-a771-fdc914c32b6e
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 253:0 &lt;span class="m"&gt;0&lt;/span&gt; 28.7G &lt;span class="m"&gt;0&lt;/span&gt; crypt&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Back up important data, then open Gparted.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Right-click the PinePhone phone partition and unmount it, delete all partitions, then format it as ext4. For the encrypted partition, after unmounting it, click &amp;ldquo;Cancel encryption&amp;rdquo;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For details, see: &lt;a href="https://ivonblog.com/posts/linux-format-sdcard/" target="_blank" rel="noreferrer"&gt;How to Format an SD Card on Linux&lt;/a&gt;&lt;/p&gt;

&lt;h2 class="relative group"&gt;6. References
 &lt;div id="6-references" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#6-references" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://wiki.postmarketos.org/index.php?title=Full_disk_encryption&amp;amp;mobileaction=toggle_view_desktop" target="_blank" rel="noreferrer"&gt;Full disk encryption - PostmarketOS wiki&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup" target="_blank" rel="noreferrer"&gt;LUKS - Wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item></channel></rss>