trents_blog/site/posts/lmde4-custom-partitions-dis.../index.html

420 lines
23 KiB
HTML
Raw Normal View History

2021-09-10 04:30:02 -07:00
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://blog.trentsonlinedocs.xyz/posts/lmde4-custom-partitions-disk-encryption/">
<link rel="shortcut icon" href="../../img/favicon.ico">
<title>LMDE4 Custom Partitions Disk Encryption - Trent's Blog</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700" />
<link rel="stylesheet" href="../../css/theme.css" />
<link rel="stylesheet" href="../../css/theme_extra.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" />
<link href="../../extra.css" rel="stylesheet" />
<script>
// Current page data
var mkdocs_page_name = "LMDE4 Custom Partitions Disk Encryption";
var mkdocs_page_input_path = "posts/lmde4-custom-partitions-disk-encryption.md";
var mkdocs_page_url = "/posts/lmde4-custom-partitions-disk-encryption/";
</script>
<script src="../../js/jquery-2.1.1.min.js" defer></script>
<script src="../../js/modernizr-2.8.3.min.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../.." class="icon icon-home"> Trent's Blog</a>
<div role="search">
<form id ="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" title="Type search term here" />
</form>
</div>
</div>
2021-09-10 04:30:02 -07:00
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">RSS</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../rss/">RSS</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Links</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../links/">Links</a>
</li>
<li class="toctree-l1"><a class="" href="https://trentpalmer.org">TrentReads</a>
</li>
<li class="toctree-l1"><a class="" href="https://blog.trentpalmer.org">AttentionSpanHistory</a>
</li>
<li class="toctree-l1"><a class="" href="https://github.com/TrentSPalmer">GitHub</a>
</li>
<li class="toctree-l1"><a class="" href="https://twitter.com/boringtrent">Twitter</a>
</li>
<li class="toctree-l1"><a class="" href="https://www.facebook.com/trentspalmer">Facebook</a>
</li>
<li class="toctree-l1"><a class="" href="https://docs.trentsonlinedocs.xyz/">TrentDocs</a>
</li>
<li class="toctree-l1"><a class="" href="https://trentsonlinedocs.xyz/hugo-themes-report/hugo-themes-report.html">HugoThemesReport</a>
</li>
<li class="toctree-l1"><a class="" href="https://play.google.com/store/apps/details?id=org.trentpalmer.libre_gps_parser">LibreGpsParser</a>
</li>
<li class="toctree-l1"><a class="" href="https://concise-pdx.com/">ConcisePDX</a>
</li>
<li class="toctree-l1"><a class="" href="https://trentspalmer.github.io/fcc-challenges/">FreeCodeCampChallenges</a>
</li>
<li class="toctree-l1"><a class="" href="https://trentpalmer.work/6a57bbe24d8244289610bf57533d6c6f/">DeviceLayout</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Posts</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../trents-favorite-podcasts/">Trent's Favorite Podcasts</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../test-qr-svg-django/">Test QRCODE Svg in Django</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../prosody-photo-uploads/">Prosody Photo Uploads</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../xmpp-apt-notifications/">Xmpp Apt Notifications</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../apache-virtual-hosts/">Apache Virtual Hosts</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../sendxmpp-handler-for-python-logging/">SENDXMPPHandler for Python Logging</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../instructions-for-tethering-from-phone/">Instructions For Tethering From Phone</a>
</li>
<li class="toctree-l1 current"><a class="reference internal current" href="./">LMDE4 Custom Partitions Disk Encryption</a>
<ul class="current">
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../linux-move-cursor-with-keyboard/">Linux Move Cursor With Keyboard</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../simplified-raspberry-streaming/">Simplified Raspberry Streaming</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../clear-linux-encrypted-xfs-root/">Clear Linux Encrypted xfs Root</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../clear-linux-guest-virt-manager/">Clear Linux Guest Virt Manager</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../faster-partitioning-with-sgdisk/">Faster Partitioning With sgdisk</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../lmde3-xfs-full-disk-encryption/">LMDE3 xfs Full Disk Encryption</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../rewrite-hugo-themes-report-in-python/">Rewrite Hugo Themes Report in Python</a>
</li>
</ul>
</div>
</div>
</nav>
2021-09-02 14:05:12 -07:00
2021-09-10 04:30:02 -07:00
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
2021-09-02 14:05:12 -07:00
2021-09-10 04:30:02 -07:00
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../..">Trent's Blog</a>
</nav>
2021-09-02 14:05:12 -07:00
2021-09-10 04:30:02 -07:00
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../..">Docs</a> &raquo;</li>
2021-09-02 14:05:12 -07:00
2021-09-10 04:30:02 -07:00
<li>Posts &raquo;</li>
2021-09-02 14:05:12 -07:00
2021-09-10 04:30:02 -07:00
<li>LMDE4 Custom Partitions Disk Encryption</li>
<li class="wy-breadcrumbs-aside">
2021-09-02 14:05:12 -07:00
</li>
</ul>
2021-09-10 04:30:02 -07:00
<hr/>
</div>
<div role="main">
<div class="section">
<p>date: 2020-12-15</p>
<h2 id="introduction"><strong>Introduction</strong></h2>
<p>Linux Mint Debian Edition is the alternate version of Linux Mint, but built on a Debian base. The result is quite pleasant: the
stability of desktop Debian, but with the rough edges polished smooth, nicely configured fonts and ui, and all the multi-media codecs included.</p>
<p>Previously, I wrote a <a href="../lmde3-xfs-full-disk-encryption/" target="_blank">guide for installing LMDE3 with disk encryption</a>.
The installer for LMDE 4 is different
in that it includes support for disk encryption, but not if you need custom partitions such as for a <strong>dual-boot
configuration</strong>.</p>
<p>With this in mind, the examples presented below assume that you have Windows 10 installed in 4 partitions, and
thus you would want to make 3 partitions (5,6,7) after that, for LMDE4.
As with before, with separate partitions for <code>/boot</code> formatted ext4, <code>/boot/efi</code> formatted fat32,
and a regular luks-encrypted partition for <code>/</code> formatted xfs.</p>
<p>With a separate efi partition for LMDE4, you can then use the computer's device boot menu to
select which efi boot entry you want to boot. There is also an advantage in having Windows use the
first efi partition, in that if something happens to the Windows efi boot entry, you can fall back to the
default efi executable. Whereas, if the efi boot entry for Linux somehow gets wiped, you could <a href="https://help.ubuntu.com/community/Grub2/Installing#via_ChRoot" target="_blank">repair that
easily enough via chroot</a>.</p>
<h2 id="prepare-the-installation-media"><strong>Prepare The Installation Media</strong></h2>
<p>Visit the <a href="https://www.linuxmint.com/" target="_blank">Linux Mint Website</a>
and <a href="https://www.linuxmint.com/edition.php?id=279" target="_blank">download</a> the iso file for LMDE 4 64bit. Download from torrents if possible, to save bandwidth.</p>
<ul>
<li>verify the sha256 sum of the iso file
<div class="highlight"><pre><span></span><code><span class="go">sha256sum lmde-4-cinnamon-64bit.iso</span>
</code></pre></div></li>
</ul>
<p>Identify the thumb drive you are going to install from.</p>
<ul>
<li>type <code>lsblk</code>, note the output, and then insert the thumb drive</li>
<li>then type <code>lsblk</code> again and note the <em>additional output</em></li>
</ul>
<p><div class="highlight"><pre><span></span><code><span class="gp"># </span>lsblk /dev/sdb
<span class="go">NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT</span>
<span class="go">sdb 8:32 1 14.5G 0 disk</span>
<span class="go">├─sdb1 8:33 1 3.4G 0 part /media/trent/Debian 9.6.0 amd64</span>
<span class="go">└─sdb2 8:34 1 416K 0 part</span>
</code></pre></div>
In the above example output we see that our thumb drive is identified as <code>/dev/sdb</code>, and partition <code>/dev/sdb1</code> is automatically mounted.</p>
<p>Take special care that you have accurately identified the thumb drive before proceeding. For the sake of example,
we will proceed on the assumption that our thumb drive is identified as <code>/dev/sdb</code>, but you need to compensate accordingly.</p>
<ul>
<li>
<p>unmount any partition of the thumb drive that are automatically mounted
<div class="highlight"><pre><span></span><code><span class="go">umount /dev/sdb1</span>
</code></pre></div></p>
</li>
<li>
<p>write the disk image to the thumb drive
<div class="highlight"><pre><span></span><code><span class="go">ddrescue -D --force lmde-4-cinnamon-64bit.iso /dev/sdb</span>
</code></pre></div></p>
</li>
</ul>
<h2 id="boot-the-install-disc"><strong>Boot The Install Disc</strong></h2>
<ul>
<li>boot into bios to disable fastboot and secureboot</li>
<li>invoke your machine's device boot menu and boot the install disc in uefi mode</li>
<li>confirm that you have booted in uefi mode by listing efivars
<div class="highlight"><pre><span></span><code><span class="go">ls /sys/firmware/efi/vars</span>
</code></pre></div></li>
</ul>
<h2 id="partition-the-hard-drive"><strong>Partition The Hard Drive</strong></h2>
<p>If you recall we are assuming the target hard drive is <code>/dev/sda</code>, as an example. So, make adjustments as necessary.</p>
<p>If you would rather use a different partition tool, make sure the efi partition is an efi partition type, and you definitely need a separate <code>/boot</code> partition.</p>
<p>If indeed, you are installing a dual-boot and are installing alongside another operating system,
then <strong>skip steps 1 and 2</strong>, obviously.</p>
<ol>
<li>if needed you can clear the drive with wipefs
<div class="highlight"><pre><span></span><code><span class="go">wipefs --all /dev/sda</span>
</code></pre></div></li>
<li>create a new partition table for <code>/dev/sda</code>
<div class="highlight"><pre><span></span><code><span class="go">sgdisk /dev/sda -o</span>
</code></pre></div></li>
<li>create a new efi partition for <code>/dev/sda</code>
<div class="highlight"><pre><span></span><code><span class="go">sgdisk /dev/sda --new=5::+512MiB --typecode=1:ef00</span>
</code></pre></div></li>
<li>create a new <code>/boot</code> partition for <code>/dev/sda</code>
<div class="highlight"><pre><span></span><code><span class="go">sgdisk /dev/sda --new=6::+1G</span>
</code></pre></div></li>
<li>create a new <code>/</code> partition for <code>/dev/sda</code>
<div class="highlight"><pre><span></span><code><span class="go">sgdisk /dev/sda --new=7</span>
</code></pre></div></li>
<li>verify your partition work
<div class="highlight"><pre><span></span><code><span class="go">sgdisk /dev/sda -p</span>
</code></pre></div></li>
<li>format the efi partition
<div class="highlight"><pre><span></span><code><span class="go">mkfs.vfat -F32 /dev/sda5</span>
</code></pre></div></li>
<li>format the /boot partition
<div class="highlight"><pre><span></span><code><span class="go">mkfs.ext4 /dev/sda6</span>
</code></pre></div></li>
<li>encrypt the <code>/</code> partition, you will be prompted for a password
<div class="highlight"><pre><span></span><code><span class="go">cryptsetup -y -v luksFormat --type luks2 /dev/sda7</span>
</code></pre></div></li>
<li>decrypt the <code>/</code> partition, you will be prompted for a password
<div class="highlight"><pre><span></span><code><span class="go">cryptsetup open /dev/sda7 cryptroot</span>
</code></pre></div></li>
<li>format the <code>/</code> device
<div class="highlight"><pre><span></span><code><span class="go">mkfs.xfs /dev/mapper/cryptroot</span>
</code></pre></div></li>
</ol>
<h2 id="mount-the-hard-drive"><strong>Mount The Hard Drive</strong></h2>
<p>This takes advantage of <em>expert mode</em> in the LMDE installer.</p>
<ol>
<li>create an <code>/target</code> directory
<div class="highlight"><pre><span></span><code><span class="go">mkdir /target</span>
</code></pre></div></li>
<li>mount the <code>/</code> device at <code>/target</code>
<div class="highlight"><pre><span></span><code><span class="go">mount /dev/mapper/cryptroot /target</span>
</code></pre></div></li>
<li>create an <code>/target/boot</code> directory
<div class="highlight"><pre><span></span><code><span class="go">mkdir /target/boot</span>
</code></pre></div></li>
<li>mount the <code>/boot</code> partition at <code>/target/boot</code>
<div class="highlight"><pre><span></span><code><span class="go">mount /dev/sda6 /target/boot</span>
</code></pre></div></li>
<li>create an <code>/target/boot/efi</code> directory
<div class="highlight"><pre><span></span><code><span class="go">mkdir /target/boot/efi</span>
</code></pre></div></li>
<li>mount the efi partition at <code>/target/boot/efi</code>
<div class="highlight"><pre><span></span><code><span class="go">mount /dev/sda5 /target/boot/efi</span>
</code></pre></div></li>
</ol>
<h2 id="run-the-installer-app-from-command-line"><strong>Run The Installer App From Command Line</strong></h2>
<p>At this point you're ready to run the live installer. But you need to run the
installer from the command line in order to <strong>use expert-mode</strong>:
<div class="highlight"><pre><span></span><code><span class="go">live-installer --expert-mode</span>
</code></pre></div></p>
<p>The first three pages of the live-installer cover Language,Timezone, and Keymap.
The fourth page of the live-installer covers name, password, and hostname. After this
<strong>select manual partitioning</strong>.</p>
<p>On the seventh page of the live-installer, you come to a partition configuration page.
But there is nothing to do here. The partition-configuration doesn't even recognize
your encrypted partitions. But no matter, because you have already mounted the target
file system relative to <code>/target/</code>, so select <em>expert mode</em> at the bottom of the page.</p>
<figure>
<img src=../../photos/Screenshot31.png width="100%" />
<figcaption>the installer doesn't even recognize the encrypted partitions ... ignore everything on this screen and click the `Expert mode` button</figcaption>
</figure>
<p>Again select <em>forward</em>, and when you come to the page where you configure the location
to install grub, that should be the efi partition, i.e. <code>/dev/sda5</code>.</p>
<figure>
<img src=../../photos/Screenshot39.png width="100%" />
<figcaption>select the efi partition as the location to install grub</figcaption>
</figure>
<p>Then continue with the installation. The installation will run for a
few minutes and will then pause. There will be a popup informing you that the installation has paused.
During the pause you need to manually configure <code>fstab</code> and <code>crypttab</code>.</p>
<h2 id="configure-fstab"><strong>Configure Fstab</strong></h2>
<ol>
<li>find the UUID of the efi partition
<div class="highlight"><pre><span></span><code><span class="go">blkid /dev/sda5 -s UUID</span>
</code></pre></div></li>
<li>find the UUID of the <code>/boot</code> partition
<div class="highlight"><pre><span></span><code><span class="go">blkid /dev/sda6 -s UUID</span>
</code></pre></div></li>
<li>find the UUID of the <code>/</code> device
<div class="highlight"><pre><span></span><code><span class="go">blkid /dev/mapper/cryptroot -s UUID</span>
</code></pre></div></li>
</ol>
<p>And when you find the correct UUID numbers, use them to configure <code>/etc/fstab</code> which is actually currently at <code>/target/etc/fstab</code>.
<div class="highlight"><pre><span></span><code># /etc/fstab
###############
# efi partition
# run the command `blkid /dev/sda1 -s UUID` which outputs
# /dev/sda5: UUID=&quot;17C4-215D&quot;, from which derive
UUID=17C4-215D /boot/efi vfat defaults 0 2
# /boot partition
# run the command `blkid /dev/sda2 -s UUID` which outputs
# /dev/sda6: UUID=&quot;f2509fff-4854-4721-b546-0274c89e6aec&quot;, from which derive
UUID=f2509fff-4854-4721-b546-0274c89e6aec /boot ext4 defaults 0 2
# &quot;/&quot; device
# run the command `blkid /dev/mapper/cryptroot -s UUID` which outputs
# /dev/mapper/cryptroot: UUID=&quot;72241377-cd65-43a6-8363-1afce5bd93f6&quot;, from which derive
UUID=72241377-cd65-43a6-8363-1afce5bd93f6 / xfs defaults 0 1
</code></pre></div></p>
<h2 id="configure-crypttab"><strong>Configure Crypttab</strong></h2>
<p>But before the file systems can be mounted, <code>crypttab</code> needs to mount <code>/dev/sda3</code> at <code>/dev/mapper/cryptroot</code>.
Configure <code>/etc/crypttab</code> which is actually currently at <code>/target/etc/crypttab</code></p>
<p>Sorry, that's actually an over-simplification. But you need to configure <code>crypttab</code> now,
because when the installer continues running again, it installs the bootloader and builds the initramfs,
and <code>mkinitramfs</code> parses <code>crypttab</code>, and builds and configures the initramfs in such a way that it knows
to decrypt your <code>/</code> partition so it can then hand it off to the kernel at boot time (I think).</p>
<ul>
<li>find the UUID of the partition that will be mounted at <code>/dev/mapper/crypttab</code>
<div class="highlight"><pre><span></span><code><span class="go">blkid /dev/sda3 -s UUID</span>
</code></pre></div></li>
</ul>
<p>And when you find the correct UUID number for <code>/dev/sda3</code>,
use that to configure <code>/etc/crypttab</code> which is actually currently at <code>/target/etc/crypttab</code>.
<div class="highlight"><pre><span></span><code># /etc/crypttab
# run the command `blkid /dev/sda7 -s UUID` which outputs
# /dev/sda7: UUID=&quot;da3e0967-711f-4159-85ac-7d5743a75201&quot;, from which derive
# &lt;target name&gt; &lt;source device&gt; &lt;key file&gt; &lt;options&gt;
cryptroot UUID=da3e0967-711f-4159-85ac-7d5743a75201 none luks
</code></pre></div></p>
<h2 id="resume-installer-app"><strong>Resume Installer App</strong></h2>
<p>At this point finish running the live installer, and you'll be done.</p>
<h2 id="uefi-fix"><strong>UEFI Fix</strong></h2>
<p>Well, actually there isn't one. In this scenario having two efi partitions,
we rely on the motherboard correctly persisting efi boot entries.</p>
<p>So if you are unlucky enough to have one of the HP laptops that
<em>forgets</em> efi boot entries, I guess you are out of luck.</p>
<p>You might try using a single efi partition instead of two, and
maybe that will work. Presumably this would require using VeraCrypt
for Windows, instead of Bitlocker (because Bitlocker won't allow Grub
to load the Windows bootloader?)</p>
<h2 id="optional-swap-file"><strong>Optional Swap File</strong></h2>
<p>Visit the <a href="https://wiki.archlinux.org/index.php/Swap#Swap_file" target="_blank">Arch Wiki</a> and they will hook you up.</p>
</div>
</div>
2021-09-10 04:30:02 -07:00
<footer>
2021-09-10 04:30:02 -07:00
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
2021-09-10 04:30:02 -07:00
<a href="../linux-move-cursor-with-keyboard/" class="btn btn-neutral float-right" title="Linux Move Cursor With Keyboard">Next <span class="icon icon-circle-arrow-right"></span></a>
2021-09-10 04:30:02 -07:00
<a href="../instructions-for-tethering-from-phone/" class="btn btn-neutral" title="Instructions For Tethering From Phone"><span class="icon icon-circle-arrow-left"></span> Previous</a>
2021-09-02 13:52:37 -07:00
2021-09-10 04:30:02 -07:00
</div>
<hr/>
<div role="contentinfo">
<!-- Copyright etc -->
2021-09-02 13:52:37 -07:00
</div>
2021-09-10 04:30:02 -07:00
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
2021-09-10 04:30:02 -07:00
</div>
</div>
</section>
</div>
<div class="rst-versions" role="note" aria-label="versions">
<span class="rst-current-version" data-toggle="rst-current-version">
2021-09-10 04:30:02 -07:00
<span><a href="../instructions-for-tethering-from-phone/" style="color: #fcfcfc">&laquo; Previous</a></span>
2021-09-10 04:30:02 -07:00
<span><a href="../linux-move-cursor-with-keyboard/" style="color: #fcfcfc">Next &raquo;</a></span>
</span>
</div>
<script>var base_url = '../..';</script>
<script src="../../js/theme_extra.js" defer></script>
<script src="../../js/theme.js" defer></script>
<script src="../../search/main.js" defer></script>
<script defer>
window.onload = function () {
SphinxRtdTheme.Navigation.enable(true);
};
</script>
</body>
</html>