<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Git on mapletree.moe</title><link>https://mapletree.moe/tags/git/</link><description>Recent content in Git on mapletree.moe</description><generator>Hugo -- 0.160.1</generator><language>en-us</language><copyright>This work is licensed under the MIT0 License.</copyright><lastBuildDate>Sun, 09 Dec 2018 17:00:00 -0600</lastBuildDate><atom:link href="https://mapletree.moe/tags/git/index.xml" rel="self" type="application/rss+xml"/><item><title>ThothBackup: Part 3</title><link>https://mapletree.moe/posts/thothbackup-part-3/</link><pubDate>Sun, 09 Dec 2018 17:00:00 -0600</pubDate><author>bakayuki</author><guid>https://mapletree.moe/posts/thothbackup-part-3/</guid><description>&amp;lt;no value&amp;gt;</description><content type="text/html" mode="escaped"><![CDATA[<h1 id="thothbackup-project-series">ThothBackup Project Series<a href="#thothbackup-project-series" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p><strong>EDIT (2026/04/25):</strong> <em>As part of bringing the contents of the old blog back
online, some things needed to be moved around. ThothBackup was originally a
series of blog posts plus a dedicated project on the blog that was supposed to
be completed, and never was. As much as could be preserved, was.</em></p>
<ul>
<li><a href="/posts/thothbackup-part-0">ThothBackup: Part 0</a></li>
<li><a href="/posts/thothbackup-stage-0">ThothBackup: Stage 0</a></li>
<li><a href="/posts/thothbackup-part-1">ThothBackup: Part 1</a></li>
<li><a href="/posts/thothbackup-part-2">ThothBackup: Part 2</a></li>
<li>ThothBackup: Part 3 <strong>(You are here.)</strong></li>
</ul>
<p>So, another week has gone, and it is time to update this blog with what I have
learned. Unfortunately, experiments were not able to be run this week in the
realm of data transfer. I decided to revisit the base system to focus on
encrypting backup data while it is at rest on the system. This was one of the
remaining security vulnerabilities with this process. While end-users still have
to trust <em>me</em>, they can at least be assured the data is encrypted at rest.</p>
<p>Essentially, if the system was ever stolen, or our apartment door was broken
down, we would just have to cut power and the data would be good. With that
previous statement, please keep in mind that this week&rsquo;s post only refers to the
root drive. I didn&rsquo;t make much progress because of things happening at work, but
this is a nice, strong, foundation to build upon.</p>
<p>Many of the steps in this post were cobbled together from various sources across
the internet. At the bottom of this post you can find a works cited that will
show the posts that I used to gather the appropriate information.</p>
<h1 id="end-goal">End Goal<a href="#end-goal" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>The end goal is to ensure that the operating system&rsquo;s root drive is encrypted at
rest. Full Disk Encryption is <em>not</em> an active security measure, it is a passive
one. It is primarily there to ensure that should the system ever be stolen, it
would not be readable. The root partition will not host any user data, so the
encryption should be transparent and seamless.</p>
<p>In short, we will utilize a USB key to provide a Keyfile which will then be
combined with LUKS encryption to unlock the LVM array to allow the initramfs to
hand over control to the operating system.</p>
<h1 id="notes">Notes<a href="#notes" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>Because we are using a solid state drive, and we will be filling the drive with
data, it was important for me to over-provision the drive. The SSD we&rsquo;re using
comes with 240GB of space. We can assume that there is some form of manufacturer
over-provisioning in play to get that number, if I had to guess I would assume
there is actually 256GB of NAND memory on the drive, but only 240GB are made
available to the user. This is a fairly reasonable level of over-provisioning.</p>
<p>However, with us planning to fill the drive with pseudorandom data in order to
obfuscate the amount of data actually in use, this 16GB could potentially be
used quite quickly. SSDs cannot actually rewrite sectors on the fly, they have
to run a READ/ERASE/WRITE cycle. This is typically done by writing the new block
to an over-provisioned area and then pointing the drive&rsquo;s firmware at that
block. In this way we avoid the ERASE penalty, which can be on the order of 0.5
seconds per block.</p>
<p>Essentially then, every single write to the drive will require a
READ/ERASE/WRITE cycle, so padding the over-provisioning is a very good idea. It
will help with wear leveling and prevent severe write amplification, while also
making the drive &ldquo;feel&rdquo; faster.</p>
<h1 id="prior-work">Prior Work<a href="#prior-work" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>Before we get into the new installation, we need to prepare the drive for its
new role. Unless the flash cells are at their default state, the firmware will
regard them as holding data and will not utilize them for wear leveling, thus
rendering the over-provisioning useless.</p>
<p>To begin, boot the system via a Debian Live-CD and open up a root prompt using
<code>sudo</code>.</p>
<p>If you, like me, prefer to work remotely, you will then need to run a sequence
of commands to prep the system for SSH access. We need to add a password to the
liveCD user, then install openSSH, and finally start the service. Once all of
this is complete, you can log in from a more comfortable system.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">apt-get update
</span></span><span class="line"><span class="cl">apt-get install openssh-server
</span></span><span class="line"><span class="cl">passwd user
</span></span><span class="line"><span class="cl">systemctl start sshd
</span></span></code></pre></div><p>We will need to install one last software package, <code>hdparm</code>. Run
<code>apt-get install hdparm</code> to grab it. Once you have done so, run
<code>hdparm -I /dev/sda</code>. Under &ldquo;Security&rdquo; you are looking for the words &ldquo;<strong>not</strong>
frozen&rdquo;. If it says frozen, and you are working remotely, you will need to
access the physical console to suspend/resume the machine. This should
unfreeze access to the ATA security system.</p>
<p>The first thing we need to do is to run an ATA Enhanced Erase. After this is
done, I still like to run <code>blkdiscard</code> just to make sure every sector has been
marked as empty. Finally, we will use <code>hdparm</code> to mark a host-protected-area,
which the drive firmware will be able to use as an over-provisioning space.
To calculate the HPA size, figure out what size you want to be available to
<em>you</em>. Convert that into bytes, and divide by 512, which is the sector size.
This will give you the number to pass to <code>hdparm</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">hdparm --user-master u --security-set-pass Eins /dev/sda
</span></span><span class="line"><span class="cl">hdparm --user-master u --security-erase-enhanced Eins /dev/sda
</span></span><span class="line"><span class="cl">blkdiscard /dev/sda
</span></span><span class="line"><span class="cl">hdparm -Np390625000 --yes-i-know-what-i-am-doing /dev/sda
</span></span><span class="line"><span class="cl">reboot
</span></span></code></pre></div><p>Once this is done <strong>reboot immediately</strong>. There is a lot that can go wrong if
you fail to reboot. At this point, I swapped out my disk for the Debian
installer. If you are doing this on your own 2006-2008 MacMini, you may want
to use the AMD64-mac ISO that the Debian project provides.</p>
<p>From here, we just have to confirm that the drive shows up how we want in the
installer (200GB in size, in my case), and we can proceed with the installation.</p>
<h1 id="installation">Installation<a href="#installation" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>Most of the Debian installation process is self explanatory. The only point
where I will interject is partitioning. Because of the way the MacMini2,1
boots, it is important that we use an MBR based grub installation. You <em>can</em> do
a 32bit EFI installation, but it is very fragile, and I&rsquo;m not a fan of fragile
things. That being said, I still wanted the ability to use GPT partitions. I
like being able to label everything from the partition up to the individual
filesystems.</p>
<p>Accomplishing this is actually fairly easy anymore. You just need to create a
1MB <code>grub_bios</code> partition as part of your scheme and you&rsquo;re good to go. To get
the level of control we need, we will select manual partitioning when prompted
to set up our partitions in the installer.</p>
<p>Create a new partition table (This will default to GPT), and then lay out your
initial partition layout. It will look something like this:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">&lt;PART #&gt;  &lt;SIZE&gt;  &lt;NAME&gt;          &lt;FILESYSTEM&gt;  &lt;FLAGS&gt;
</span></span><span class="line"><span class="cl">#1        1MB     BIOS_PARTITION  none          grub_bios
</span></span><span class="line"><span class="cl">#2        1GB     BOOT_PARTITION  ext4          bootable
</span></span><span class="line"><span class="cl">#3        199GB   ROOT_PARTITION  crypto        crypto
</span></span></code></pre></div><p>When you select &ldquo;Physical Volume For Encryption&rdquo; it will prompt you to configure
some features. You can customize the partition there, but I actually wanted more
options than the GUI provided, so I accepted the defaults and planned to
re-encrypt later. Please make sure to allow the installer to write encrypted
data to the partition. Since we have already set up a customized HPA, a
potential attacker already knows the maximum amount of cipher text that can
be present, and if the HPA is disabled they would likely be able to gain
access to more. Therefore, it is important that we take every possible
precaution.</p>
<p>Once this is done, you should scroll to the top where it will say &ldquo;Configure
Encryption&rdquo; or something similar. Select this option, then select the physical
volume we just set up, and it should drop you back to the partitioning menu.
This time, however, you will be able to see the newly unlocked crypto partition
as something that we can further customize.</p>
<p>Select that volume and partition it like so:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">&lt;PART #&gt;  &lt;SIZE&gt;  &lt;NAME&gt;          &lt;FILESYSTEM&gt;  &lt;FLAGS&gt;
</span></span><span class="line"><span class="cl">#1        199GB                   none          lvm
</span></span></code></pre></div><p>The LVM option will show up in the menu as &ldquo;Physical Volume for LVM.&rdquo; From here,
we go back up to the top of our menu and select &ldquo;Configure Logical Volume
Manager.&rdquo; You will then be taken to a new screen where it should show that you
have one <code>PV</code> available for use. Create a new volume group that fills the entire
<code>PV</code> and name it as you would like. For this project, I named it <code>djehuti-root</code>
and completed setup.</p>
<p>Next we need to create a Logical Volume for each partition that you would like
to have. For me, this looked like the following:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">&lt;Logical Volume&gt;  &lt;Size&gt;  &lt;Name&gt;
</span></span><span class="line"><span class="cl">#1                30GB    root-root
</span></span><span class="line"><span class="cl">#2                25GB    root-home
</span></span><span class="line"><span class="cl">#3                10GB    root-opt
</span></span><span class="line"><span class="cl">#4                05GB    root-swap
</span></span><span class="line"><span class="cl">#5                05GB    root-tmp
</span></span><span class="line"><span class="cl">#6                10GB    root-usr-local
</span></span><span class="line"><span class="cl">#7                10GB    root-var
</span></span><span class="line"><span class="cl">#8                05GB    root-var-audit
</span></span><span class="line"><span class="cl">#9                05GB    root-var-log
</span></span><span class="line"><span class="cl">#10               05GB    root-var-tmp
</span></span></code></pre></div><p>Your layout may be similar. Once this is done, you can exit out and you will
see that all of your logical volumes are now available for formatting. Since I
wanted to stick with something stable, and most importantly resizable (more on
why later), I picked <code>ext4</code> for all of my partitioning. We will tweak mount
options later. For now, the end product looked like the following:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">&lt;PARTITION&gt;                       &lt;FS&gt;    &lt;MOUNT POINT&gt; &lt;MOUNT OPTIONS&gt;
</span></span><span class="line"><span class="cl">/dev/sda2                         ext4    /boot         defaults
</span></span><span class="line"><span class="cl">/dev/djehuti-root/root-root       ext4    /             defaults
</span></span><span class="line"><span class="cl">/dev/djehuti-root/root-home       ext4    /home         defaults
</span></span><span class="line"><span class="cl">/dev/djehuti-root/root-opt        ext4    /opt          defaults
</span></span><span class="line"><span class="cl">/dev/djehuti-root/root-swap       swapfs  none          defaults
</span></span><span class="line"><span class="cl">/dev/djehuti-root/root-tmp        ext4    /tmp          defaults
</span></span><span class="line"><span class="cl">/dev/djehuti-root/root-usr-local  ext4    /usr/local    defaults
</span></span><span class="line"><span class="cl">/dev/djehuti-root/root-var        ext4    /var          defaults
</span></span><span class="line"><span class="cl">/dev/djehuti-root/root-var-audit  ext4    /var/audit    defaults
</span></span><span class="line"><span class="cl">/dev/djehuti-root/root-var-log    ext4    /var/log      defaults
</span></span><span class="line"><span class="cl">/dev/djehuti-root/root-var-tmp    ext4    /var/tmp      defaults
</span></span></code></pre></div><p>Once everything is setup appropriately, follow through the installation until
you get to the <code>task-sel</code> portion. You really only want to install an ssh server
and the standard system utilities pack. Once the installation completes, reboot
into your server and make sure everything boots appropriately. We&rsquo;re going to be
doing some offline tweaking after this point, so ensuring that everything is
functioning as is will save you a lot of headache.</p>
<p>Once you are satisfied the initial installation is functioning and booting
correctly, it is time to move on to re-encrypting the partition with our own
heavily customized parameters.</p>
<h1 id="re-encryption">Re-Encryption<a href="#re-encryption" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>This process isn&rsquo;t so much difficult as it is simply time consuming. Go ahead
and reboot your system to the boot media selection screen. You will want to
swap out your Debian Installation CD for the Debian LiveCD that we used earlier.
Once the disks have been swapped, boot into the live environment and then
bring up a shell. We will first need to install the tools that we will use, and
then run the actual command. The command is actually fairly self explanatory,
so I won&rsquo;t explain that, but I will explain the reasoning behind the parameters
below.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">apt-get update
</span></span><span class="line"><span class="cl">apt-get install cryptsetup
</span></span><span class="line"><span class="cl">cryptsetup-reencrypt /dev/sda3 --verbose --use-random --cipher serpent-xts-plain64 --key-size <span class="m">512</span> --hash whirlpool --iter-time &lt;higher number&gt;
</span></span></code></pre></div><p>So, onto the parameters:</p>
<ul>
<li><em>cipher</em> - I picked Serpent because it is <a href="https://en.wikipedia.org/wiki/Serpent_(cipher)">widely acknowledged</a> to be a
more &ldquo;secure&rdquo; cipher. Appropriate text from the above link is as follows:
&ldquo;The official NIST report on AES competition classified Serpent as having <strong>a
high security margin</strong> along with MARS and Twofish, <strong>in contrast to the
adequate security margin of RC6 and Rijndael (currently AES)</strong>.&rdquo; The speed
trade-off was negligible for me, as the true bottleneck in the system will be
network speed, not disk speed.</li>
<li><em>key-size</em> - The XTS algorithm requires double the number of bits to
achieve the same <a href="https://en.wikipedia.org/wiki/Disk_encryption_theory#XTS">level of security</a>. Therefore, 512 bits are required to
achieve an AES-256 level of security.</li>
<li><em>hash</em> - In general, I prefer hashes that have actually had extensive
cryptanalysis performed to very high round counts. The best example of an
attack on whirlpool, with a worst case situation where the attacker controls
almost all aspects of the hash, the time complexity is still 2^128th on 9.5
of 10 rounds. This establishes a <em>known</em> time to break of over 100 years.</li>
<li><em>iter-time</em> - The higher your iteration time, the longer it takes to
unlock, but it also makes it harder to break the hash function. So if we
combine what we know above with a large iteration time, we gain fairly strong
security at the expense of a long unlock time when using a passphrase.</li>
</ul>
<p>Once these specifications have been entered, you simply need to press enter and
sit back and relax as the system handles the rest. Once this process is
complete, you should once again reset and boot into the system to verify that
everything is still working as intended. If it is, you are ready for the next
step, which is automating the unlock process.</p>
<h1 id="auto-decryption">Auto-Decryption<a href="#auto-decryption" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>There are a few ways to handle USB key based auto-decryption. The end goal is
to actually use a hardware security module to do this, and I don&rsquo;t anticipate
the FBI busting down my door any time soon for hosting the data of my friends
and family, so I opted for one that is easily extendable.</p>
<p>Essentially, the key will live on an <code>ext4</code> filesystem. It will be a simple
hidden file, so nothing extremely complex to find. This shouldn&rsquo;t be considered
secure at <em>this point</em>, but it is paving the way to a slightly more secure
future.</p>
<p>The first thing that I did, though it isn&rsquo;t strictly necessary, is write random
data to the entire USB stick. In my case, the USB drive could be found at
<code>/dev/sdb</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">dd <span class="k">if</span><span class="o">=</span>/dev/urandom <span class="nv">of</span><span class="o">=</span>/dev/sdb <span class="nv">status</span><span class="o">=</span>progress <span class="nv">bs</span><span class="o">=</span>1M
</span></span></code></pre></div><p>Once this is done, we&rsquo;ve effectively destroyed the partition table. We will
recreate a GPT table, and then create a partition that fills the usable space
of the drive.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">apt update
</span></span><span class="line"><span class="cl">apt install parted
</span></span><span class="line"><span class="cl">parted /dev/sdb
</span></span><span class="line"><span class="cl"><span class="o">(</span>parted<span class="o">)</span> mklabel gpt
</span></span><span class="line"><span class="cl"><span class="o">(</span>parted<span class="o">)</span> mkpart KEYS ext4 0% 100%
</span></span><span class="line"><span class="cl"><span class="o">(</span>parted<span class="o">)</span> quit
</span></span></code></pre></div><p>Now we just create the filesystem, a mount point for the filesystem, and make
our new LUKS keyfile. Once the file has been created, we just add it to the
existing LUKS header.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">mkfs.ext4 -L KEYS /dev/sdb1
</span></span><span class="line"><span class="cl">mkdir /mnt/KEYS
</span></span><span class="line"><span class="cl">mount <span class="nv">LABEL</span><span class="o">=</span>KEYS /mnt/KEYS
</span></span><span class="line"><span class="cl">dd <span class="k">if</span><span class="o">=</span>/dev/random <span class="nv">of</span><span class="o">=</span>/mnt/KEYS/.root_key <span class="nv">bs</span><span class="o">=</span><span class="m">1</span> <span class="nv">count</span><span class="o">=</span><span class="m">4096</span> <span class="nv">status</span><span class="o">=</span>progress
</span></span><span class="line"><span class="cl">cryptsetup luksAddKey /dev/sda3 /mnt/KEYS/.root_key
</span></span></code></pre></div><p>After this point, the setup diverges a bit depending on what guide you follow.
We will stick close to the guide posted to the Debian mailing list for now, as
that guide got me a successful boot on the first try. The others are slightly
more elegant looking, but at the expense of added complexity. As such, they may
end up being the <em>final</em> configuration, but for this prototyping phase they are
a bit excessive.</p>
<p>We have to modify the <code>crypttab</code> file to enable the keyfile to be loaded off of
our freshly set up key drive.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">sda3_crypt  UUID=&#34;...&#34;  /dev/disk/by-label/KEYS:/.root_key:5  luks,initramfs,keyscript=/lib/cryptsetup/scripts/passdev,tries=2
</span></span></code></pre></div><p>At this point, we need to repackage our startup image, update grub, and reboot
to test the whole package.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">update-initramfs -tuck all
</span></span><span class="line"><span class="cl">update-grub
</span></span><span class="line"><span class="cl">reboot
</span></span></code></pre></div><p>At this point the system should boot automatically, but you will notice a weird
<code>systemd</code> based timeout that happens. This is mentioned in the guide posted to
the Debian Stretch mailing list, and is fairly easy to solve. We just need to
create an empty service file to prevent <code>systemd</code> from doing it&rsquo;s own thing.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">touch <span class="s2">&#34;/etc/systemd/system/systemd-cryptsetup@sda3_crypt.service&#34;</span>
</span></span><span class="line"><span class="cl">reboot
</span></span></code></pre></div><p>At this point, everything should boot correctly and quickly. You may notice a
few thrown errors, but it shouldn&rsquo;t be anything severe, more services loading
out of order.</p>
<p>It used to be possible to allow for the creation of a fallback in the event
that the key drive wasn&rsquo;t present, but that seems to have been removed. I plan
to look into it further when I have more time.</p>
<h1 id="conclusion">Conclusion<a href="#conclusion" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>This concludes the first part of the Operating System setup process. The next
step was originally planned to be thin-provisioning the partitions inside the
<code>djehuti-root</code> volume group, but there seems to be some problems in getting
the system to boot from a thin-provisioned root. I&rsquo;m looking into a weird
combined system, where the root is static but all the accessory partitions are
thinly provisioned, but it will take time to tinker with this and report back.</p>
<p>Thin Provisioning isn&rsquo;t strictly required, but it is a rather neat feature and
I like the idea of being able to create more partitions than would technically
fit. I&rsquo;m not sure when this would be useful, but we will see.</p>
<p>Once all of this is finalized, we will move on to hardening the base system,
and last but not least creating the Stage 1 Project page. Then it is back to
experiments with data synchronization. This is a fairly large step back in
progress, but I am hopeful it will result in a better end product, where
security can be dynamically updated as needed.</p>
<h1 id="works-cited">Works Cited<a href="#works-cited" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>The following sources were invaluable in cobbling this process together. I
sincerely thank the authors both for figuring the process out and documenting
the process online.</p>
<ul>
<li><a href="https://lists.debian.org/debian-user/2017/12/msg00523.html">Debian Stretch - USB Keyfile with LUKS</a></li>
<li><a href="https://wiki.archlinux.org/index.php/Securely_wipe_disk">Arch Wiki - Secure Disk Wiping</a></li>
<li><a href="https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_an_entire_system">Arch Wiki - Encrypting an Entire Disk</a></li>
<li><a href="https://wiki.gentoo.org/wiki/Sakaki%27s_EFI_Install_Guide/Preparing_the_LUKS-LVM_Filesystem_and_Boot_USB_Key">Gentoo Wiki - Sakaki&rsquo;s EFI Install Guide</a></li>
<li><a href="https://aaronbonner.io/post/21103731114/chroot-into-a-broken-linux-install">Chroot Into Broken Linux Install</a></li>
<li><a href="https://mattgadient.com/2016/07/11/linux-dvd-images-and-how-to-for-32-bit-efi-macs-late-2006-models/">Linux Images for 32Bit EFI Macs</a></li>
<li><a href="https://mattgadient.com/2018/02/12/reducing-the-30-second-delay-when-starting-64-bit-ubuntu-in-bios-mode-on-the-old-32-bit-efi-macs/">Reducing 30 Second Delay when Booting Linux</a></li>
<li><a href="https://support.siliconmechanics.com/portal/kb/articles/over-provisioning-ssds">Over-Provisioning SSDs</a></li>
</ul>
]]></content></item><item><title>ThothBackup - Part 2</title><link>https://mapletree.moe/posts/thothbackup-part-2/</link><pubDate>Sun, 02 Dec 2018 20:30:00 -0600</pubDate><author>bakayuki</author><guid>https://mapletree.moe/posts/thothbackup-part-2/</guid><description>&amp;lt;no value&amp;gt;</description><content type="text/html" mode="escaped"><![CDATA[<h1 id="thothbackup-project-series">ThothBackup Project Series<a href="#thothbackup-project-series" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p><strong>EDIT (2026/04/25):</strong> <em>As part of bringing the contents of the old blog back
online, some things needed to be moved around. ThothBackup was originally a
series of blog posts plus a dedicated project on the blog that was supposed to
be completed, and never was. As much as could be preserved, was.</em></p>
<ul>
<li><a href="/posts/thothbackup-part-0">ThothBackup: Part 0</a></li>
<li><a href="/posts/thothbackup-stage-0">ThothBackup: Stage 0</a></li>
<li><a href="/posts/thothbackup-part-1">ThothBackup: Part 1</a></li>
<li>ThothBackup: Part 2 <strong>(You are here.)</strong></li>
<li><a href="/posts/thothbackup-part-3">ThothBackup: Part 3</a></li>
</ul>
<p>Hello! It&rsquo;s that time of the week again, where I update everyone on my latest
work. This episode is far less technical and focuses more on the concept of a
&ldquo;One and Done&rdquo; backup solution, aka the holy grail of data maintenance.</p>
<p>It fucking sucks.</p>
<h1 id="introduction">Introduction<a href="#introduction" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>This entry is slightly unidirectional. The concept of a simple, easy to
implement, catch everything you might ever need solution is quite literally the
holy grail, yet it has never honestly been implemented. Sure, user data is
generally scooped out, but in the day and age of game mods, and with some
development projects taking place outside of the User directory, it seemed
prudent to at least <em>attempt</em> the full backup. Well, I&rsquo;ve been attempting it
for seven days. Here&rsquo;s what I&rsquo;ve found.</p>
<h2 id="focus">Focus<a href="#focus" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>We will not be focusing on the space impact of a complete backup. This is
actually fairly negligible. With out-of-band deduplication, only one set of
operating system files would ever be stored, so server side storage would reach
a weird type of equilibrium fairly quickly. Instead, I&rsquo;ll talk about three
things:</p>
<ul>
<li>Metadata Overhead</li>
<li>Metadata Processing</li>
<li>Initial Synchronization</li>
</ul>
<p>There may be another post tonight talking about additional things, but this
deserves it&rsquo;s own little deal.</p>
<h1 id="metadata-overhead">Metadata Overhead<a href="#metadata-overhead" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>A fully updated Windows 10 partition of your average gamer, aka my fiancé, is
composed of <strong>479,641 files</strong> and <strong>70,005 directories</strong> which comprise a total
data size of <strong>~216 GiB</strong>. This is actually just the C drive and typical
programs. If you factor in the actual game drive in use by our test case, that
drive contains <strong>354,315 files</strong> and <strong>29,111 directories</strong> which comprise a
total of <strong>~385 GiB</strong> of space.</p>
<p>In summation, an initial synchronization of what is typically considered a &ldquo;full
system backup&rdquo; comprises <strong>833,956 files</strong> and <strong>99,116 directories</strong> comprising
<strong>~601GiB</strong> which results in an average filesize of <strong>~755KiB</strong> and an average
directory size of <strong>~9 files</strong>.</p>
<p>SyncThing creates a block store that is comprised of, by default, <strong>128KiB</strong>
blocks. This means that for our system, assuming the data is contiguous, we need
<strong>4923392 Metadata Entries</strong>. Assuming the files are NOT contiguous, this is
probably closer to about <strong>5 Million</strong> metadata entries. As of right now, the
server side metadata storage for the testing pool is at <strong>1.7 GiB</strong> and initial
syncronization is <strong>not yet complete</strong>. Extrapolating a bit, we can assume that
<strong>2.0 GiB</strong> would not be an unreasonable size for a final server side data
store.</p>
<p>The client side store, at the time of writing, is approximately <strong>1 GiB</strong> and
may grow slightly larger. However, I will use <strong>1 GiB</strong>. This means that there
is a plausible total of <strong>3GiB of metadata overhead</strong> representing an overhead
percentage of <strong>~0.5%</strong> across the pool. Scaling up, this means 10 clients
with 1TB of data each would require <strong>51.2GB of Metadata</strong>.</p>
<p><strong>Should anything happen to the metadata store, it would need to be rebuilt by
data reprocessing. This introduces a potentially massive liability, as scanning
frequency would need to be reduced to not impact the rebuild operation.</strong></p>
<h1 id="metadata-processing">Metadata Processing<a href="#metadata-processing" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>The server is capable of a hash rate of <strong>107MB/s</strong>. I am picking the server&rsquo;s
hash rate because it is both the slowest hash rate of the pool and would have
the most metadata that would need to be rebuilt.</p>
<p>For a complete rebuild of the data of our current cluster, it would take the
server <strong>~96 Minutes</strong> during which no data synchronization could occur. This
equates to a minimum of <strong>1 Missed Hourly Update</strong> and could potentially result
in up to 2 missed hourly updates if the timing was unfortunate enough.</p>
<p>For a complete rebuild of the data of our theoretical cluster, we will allow for
a hash rate of <strong>300MB/s</strong>. The total data needed to be rebuilt would be 10TB.
This would result in a database rebuilt time of <strong>~10 Hours</strong> which could result
in up to 11 missed synchronization attempts.</p>
<h1 id="initial-synchronization">Initial Synchronization<a href="#initial-synchronization" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>The initial syncronization is composed of three primary parts. First, the
client and host must agree on what folders to syncronize. Second, the client
must build a database of the content hosted locally. Next, utilizing a rolling
hash algorithm, data is entered into the metadata cache and transmitted to the
server.</p>
<p><em>Per the developer of SyncThing, millions of small files are the worst case
scenario for the backup system.</em> As of my independent, albeit anecdotal testing,
After 7 days the synchronization process is still in effect. This represents a
very <strong>poor user experience</strong> and would not be ideal for a widespread rollout.</p>
<h1 id="conclusion">Conclusion<a href="#conclusion" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>The primary goal of a backup utility is to synchronize files and achieve cross
system consistency as quickly as possible. While it is true that eventually
consistent systems are utilized in large scale operations, this type of
consistency is allowable only, in my opinion, at data sizes over 10TB. The
current testing set is approximately 1TB at most, and thus this is unacceptable.</p>
<p><strong>Either the backup paradigm must change, or the utility used to implement it
must change.</strong> While I do not expect to find any faster utilities for performing
the backup process, I do plan to continue to experiment. At this time, however,
it seems that the most likely way to make the process as friendly as possible
would be the implementation of a default backup subset, with additional data
added upon user request, and after the high priority synchronization had been
completed.</p>
]]></content></item><item><title>ThothBackup: Part 1</title><link>https://mapletree.moe/posts/thothbackup-part-1/</link><pubDate>Wed, 28 Nov 2018 16:30:00 -0600</pubDate><author>bakayuki</author><guid>https://mapletree.moe/posts/thothbackup-part-1/</guid><description>&amp;lt;no value&amp;gt;</description><content type="text/html" mode="escaped"><![CDATA[<h1 id="thothbackup-project-series">ThothBackup Project Series<a href="#thothbackup-project-series" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p><strong>EDIT (2026/04/25):</strong> <em>As part of bringing the contents of the old blog back
online, some things needed to be moved around. ThothBackup was originally a
series of blog posts plus a dedicated project on the blog that was supposed to
be completed, and never was. As much as could be preserved, was.</em></p>
<ul>
<li><a href="/posts/thothbackup-part-0">ThothBackup: Part 0</a></li>
<li><a href="/posts/thothbackup-stage-0">ThothBackup: Stage 0</a></li>
<li>ThothBackup: Part 1 <strong>(You are here.)</strong></li>
<li><a href="/posts/thothbackup-part-2">ThothBackup: Part 2</a></li>
<li><a href="/posts/thothbackup-part-3">ThothBackup: Part 3</a></li>
</ul>
<p>As many people may have guessed, this backup system very quickly got much larger
than I initially expected. Because of the size of the backup project, the number
of people interested, and how quickly things are changing along the way, I&rsquo;ve
decided to approach this project in a new way.</p>
<p>In the sidebar to the left you will notice there is a new link to a &ldquo;Projects&rdquo;
directory. Here you will be able to find all my larger works. The project is
now called ThothBackup, and what follows is a list of things I have learned
along the way. All of this data will be consolidated and entered in a more
coherent fashion into the project pages, so keep an eye out for those to update.</p>
<p>But for now, we have a lot of ground to cover, so let&rsquo;s get to work.</p>
<h1 id="part-1---cross-platform-is-hard">Part 1 - Cross Platform is hard<a href="#part-1---cross-platform-is-hard" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>One of the biggest parts of the backup project was its ability to be
cross-platform. I want the system to be easy enough to use that anyone and
everyone could grab a client, get it configured, and get going. To facilitate
this, the initial idea was to use tools that were built into the operating
system. On Linux and macOS this is easy enough, as <code>rsync</code> is installed on most
distributions by default, and if it isn&rsquo;t installed it is just a quick package
manager installation away.</p>
<p>Then however, entered Windows. Initially I assumed that it would be easy to use
with windows as well. After all, <a href="https://www.rsync.net/resources/howto/windows_rsync.html">rsync.net</a> has a nice little guide
explaining how to set it up. However, their client can detect when you&rsquo;re not
using rsync.net servers (which is totally fair, there&rsquo;s no hate from me on that)
and limits using the program to 30 days. The other alternative is cwRsync, which
was initially freeware, but has since changed to being a paid product. Obviously
asking someone to play for a program to even be able to start to use the backup
isn&rsquo;t a great selling point.</p>
<p>The first idea that I had was to write something on my own. Maybe have shell
scripts on all platforms check for required code and fetch anything that is
needed. However, shell scripts are hard for many people to debug, and the sight
of a command prompt can strike fear into the hearts of many windows users.</p>
<p>The second iteration of the idea was to write something in Python. However at
that point the client is becoming a software project in its own right, and I
didn&rsquo;t start this to develop software, I started it because I wanted to set up
a neat little backup service for my friends and family.</p>
<p>Thankfully, there are many other software suites that are both cross platform
and useful for this task. We ended up going with <a href="https://syncthing.net/">SyncThing</a>. SyncThing is
an open-source (MPL2, which is a permissive form of copyleft) synchronization
library that is cross-platform and written in Go. I&rsquo;m a huge fan of Go even
though I don&rsquo;t actually write it myself, as it is a fantastic language for
exactly this type of thing. Even better, SyncThing comes with easy to use and
easy to understand GUIs, and is capable of NAT and Firewall punching via relays,
and makes device configuration dependent on acceptance from both the server
and the client. The protocol it uses is open source, and based on the usage
reports at least one person is using it on 30 million files with 2,000 peers.
Last, but most certainly not least, traffic is encrypted with 128 bit AES,
and the protocol maintains perfect forward secrecy.</p>
<p>All of this (and a whole lot more, it really is an awesome bit of software)
makes SyncThing perfect for our use case. This may not always remain the case,
but it gives me somewhere to start. Even if we end up moving beyond SyncThing in
the future, you really should give it a look. It is a phenomenal piece of
software.</p>
<h1 id="part-2---changes-in-sync-methods">Part 2 - Changes in Sync Methods<a href="#part-2---changes-in-sync-methods" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>As hinted above, the original plan to synchronize systems wasn&rsquo;t going to work
without more work than I was willing to put in to a single component of the
system. Once we threw out the initial way the system was supposed to work, we
had to retool the way things worked on the operating system too.</p>
<p>The original way the sync process was meant to work was that every user&rsquo;s
operating system would get its own Server Account, and rsync or some other
synchronization system would be tunneled through SSH. I wasn&rsquo;t sure if
authentication would be handled by system accounts or LDAP, because I never got
that far. But I did specifically pick the operating system (OpenSUSE) because
of that distribution&rsquo;s system configuration manager (YaST).</p>
<p>Now with the use of SyncThing, a daemon process would run under a single user,
and all clients would then connect to that daemon process which would then
write to disk using that daemon&rsquo;s permission set. Thus, no need to worry about
ACLs or anything of the like. It was interesting to work with ACLs though. You
can see some of my old code if you browse through the commits history of the
ThothBackup GitHub repository.</p>
<h1 id="part-3---filesystem-considerations">Part 3 - Filesystem Considerations<a href="#part-3---filesystem-considerations" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>When I was testing the original synchronization strategy, I had everything being
deposited onto BTRFS subvolumes that were mounted with the <code>compress</code> option. To
be entirely honest, I wasn&rsquo;t that impressed with the way the compression was
working.</p>
<p>In the new system, BTRFS subvolumes are still being used (User, System Name,
Operating System, Drive Name, Backup Client, Archive Client, etc) except now
the subvolumes are mounted with <code>compress-force</code> option. Additionally, I have
learned about out-of-band BTRFS deduplication and plan to play around with that
at this stage in the project as well.</p>
<h1 id="part-4---operating-systems">Part 4 - Operating Systems<a href="#part-4---operating-systems" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>I really, really like OpenSUSE. Like, a whole whole lot. It may very well be my
favorite binary distribution, and I&rsquo;ve used quite a few. I think the whole way
it works is simply phenomenal, I like the company behind it, and it honestly
boils down to just that: I like it.</p>
<p>But, after all the changes above I began to consider if I shouldn&rsquo;t change
distributions. Originally I thought of changing to BSD, but I was concerned
about software availability. I know FreeBSD tends to have a very well maintained
ports collection, but I was still.. concerned. Most tools in this arena seem to
cater toward Linux, and if I was already changing multiple systems to avoid
having to write new software, did I really want to run the risk of needing to
write server side software?</p>
<p>After much deliberation, I ended up settling on Debian Stable with backports.
The initial installation is extremely lean, and there is a truly massive amount
of documentation available for Debian. It paid off well too. The initial install
of Debian stable clocked in at 60MB of ram used, where as OpenSUSE was running
around 200MB after reboot.</p>
<h1 id="conclusion">Conclusion<a href="#conclusion" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>There is honestly still quite a bit more that needs to be discussed. One of the
most amusing things that the past week or so has taught me is that Sydney&rsquo;s
computer is as good of a backup test as a normal single family household. His
System has 4 drives, over one million files, a quarter of a million directories,
and about a terabyte of <em>used</em> storage on it. Combining his single computer
with my mac and a windows virtual machine, and we have as much testing as we
could need.</p>
<h1 id="notes">Notes<a href="#notes" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>I&rsquo;m going to start including a little section at the bottom of each post to
remind me what I need to work on. Hopefully having this publicly viewable will
encourage me to actually follow through on writing more than one blog post every
18 days.</p>
<ul>
<li>stage 1 project page</li>
<li>stage 2 project page</li>
<li>talk about security improvements that can be done</li>
<li>rewrite the server side new client script</li>
<li>talk about specific SyncThing configuration options used</li>
<li>write utility script to keep server config files up to date in git</li>
</ul>
]]></content></item><item><title>ThothBackup: Stage 0 - Environment &amp; Hardware Setup</title><link>https://mapletree.moe/posts/thothbackup-stage-0/</link><pubDate>Tue, 27 Nov 2018 16:30:00 -0600</pubDate><author>bakayuki</author><guid>https://mapletree.moe/posts/thothbackup-stage-0/</guid><description>&amp;lt;no value&amp;gt;</description><content type="text/html" mode="escaped"><![CDATA[<h1 id="thothbackup-project-series">ThothBackup Project Series<a href="#thothbackup-project-series" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p><strong>EDIT (2026/04/25):</strong> <em>As part of bringing the contents of the old blog back
online, some things needed to be moved around. ThothBackup was originally a
series of blog posts plus a dedicated project on the blog that was supposed to
be completed, and never was. As much as could be preserved, was.</em></p>
<ul>
<li><a href="/posts/thothbackup-part-0">ThothBackup: Part 0</a></li>
<li>ThothBackup: Stage 0 <strong>(You are here.)</strong></li>
<li><a href="/posts/thothbackup-part-1">ThothBackup: Part 1</a></li>
<li><a href="/posts/thothbackup-part-2">ThothBackup: Part 2</a></li>
<li><a href="/posts/thothbackup-part-3">ThothBackup: Part 3</a></li>
</ul>
<h1 id="environment--hardware-setup">Environment &amp; Hardware Setup<a href="#environment--hardware-setup" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<h2 id="introduction">Introduction<a href="#introduction" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>This section will be divided into several parts. In the first part, we will talk
about the environment that the server exists in. This will handle things like
power and networking, basically everything that exists outside the server. Next,
we will take a look at the server itself, and any changes that have been made to
it. We will then discuss the currently used storage devices. Finally, we will
talk about things that could be improved with this setup, and any potential
changes that could be made to increase security.</p>
<h1 id="environment">Environment<a href="#environment" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<h2 id="location">Location<a href="#location" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>Everything lives in a TV-stand-esque cabinet inside the living room of our
800ft^2 apartment. The Mac Mini and the storage devices sit on a little shelf
above the cabinet portion so they have ample access to fresh air, and the
other devices sit inside the closed portion of the cabinet. The cabinet is
actually right next to my bed, so in the event of a power outage the beep would
theoretically be loud enough to wake me up.</p>
<h2 id="networking">Networking<a href="#networking" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>The Mac Mini is connected to an <a href="https://www.ubnt.com/edgemax/edgerouter-lite/">Ubiquiti EdgeRouter Lite</a> via a
<a href="https://www.netgear.com/business/products/switches/unmanaged/GS108.aspx">Netgear GS180v4 Unmanaged Switch</a>. The WAN connection to the router is a
100mbps symmetrical fiber connection that will eventually be upgraded to a 1Gbps
symmetrical fiber connection. The fiber is coverted to ethernet via a GPON to
ethernet conversion jack. Cabling from each point is provided by
<a href="https://www.amazon.com/dp/B07BYBCXZ8/ref=cm_sw_r_cp_ep_dp_QMoaCbJKKX17D">LinkUp Fluke Certified Cat7 S/FTP Cables</a>. While I don&rsquo;t actually think
these cables are any better than any other cable, I like the design of them and
the way they feel. Besides, having an included Fluke report with each cable
certainly can&rsquo;t hurt.</p>
<h2 id="power">Power<a href="#power" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>The Mac Mini is connected to a small battery backup. The battery wouldn&rsquo;t be
able to power it for the entire duration of the outage, but the theory is that
it would allow time to get everything successfully and safely shut down.</p>
<p>Additionally, the router that the mini connects to the internet through is on
the same battery. This is for the same reasons, as the router is an EdgeRouter
and sudden shut off could potentially cause corruption to the boot image.</p>
<p>Finally, any and all storage devices that the server uses are connected to the
battery as well. This ensures that any writes will be able to complete
successfully.</p>
<p>The battery is connected to mains power a short distance away.</p>
<h1 id="server">Server<a href="#server" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<h2 id="base-model">Base Model<a href="#base-model" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>The Mac Mini that is being used is an <a href="https://everymac.com/systems/apple/mac_mini/specs/mac-mini-core-2-duo-2.0-specs.html">A1176 Mac Mini</a> with an Intel Core 2
Duo processor. You can see the original specifications of the Mac by following
the link above. The Mac was purchased by me second hand for about $100 and
some change and came with a whole host of accessories that are not in use at
this time. Unfortunately, this Mac was one of the last ones before Apple
switched to using a 64-bit EFI for the system firmware. You will read more about
why that is unfortunate during stage one.</p>
<h2 id="upgrades--modifications">Upgrades &amp; Modifications<a href="#upgrades--modifications" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p><strong>EDIT(2026/04/25):</strong> <em>Picture lost to time.</em></p>
<p>The Mac has been extensively modified. To begin with, many of the components
inside have been removed. You can see from the above picture some of the
modifications. The sound card, bluetooth card, wireless card, any errant wires,
anything that is non-essential was stripped out and thrown away. The server has
no ability to communicate wirelessly at this point. The only thing that remains
is the IR sensor, but that is strange to me because I removed the actual
receiver.</p>
<p>The CPU heatsink was removed, very carefully, and the thermal pad was replaced
with Artic Silver thermal compound. The entire system was completely
disassembled and meticulously cleaned with 99% Isopropyl alcohol. In addition,
the fan was replaced with a new OEM fan to ensure longer survival.</p>
<p>The hard drive of the Mac was originally a 5400rpm Hitachi 160GB SATA drive
that was white labeled for Apple specifically. This has been replaced with an
<a href="https://www.owcdigital.com/products/electra-3g-ssd">OWC Mercury Electra 3G 240GB SSD</a> and the RAM was upgraded with a matched
set of <a href="https://eshop.macsales.com/item/OWC/5300DDR2S4GP/">OWC PC5300 DDR2 2GB</a> memory modules. While it is likely I could
have got the RAM and SSD from pretty much anywhere, I like OWC and their prices,
for these upgrades at least, were reasonable.</p>
<h2 id="peripherals">Peripherals<a href="#peripherals" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>The only peripheral worth listing in this section is a <a href="https://madebymitchell.com/edid/">DVI EDID Dummy Plug</a>
which simulates a 1920x1200 monitor being attached to the Mac. Normally I would
not bother with an EDID Dummy Plug because the server won&rsquo;t need to render any
graphics for this use case, but in their infinite wisdom Apple decided that this
model of Mini should <em>only</em> be able to function as a Personal Computer, and the
damn thing won&rsquo;t load past the EFI unless it detects a monitor.</p>
<p>Other than power, networking, and storage, this is the only peripheral attached
to the Mini.</p>
<h2 id="future-plans">Future Plans<a href="#future-plans" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>It is possible more upgrades may be done on the Mini in time. The most
significant issue preventing any further upgrades is that I cannot seem to get
the damn computer to detect a USB drive for a boot option. Should I manage to
get it to the point that the system will boot from USB, there are a few
additional updates I would make:</p>
<ul>
<li>Replace the Internal DVD-ROM Drive with a PATA to SATA converter from iFixit</li>
<li>Install a 1TB Western Digital RED data drive</li>
<li>Replace the top cover of the mini with the cover from an A1278 Mini Server</li>
<li><em>Possibly</em> max out the CPU to an Intel Core2 T7600.
<ul>
<li>Doing literally anything involving the CPU is a tedious endeavor because
Apple used one way plastic plugs to mount the heatsink. I was lucky when
I was changing the thermal compound, and I do not think I will get lucky
again. This means that I would need to use nylon bolts to remount the HS
and that solution isn&rsquo;t particularly elegant to me.</li>
</ul>
</li>
</ul>
<h1 id="storage">Storage<a href="#storage" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<h2 id="drive">Drive<a href="#drive" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>Right now storage is provided by a single external drive. The drive is a
<a href="https://www.g-technology.com/products/desktop/g-drive-usb-c#0G05666">G-Drive 4TB USB-C</a> external drive, which internally is just a white labeled
Western Digital 4TB RED drive. I bought the USB-C model even though the Mini
only has USB 2.0 Ports because based on some preliminary research, USB-3 drives
on USB-2 ports are still faster than USB-2 drives on USB-2 ports. Additionally,
should I ever upgrade the server, the drive will just get faster instead of
slower. Additionally, the USB-C port is just more elegant than the way they
added USB3 onto existing USB2-B connections. I just like the look of them more.
I understand that that is trivial, but that&rsquo;s just the way it is.</p>
<h2 id="cable">Cable<a href="#cable" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>While I am sure that the standard cable would have been more than sufficient, I
have this weird thing about using manufacturer provided cables, even from a
reputable manufacturer. To this end, I replaced the original cable with an
<a href="https://www.anker.com/products/variant/powerline-usb-c-to-usb-a-double-braided-nylon-fast-charging-cable/B8266092">Anker PowerLine+ USBC to USBA</a>. It&rsquo;s red, it&rsquo;s pretty, and it has a pretty
decent warranty on it.</p>
<h1 id="improvements">Improvements<a href="#improvements" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>Honestly the biggest improvement that could be made would be swapping the server
for something much more powerful. Right now I am looking at second hand Mac Pro
towers, with Xeon processors and ECC Ram. Once I purchase one, it is likely that
I would max it out and do some internal modifications to it before switching it
out with the current Mini.</p>
<p>Beyond that obvious one though, other upgrades could be made as noted in the
server section. The most realistic one that could happen relatively soon is the
addition of a second external drive. This drive would allow for dedicated drives
for each part of the data process, or more likely, mirrored drives to increase
performance. That being said, the USB-2 connection isn&rsquo;t actually the bottleneck
in the system at this time. That discussion, however, will take place during
Stage One.</p>
<h1 id="security-considerations">Security Considerations<a href="#security-considerations" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>The biggest thing that could be done with respect to increasing security is the
addition of a Hardware Security Module. Currently I am considering implementing
the NitroKey HSM due to its reasonable price, open nature, and multiple
interesting features. All of this is secondary, however, to the far more likely
progression of upgrading the entire server with a new one. Once that is done,
then it is reasonable that we may focus on security.</p>
<p>That said, it is possible that I will be unable to find a reasonable deal on
secondhand towers, and in that case I may, instead, choose to continue working
with this little Mini.</p>
<h1 id="conclusion">Conclusion<a href="#conclusion" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>This concludes the first stage, or rather, the zeroth stage, of the backup
project. We itemized the various components that form the foundation for the
software aspects of this project, iterated over potential improvements, and
listed security features that could be implemented at a later date. After this,
we move on to <a href="/posts/thothbackup-stage-1">Stage 1</a> where we talk about the chosen operating system and
how to make it more secure for it&rsquo;s use as a hosting environment.</p>
]]></content></item><item><title>ThothBackup: Part 0</title><link>https://mapletree.moe/posts/thothbackup-part-0/</link><pubDate>Sat, 10 Nov 2018 12:00:00 -0600</pubDate><author>bakayuki</author><guid>https://mapletree.moe/posts/thothbackup-part-0/</guid><description>&amp;lt;no value&amp;gt;</description><content type="text/html" mode="escaped"><![CDATA[<h1 id="thothbackup-project-series">ThothBackup Project Series<a href="#thothbackup-project-series" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p><strong>EDIT (2026/04/25):</strong> <em>As part of bringing the contents of the old blog back
online, some things needed to be moved around. ThothBackup was originally a
series of blog posts plus a dedicated project on the blog that was supposed to
be completed, and never was. As much as could be preserved, was.</em></p>
<ul>
<li>ThothBackup: Part 0 <strong>(You are here.)</strong></li>
<li><a href="/posts/thothbackup-stage-0">ThothBackup: Stage 0</a></li>
<li><a href="/posts/thothbackup-part-1">ThothBackup: Part 1</a></li>
<li><a href="/posts/thothbackup-part-2">ThothBackup: Part 2</a></li>
<li><a href="/posts/thothbackup-part-3">ThothBackup: Part 3</a></li>
</ul>
<h1 id="introduction">Introduction<a href="#introduction" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>I&rsquo;ve been wanting to get back into blogging, or at least writing more
consistently, and I&rsquo;ve also been looking for projects to work on. One of my
favorite things to do, oddly enough, is to work on systems that will manage
large amounts of data. So, I&rsquo;ve decided to start a new project.</p>
<p>This is the first in a series of posts detailing the creation of a multi-tiered
backup system for me, some of my friends, and potentially (but not likely)
others as well. I will warn people ahead of time that I&rsquo;m not building any
hardware that could be called &ldquo;resilient,&rdquo; instead I&rsquo;m using things that I
already have around the house, plus a few extra cheap purchases, and a lot
of software to make things work.</p>
<p>Speaking of software, almost everything used will be cross-platform and open
source. I will likely be writing a lot of &ldquo;glue,&rdquo; in the form of shell scripts
or potentially even some ruby. I will also be trying to focus on keeping things
secure on untrusted servers, and secure in transit, to sometimes ridiculous
levels. That being said, this is <strong>NOT</strong> a zero-knowledge system. Since it is
for me, family, and friends, they are made aware of this ahead of time. In time,
it is possible that this setup will grow and evolve to make a zero-knowledge
system that functions similarly to this initial design idea, but that&rsquo;s far
down the line.</p>
<p>None of these blog posts will likely be as refined as my Icinga2 tutorials. One
of the things I am trying to do is just get myself into the habit of documenting
my projects. If I keep having to revise, edit, and source, I&rsquo;ll eventually give
up. So if there is anything you are interested in learning more about, Google
will likely be your best friend.</p>
<p>Essentially, these are meant to explain how I built the system, and why I did
what I did. Sometimes that may be as simple as &ldquo;because I like them more&rdquo; and
other times it may have to do with more in depth research.</p>
<h1 id="environment">Environment<a href="#environment" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>The server will exist in an environment with a battery backup system provided
for the server, any data drives, and the core router that the server will be
connected to. Connection to the internet is provided with a 100mbps symmetrical
fiber connection that can be upgraded instantly to 1Gbps symmetrical if needed.
Connections between the server and the fiber node is provided via CAT-7A
cabling. Routing is handled by a Ubiquiti EdgeRouter Lite, with 3gbps line rate
and one million packet per second routing. IPv6 and IPv4 are supported.</p>
<p>Eventually the router will be able to provide routes both to the public internet
and to the dn42 darknet and Tor services.</p>
<h1 id="hardware">Hardware<a href="#hardware" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>The hardware isn&rsquo;t exactly great, but it is the best that can be done at this
time. The server consists of a Mac Mini Model 2,1 made circa early 2007. It
contains a dual core Intel Core2 Duo processor running at 2.0 GHz.
<code>/proc/cpuinfo</code> is provided here:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">processor       : 0
</span></span><span class="line"><span class="cl">vendor_id       : GenuineIntel
</span></span><span class="line"><span class="cl">cpu family      : 6
</span></span><span class="line"><span class="cl">model           : 15
</span></span><span class="line"><span class="cl">model name      : Intel(R) Core(TM)2 CPU         T7200  @ 2.00GHz
</span></span><span class="line"><span class="cl">stepping        : 6
</span></span><span class="line"><span class="cl">microcode       : 0xd1
</span></span><span class="line"><span class="cl">cpu MHz         : 2000.000
</span></span><span class="line"><span class="cl">cache size      : 4096 KB
</span></span><span class="line"><span class="cl">physical id     : 0
</span></span><span class="line"><span class="cl">siblings        : 2
</span></span><span class="line"><span class="cl">core id         : 0
</span></span><span class="line"><span class="cl">cpu cores       : 2
</span></span><span class="line"><span class="cl">apicid          : 0
</span></span><span class="line"><span class="cl">initial apicid  : 0
</span></span><span class="line"><span class="cl">fpu             : yes
</span></span><span class="line"><span class="cl">fpu_exception   : yes
</span></span><span class="line"><span class="cl">cpuid level     : 10
</span></span><span class="line"><span class="cl">wp              : yes
</span></span><span class="line"><span class="cl">flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon
</span></span><span class="line"><span class="cl">pebs bts rep_good nopl cpuid aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm pti tpr_shadow dtherm
</span></span><span class="line"><span class="cl">bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
</span></span><span class="line"><span class="cl">bogomips        : 3999.68
</span></span><span class="line"><span class="cl">clflush size    : 64
</span></span><span class="line"><span class="cl">cache_alignment : 64
</span></span><span class="line"><span class="cl">address sizes   : 36 bits physical, 48 bits virtual
</span></span><span class="line"><span class="cl">power management:
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">processor       : 1
</span></span><span class="line"><span class="cl">vendor_id       : GenuineIntel
</span></span><span class="line"><span class="cl">cpu family      : 6
</span></span><span class="line"><span class="cl">model           : 15
</span></span><span class="line"><span class="cl">model name      : Intel(R) Core(TM)2 CPU         T7200  @ 2.00GHz
</span></span><span class="line"><span class="cl">stepping        : 6
</span></span><span class="line"><span class="cl">microcode       : 0xd1
</span></span><span class="line"><span class="cl">cpu MHz         : 1000.000
</span></span><span class="line"><span class="cl">cache size      : 4096 KB
</span></span><span class="line"><span class="cl">physical id     : 0
</span></span><span class="line"><span class="cl">siblings        : 2
</span></span><span class="line"><span class="cl">core id         : 1
</span></span><span class="line"><span class="cl">cpu cores       : 2
</span></span><span class="line"><span class="cl">apicid          : 1
</span></span><span class="line"><span class="cl">initial apicid  : 1
</span></span><span class="line"><span class="cl">fpu             : yes
</span></span><span class="line"><span class="cl">fpu_exception   : yes
</span></span><span class="line"><span class="cl">cpuid level     : 10
</span></span><span class="line"><span class="cl">wp              : yes
</span></span><span class="line"><span class="cl">flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon
</span></span><span class="line"><span class="cl">pebs bts rep_good nopl cpuid aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm pti tpr_shadow dtherm
</span></span><span class="line"><span class="cl">bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
</span></span><span class="line"><span class="cl">bogomips        : 3999.68
</span></span><span class="line"><span class="cl">clflush size    : 64
</span></span><span class="line"><span class="cl">cache_alignment : 64
</span></span><span class="line"><span class="cl">address sizes   : 36 bits physical, 48 bits virtual
</span></span><span class="line"><span class="cl">power management:
</span></span></code></pre></div><p>The server has been modified substansially from it&rsquo;s factory state. The sound
card has been removed, as has the WiFi card and Bluetooth card. IR functionality
has been disconnected. Any extraneous wires have been removed. The original
160GB Hitachi hard drive has been replaced with a 240GB solid state drive from
OWC. The ram has been maxed out with 4GBs, again provided from OWC. The system
is not capable of addressing all 4GB despite being a 64-bit system due to
limitations imposed in the EFI. The CMOS battery was replaced, and the processor
was unseated, cleaned, and thermal material replaced. The fan was also replaced
to head off any potential issues caused by old age. You can see a picture of the
internals of the system below.</p>
<p><strong>EDIT(2026/04/25):</strong> <em>Picture lost to time.</em></p>
<p>The system is connected to the router with a Fluke-Certified CAT-7A S/FTP dual
shielded cable. The interface it is connected to supports a 1Gbps full-duplex
connection.</p>
<p>The primary data disk is a G-Disk USB-C 4TB external drive. This drive utilizes
a white label Western Digital Red WD40EFRX. It is connected to the Mac Mini via
an Anker PowerLine+ USB-C to USB-A nylon cable.</p>
<p>The older Mac Mini&rsquo;s would refuse to boot if the system could not detect that a
monitor was connected to the system. Apple claims that this is because the Mac
Mini was intended to be a true personal computer, which would generally prohibit
the system&rsquo;s operation without a display device. Strangely, no such detection is
present to test for either a keyboard or a mouse.</p>
<p>To bypass this issue, a DVI Dummy Plug is installed in the Mini&rsquo;s DVI port. This
plug uses EDID to tell the system that a 1920x1200 capable display is connected.
This has also been reported to be useful in accelerating VNC Remote
Administration, however no GUI is present on the system.</p>
<h1 id="operating-system">Operating System<a href="#operating-system" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>The operating system used on the server is OpenSUSE Leap 15 x64. You may
remember that I mentioned above that the EFI used on the system is 32-bits.
This limitation is bypassed by formatting the internal server drive to utilize
a legacy MBR partition table. From this, GRUB2 loads in legacy mode, which is
32-bits. This provides the shim that allows the 32-bit system firmware to load
a 64-bit operating system. Over 72 hours of stress testing revealed no
instability with the operating system booted via this method.</p>
<p>OpenSUSE was installed using the Server profile. Originally the
Transactional-Server profile was used, however the early morning reboots
could cause issues, and the installation did not seem to play well with LVM.</p>
<h1 id="hardware-stress-testing">Hardware Stress Testing<a href="#hardware-stress-testing" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>The internal solid state drive was tested via an OpenSUSE Live distribution. The
computer was first suspended and resumed to bypass the system&rsquo;s EFI&rsquo;s proclivity
for freezing the internal drive&rsquo;s security interface. Once the interface was
unlocked, <code>smartctl</code> was used to trigger the drives internal SMART short test,
conveyance test, and extended test, in that order. All results were nominal.
The internal drive was then wiped via <code>hdparm</code> by sending an ATA Enhanced Secure
Erase Command with a non-null password.</p>
<p>A quick installation of OpenSUSE Leap 15 was then performed.</p>
<p>The hardware was then tested from inside the new installation utilizing the
Stress-NG test suite for over 24 hours. During this time, four virtual memory
test workers iterated over 100% of the available memory to force swapping as
well as check for ram errors. Two CPU test workers were ran on the aggressive
settings, and an IO worker was deployed to check the SSD interface. All systems
passed the stress test perfectly, with benchmarks appropriate for a system from
2007.</p>
<p>The external drive was then connected to the system. A battery of tests were
performed. First, the drive was tested via <code>smartctl</code>. As the drive is connected
via USB, the <code>-d sat,16</code> option was passed to allow communication directly with
the USB-SATA bridge. The drive was tested out of the box using the SMART short
self test, conveyance test, and extended self test. This first round of testing
took 10 hours to execute. After the inital round of tests, the SMART attributes
table and its corresponding values was recorded.</p>
<p>Then the <code>badblocks</code> command was ran to write to and read from every sector on
the drive. The full command was
<code>badblocks -wsv -t random -b 4096 -c 4096 -p 4 -o /root/sdb.log /dev/sdb</code>. This
performed four read-write-verify passes. Each pass took approximately 50 hours
to complete.</p>
<p>Once the <code>badblocks</code> battery was complete, <code>smartctl</code> was once again used to
run the same testing sequence of short, conveyance, and extended self tests. The
attribute table was once again dumped, it&rsquo;s values recorded, and the values then
compared to those from the table dumped prior to running <code>badblocks</code>.</p>
<p>As these tests are actually still in progress, the results are not yet
definitive.</p>
<h1 id="conclusion">Conclusion<a href="#conclusion" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<p>This first post simply outlines the primary variables in this project. Hardware,
operating system, and environment should all be assumed to remain static for
the remaining project entries. Should anything change, I will likely update this
entry versus notating it in the respective entry where the change was made. It
will be made clear that this entry has been edited, should that come to pass.</p>
<p>Extensive testing was performed to detect any chance of infant-mortality in the
hardware. I have previously had negative experiences utilizing hardware right
out of the box.</p>
]]></content></item><item><title>Collegi Backup - Work Notes</title><link>https://mapletree.moe/posts/collegi-backup-work-notes/</link><pubDate>Fri, 14 Oct 2016 03:00:00 -0500</pubDate><author>bakayuki</author><guid>https://mapletree.moe/posts/collegi-backup-work-notes/</guid><description>&amp;lt;no value&amp;gt;</description><content type="text/html" mode="escaped"><![CDATA[<p><strong>EDIT (2026/04/25):</strong> <em>Collegi has been discontinued for quite a while now, the
below information is still broadly useful, however, so it is maintained.
However, I have switched from borg to another software called Kopia.</em></p>
<h1 id="collegi-minecraft-server-series">Collegi Minecraft Server Series<a href="#collegi-minecraft-server-series" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<ul>
<li><a href="/posts/collegi-backup-system">Collegi Pixelmon Server Backup</a></li>
<li><a href="/posts/collegi-backup-part-2">Collegi Backup System: Part 2</a></li>
<li>Collegi Backup Work Notes <strong>(You are here.)</strong></li>
</ul>
<p>The following post is an extreme rough draft. In fact, it isn&rsquo;t even actually a
post. These are my development notes from my refactoring of the collegi data
infrastructure. As such, they&rsquo;re arranged in no real sensible order besides
having been written chronologically. Additionally, these have not been
proofread, grammar checked, copyedited, or spell checked, as i write them in an
IDE and not an actual text editor. As such, please don&rsquo;t judge my writing
ability off of them. More importantly, however, these do not have the
standardized links that i provide to new concepts or commands in my blog posts,
as embedding links to things I already know or have access to in a developer log
that on average no one else sees just seems silly.</p>
<p>So, if you have questions, use google, and expect these to be updated over time.</p>
<p>The logs as of this posting run from 10/13/2016 to 10/16/2016, so over three
days of work. There is a -LOT- more to be done.</p>
<p>They are broken down into the following format. Each list is a set of specific
actions I took, and sometimes the list ends up with notes in it because, again,
no one generally sees these, but under the task list is the space reserved for
notes on the above list. Then a new task list is declared, then notes, then
tasks, and so on and so forth. Generally each new task heading would signify
a new blog post, talking about the tasks and the notes, so keep that in mind.</p>
<p>These were requested by Kan, a player on our server. Enjoy!</p>
<h1 id="tasks---part-1">Tasks - Part 1<a href="#tasks---part-1" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<ul>
<li>Made a backup of the repository as it stood on 2016-10-13 in the event
anything breaks too badly during this.</li>
<li>Removed all existing submodules from the <code>git</code> repository. Committed the
removal.</li>
<li>Ran the previous backup script to make sure that 10/13 was backed up. This
included new additions to git annex.</li>
<li>Forced git annex to drop the old SHA256E key-value backend files that were
made obsolete by the conversion to SHA512E key-value backend.</li>
</ul>
<p><strong>Notes 1:</strong> During this time, and while watching the way the version 1.0
backup script ran, I noticed there is a significant performance penalty for
moving the location of the local mirror. Borg uses the entire path as the file
name, so any deviation in the path spec causes it to treat the files as brand
new. Note that this does not cause any issues with de-duplication, but the
process of adding these files causes a massive performance hit. This made me
start thinking about including the local mirror in the git annex so that as
long as the annex was kept in tact in regards to metadata, the paths would
remain the same as all additions to Borg would take place from the same root
directory.</p>
<p><em>The problem with this would be the fact that annex keeps everything as
symlinks. As such, I am looking into the unlock feature of version six
repositories.</em></p>
<p><strong>Notes 2:</strong> Dropping unused from a local area goes -much- faster than
dropping from remote. Who knew, right?</p>
<h1 id="tasks---part-2">Tasks - Part 2<a href="#tasks---part-2" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<ul>
<li><code>git-Annex</code> drop completed, but Finder isn&rsquo;t showing a reduction in used
drive space, but I think this is more an error on the side of finder than
something with git annex, as <code>du -h</code> showed the directory was down to the
size it should have been. Once I manage to get this finder thing figured out,
I&rsquo;ll move on to the next part.</li>
<li>Finder is taking too bloody long to figure its shit out, so I moved on to
the next step in cleaning up the repository. I&rsquo;m rewriting the commit history
to completely remove files I don&rsquo;t need from the actual <code>git</code> repo. In theory
this shouldn&rsquo;t touch <code>git-annex</code> at all, but that remains to be seen.</li>
<li>Ran BFG Repo Cleaner on the following directories and files:
<ul>
<li>collegi.web</li>
<li>collegi.pack</li>
<li>collegi.git</li>
<li>.DS_Store</li>
<li>.gitmodules</li>
<li>collegi.logs (Just for a moment, and we made backups.)</li>
<li>collegi.configs</li>
</ul>
</li>
<li>Ran filter branch to purge any empty commits left after the above.</li>
<li>Expired original ref-logs, repacked archive.</li>
</ul>
<p><strong>Notes 3:</strong> At this point we had gone from 230 commits to 102 commits. We were
also left with the original envisioning of what this repo would be, which was
a simple git annex to push files to Backblaze b2 from the Borg repository. Now
to verify that all of our data is still 100% ok.</p>
<h1 id="tasks---part-3">Tasks - Part 3<a href="#tasks---part-3" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<ul>
<li>Ran <code>git fsck</code></li>
<li>Ran <code>git annex fsck</code></li>
</ul>
<p><strong>Notes 4:</strong> Wow this is going to take a long fucking time. Who woulda thunk
it.</p>
<p><strong>Notes 5:</strong> So apparently the current version of <code>git-annex</code> is using the old
mixed hashing method, which is a format that &ldquo;we would like to stop using&rdquo;
according to the wiki. Might need to migrate. Need to figure out how.</p>
<p><strong>Notes 6:</strong> From the wiki: &ldquo;Initial benchmarks suggest that going from
<code>xX/yY/KEY/OBJ</code> to <code>xX/yY/OBJ</code> directories would improve speed 3x.&rdquo; It&rsquo;s worth
migrating.</p>
<h1 id="tasks---part-4">Tasks - Part 4<a href="#tasks---part-4" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<ul>
<li>Run <code>git annex uninit</code></li>
<li>Reading through the <code>git-annex-init</code> man page to see what else we should
change now since we&rsquo;re already migrating. Post Uninit we&rsquo;re going to have to
run a full borg data consistancy check.</li>
</ul>
<p><strong>Notes 7:</strong> Ugh. The document I found was actually an theoretical one, and
while it is true that <code>git-annex</code> does use the new hashing format in bare
repositories there is no actual way to move to the new one in a regular repo.
So I am running an <code>uninit</code> for basically no reason. The only good thing about
this that I can think of is that I will be able to reform the final <code>git-annex</code>
repo in a much saner fashion. The bad news is that I have lost the log files,
unless <code>git-annex</code> is going to bring those back for me. I am annoyed.</p>
<p><strong>Notes 8:</strong> Good news! I just remembered that I had made a <code>rsyn</code>ced backup
of the repository before I started fucking with it. So I didn&rsquo;t actually lose
the log files, I just went ahead and pulled them out of the <code>git-annex</code>
backup.</p>
<h1 id="tasks---part-5">Tasks - Part 5<a href="#tasks---part-5" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<ul>
<li>After the git annex had uninitialized, I decided that if I was going to do
this whole damn thing over again I was going to do it right.</li>
<li>Started a new <code>borg</code> repository in new-collegi. Pulled out contents from the
original <code>borg</code> repository, using backups to restore any files that got hit in
the above clusterfuck, then recompressed with maximum LZMA compression.</li>
<li>During this period I also standardized how the <code>borg create</code> paths would
work. The server would exist within a collegi.mirror directory, and the entire
directory would be added to <code>borg</code> upon each run of the backup script. This
effectively means we never have to worry about the LZMA penalty discussed
below again after the first re-add, unless we do major server restructuring,
because paths will remain stable between commits.</li>
</ul>
<p><strong>Notes 9:</strong> The initial speed penalty for using LZMA is absolutely jaw
dropping. One <code>borg create</code> took eight hours to complete. Eight. However, I
quickly noticed that due to Borg&rsquo;s de-duplication mechanism, the add times got
faster the more data I added, and gzip-9 to lzma-9 did actually yield some
improvement. It also reduces the incentive for me to do this fucking disaster
again, because of how much it absolutely fucking sucks.</p>
<p><strong>Notes 10:</strong> As an example of what I mean by the above, the initial adding of
1.8.9 took six hours with LZMA-9. When the map was changed from NewSeed over to
Collegi, it took another four hours just to update the paths and what not, even
though the data hadn&rsquo;t updated, just the paths have changed. (This is indicated
by the fact that the total repository size barely increased, all the size that
changed could be explained by new metadata.) However, when the paths are kept
the same, adding 100GB of data takes 13 to 15 minutes. So, the benefit of
LZMA-9 is worth the initial startup, imho.</p>
<p><strong>Notes 11:</strong> <code>borg extract</code>ing from the GZIP-9 archives takes about 40
minutes, and that&rsquo;s from highly de-duplicated and GZIP-9 archives. What this
means is that pulling from an lzma-9 is probably going to take about an hour,
depending on just how de-duplicated the archive is (as in, how many different
chunk files contain parts needed to reassemble the original content).</p>
<p><strong>Notes 12:</strong> Have hit the series of backups where things have moved into the
Users path, and I&rsquo;m restructuring them. It made me think about how I will handle
the mirror directory in the future. I think I am going to do a few new things
with respect to the new setup. The mirror directory will be a part of the
<code>git-annex</code> repository, so there will be a new folder inside it called
<code>collegi.mirror</code> or something similar, and then I can move the new backup
script to be ran from the root directory, which will be beneficial. That way
everything is neatly packaged. the issue becomes mirroring this, because
uploading that much constantly changing data to backblaze would be literally
stupid, and not at all within our budget. What I will likely do is initialize
a &ldquo;bare repository&rdquo; on my time machine drive, and mirror the entirity of the
<code>git-annex</code> repository to that.</p>
<h1 id="mandatory-break-notes">Mandatory Break Notes<a href="#mandatory-break-notes" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<ul>
<li>You need to run borg info to make sure the latest creation thingy is the
proper size, and a borg check might not be a bad idea either as you fell
asleep and closed the mac during work on the repo.</li>
<li>Cleaned the time machine volume of the repeated backups of the new
repository because it doesn&rsquo;t make any sense to have 20 versions of it.</li>
<li>Moved the repo to the time machine drive as temporary storage using rsync.</li>
</ul>
<h1 id="tasks---part-6">Tasks - Part 6<a href="#tasks---part-6" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<ul>
<li>Restarted the transfer process starting on the 8th of October</li>
</ul>
<p><strong>Notes 13:</strong> Not a huge shock but running some of these commands across USB
2.0 can add anywhere from 10 to 30 minutes. Doing them cross device gets even
worse, with some transactions taking almost an hour.</p>
<p><strong>Notes 14:</strong> I&rsquo;ve been going back and forth on what filesystem I would like
to deploy since I am redoing the collegi drive as a whole. Now the interesting
thing to note here is that by the time I get this thing fully ready to deploy,
the drive I have here may not be the drive it ends up on, but this is as good
of a testbed as any. I&rsquo;m really thinking I will go with apfs. Most of the
gripes I have with it are easily resolved through borg and git annex.</p>
<p><strong>Notes 15:</strong> In a highly amusing turn of events, it is bigger in lzma 9 than
it was with gzip 9. weird.</p>
<p><strong>Notes 16:</strong> While it would likely be prudent to go back to the previous
compression method, the benefits that I have made to the directory structure
while redoing the borg repository are worth the few extra gigabytes of overhead
especially concerning with Backblaze B2 it barely costs a penny.</p>
<h1 id="tasks---part-7">Tasks - Part 7<a href="#tasks---part-7" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<ul>
<li>Use JHFSX for the new drive. I would have really liked to use APFS but I am
still worried about the data loss considering there is almost a year till it
will ship. JHFSX is reasonable enough for right now, while still being safe to
unplug.</li>
<li>I went round and round on using encryption on the new drive. did it.</li>
<li>using rsync to bring the data to its final resting location.</li>
<li>OK started setting things up</li>
<li>Defined gitlab as the metadata backup again</li>
<li>created a bare repository on skaia</li>
<li>set up prefered content so skaia requires everything in the main repo</li>
<li>set the main repo to require a &ndash;force to drop content via preferred content</li>
<li>Set the backend to SHA512E</li>
<li>began the long process of adding the data to the git-annex</li>
<li>Set up bin directory to not be tracked by git-annex but instead by git</li>
<li>added backblaze remote, not encrypted, with a proper prefix</li>
<li>started to sync to backblaze</li>
<li>noticed an issue with how the sync was going to gitlab, will correct.
<ul>
<li>corrected the issue</li>
</ul>
</li>
</ul>
]]></content></item><item><title>Collegi Pixelmon - Backup System Part 2</title><link>https://mapletree.moe/posts/collegi-backup-part-2/</link><pubDate>Thu, 13 Oct 2016 12:00:00 -0500</pubDate><author>bakayuki</author><guid>https://mapletree.moe/posts/collegi-backup-part-2/</guid><description>&amp;lt;no value&amp;gt;</description><content type="text/html" mode="escaped"><![CDATA[<p><strong>EDIT (2026/04/25):</strong> <em>Collegi has been discontinued for quite a while now, the
below information is still broadly useful, however, so it is maintained.
However, I have switched from borg to another software called Kopia.</em></p>
<h1 id="collegi-minecraft-server-series">Collegi Minecraft Server Series<a href="#collegi-minecraft-server-series" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h1>
<ul>
<li><a href="/posts/collegi-backup-system">Collegi Pixelmon Server Backup</a></li>
<li>Collegi Backup System: Part 2 <strong>(You are here.)</strong></li>
<li><a href="/posts/collegi-backup-work-notes">Collegi Backup Work Notes</a></li>
</ul>
<p>What was originally intended to be a one off blog post may become my new source
of material for the coming weeks. After utilizing <a href="https://github.com/borgbackup/borg" title="BorgBackup">BorgBackup</a> and
<a href="https://git-annex.branchable.com/" title="Git-Annex">git-annex</a> to backup what has now grown to almost <a href="https://twitter.com/Zyradyl/status/786205897810780160" title="Zyradyl's Twitter">2.5 Terabytes</a> of
data, I began to wonder what other ways I could put git-annex to use for us here
at <a href="https://collegi.enjin.com" title="Collegi Pixelmon Main Website">Collegi</a>. We already use various <a href="https://gitlab.com/" title="GitLab">GitLab</a> repositories to manage
different facets of the project, and I began to wonder if there wouldn&rsquo;t be some
way to use git-annex to completely unify those repositories and distribute their
information as needed.</p>
<p>This started as a brief foray into <a href="https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407#.24xm3mdlt" title="Mastering Git Submodules">git submodules</a> which, while allowing me
to consolidate data <strong>locally</strong>, does nothing in helping me to properly
redistribute that data to various locations. The only way that it would be
possible to do such a thing would be to take all the various git repositories
that Collegi utilizes, which currently is sitting at <a href="https://gitlab.com/groups/collegi" title="GitLab: Collegi Group">six total</a>, including
the git-annex metadata repository (which isn&rsquo;t publicly visible), and merge them
into one master repository through the use of <a href="https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec#.r5p4ozyfm" title="Mastering Git Subtrees">git subtrees</a>. This would
allow me to still have multiple repositories for ease of project management, but
all those repositories would be pulled down, daily, to a local &ldquo;master&rdquo;
git-annex repository and merged into it.</p>
<p>Once this was done, the use of git annex&rsquo;s <a href="https://git-annex.branchable.com/git-annex-preferred-content/" title="Git Annex: Preferred Content Manual Page">preferred content</a> system would
allow me to decide what data needed to be sent to which remote. This would let
me back up some information to one remote, and other information to another.
As an added bonus, the use of git subtrees would even allow me to push changes
back upstream, and all of it would be centralized.</p>
<p>In the future, this would allow us to push very specific data to specific team
members, who would then modify the data, which would be pulled back down on the
next git-annex sync, we would see changes needing to be pushed upstream had been
made, unlock those files, then use git subtree to push them back to their
remotes. That&rsquo;s the theory at least. As far as I am aware, either no one has
done this before, no one who has done this before has lived to tell the tale, or
no one who has done this before has blogged about their experiences in doing so.</p>
<p>That&rsquo;s where this blog comes in. I&rsquo;m currently in the process of making a
complete copy of the current root repository, which is still using git
submodules, and from there I can begin experimenting. Whether or not this works
remains to be seen, but it coincides neatly with a rewrite of the
<a href="https://gitlab.com/collegi/collegi-backup-automation" title="GitLab: Collegi Group - Backup Automation">backup script</a> to update it to Google Shell Style Guidelines, which means
I can build the script around the new repository layout, and while doing so I
should be able to head off any unforeseen issues.</p>
<p>It&rsquo;s very likely that I am going to finish writing 2.0 of the script before
doing any of this crazy shit, but this post helps me to organize my thoughts.
Besides, it just means 3.0 will be that much more exciting when it drops.</p>
<p>Stay tuned for more of my antics and adventures with making this absurd system
take shape, and turn into the omnipresent repository of every single facet of
a Minecraft community.</p>
]]></content></item></channel></rss>