<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=R5</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=R5"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/R5"/>
	<updated>2026-04-30T04:19:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Root_on_ZFS_with_native_encryption&amp;diff=24380</id>
		<title>Root on ZFS with native encryption</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Root_on_ZFS_with_native_encryption&amp;diff=24380"/>
		<updated>2023-08-21T17:18:06Z</updated>

		<summary type="html">&lt;p&gt;R5: fix link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a guide for installing Alpine Linux with its root partition on an encrypted ZFS volume, using ZFS&#039;s own encryption capabilities. The system will be encrypted when powered off and will need to be unlocked by typing a passphrase at boot. To be able to boot the system, the `/boot` partition remains unencrypted.&lt;br /&gt;
&lt;br /&gt;
= OpenZFS Guide =&lt;br /&gt;
&lt;br /&gt;
A guide on OpenZFS website supports native encryption, UEFI boot and legacy boot, and multi-disk.  See [https://openzfs.github.io/openzfs-docs/Getting%20Started/Alpine%20Linux/Root%20on%20ZFS.html here].&lt;br /&gt;
&lt;br /&gt;
= Downloading Alpine =&lt;br /&gt;
&lt;br /&gt;
Download the &#039;&#039;&#039;extended&#039;&#039;&#039; release from https://www.alpinelinux.org/downloads/ as only it contains the zfs kernel modules at the time of writing (2022-02-12).&lt;br /&gt;
&lt;br /&gt;
Write it to a USB device and boot from it.&lt;br /&gt;
&lt;br /&gt;
= Initial Setup =&lt;br /&gt;
&lt;br /&gt;
Run the following to start the installation procedure:&lt;br /&gt;
&lt;br /&gt;
{{cmd|setup-alpine}}&lt;br /&gt;
&lt;br /&gt;
Answer all the questions, and hit {{Key|Ctrl}}+{{Key|C}} when prompted for which disk you&#039;d like to use.&lt;br /&gt;
&lt;br /&gt;
== Optional: SSH access ==&lt;br /&gt;
&lt;br /&gt;
This section is optional and it assumes internet connectivity. You may enable sshd so you can ssh into the box and copy and paste the rest of the commands from these instructions into a terminal window.&lt;br /&gt;
&lt;br /&gt;
Edit {{path|/etc/ssh/sshd_config}} and search for `Permit`. Change the value after `PermitRootLogin` to read `yes`&lt;br /&gt;
&lt;br /&gt;
save and exit to shell. Run {{codeline|service sshd restart}}&lt;br /&gt;
&lt;br /&gt;
Now you can ssh in as root. Do not forget to go back and comment this line out when you&#039;re done since it will be enabled on the resulting machine. You will be reminded again at the end of this doc.&lt;br /&gt;
&lt;br /&gt;
= Add required packages  =&lt;br /&gt;
&lt;br /&gt;
{{cmd|apk add {{pkg|zfs}} {{pkg|sfdisk}} {{pkg|e2fsprogs}} {{pkg|syslinux}}}}&lt;br /&gt;
&lt;br /&gt;
= Partition setup =&lt;br /&gt;
&lt;br /&gt;
We&#039;re assuming that {{path|/dev/sda}} is the target storage device here and in the rest of the document, but the name of the storage device you wish to install to may be different. To see a list of storage devices and determine the correct one, type {{codeline|sfdisk -l}}.&lt;br /&gt;
&lt;br /&gt;
{{cmd|echo -e &amp;quot;/dev/sda1: start{{=}}1M,size{{=}}100M,bootable\n/dev/sda2: start{{=}}101M&amp;quot; &amp;amp;#124; sfdisk --quiet --label dos /dev/sda}}&lt;br /&gt;
&lt;br /&gt;
== Create device nodes ==&lt;br /&gt;
&lt;br /&gt;
{{cmd|mdev -s}}&lt;br /&gt;
&lt;br /&gt;
== Create the {{path|/boot}} filesystem ==&lt;br /&gt;
&lt;br /&gt;
{{cmd|mkfs.ext4 /dev/sda1}}&lt;br /&gt;
&lt;br /&gt;
= ZFS setup =&lt;br /&gt;
== Create the root zpool ==&lt;br /&gt;
&lt;br /&gt;
{{cmd|modprobe zfs&lt;br /&gt;
zpool create -f -o ashift{{=}}12 \&lt;br /&gt;
-O acltype{{=}}posixacl -O canmount{{=}}off -O compression{{=}}lz4 \&lt;br /&gt;
-O dnodesize{{=}}auto -O normalization{{=}}formD -O relatime{{=}}on -O xattr{{=}}sa \&lt;br /&gt;
-O encryption{{=}}aes-256-gcm -O keylocation{{=}}prompt -O keyformat{{=}}passphrase \&lt;br /&gt;
-O mountpoint{{=}}/ -R /mnt \&lt;br /&gt;
rpool /dev/sda2}}&lt;br /&gt;
&lt;br /&gt;
You will have to enter your passphrase at this point. Choose wisely, as your passphrase is most likely [https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions#5-security-aspects the weakest link in this setup].&lt;br /&gt;
&lt;br /&gt;
A few notes on the options supplied to zpool:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;{{codeline|ashift{{=}}12}} is recommended here because many drives today have 4KiB (or larger) physical sectors, even though they present 512B logical sectors&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;{{codeline|acltype{{=}}posixacl}} enables POSIX ACLs globally&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;{{codeline|normalization{{=}}formD}} eliminates some corner cases relating to UTF-8 filename normalization. It also enables `utf8only=on`, meaning that only files with valid UTF-8 filenames will be accepted.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;{{codeline|xattr{{=}}sa}} vastly improves the performance of extended attributes, but is Linux-only. If you care about using this pool on other OpenZFS implementation don&#039;t specify this option.&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After completing this, confirm that the pool has been created:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# zpool status}}&lt;br /&gt;
&lt;br /&gt;
Should return something like:&lt;br /&gt;
&lt;br /&gt;
      pool: rpool&lt;br /&gt;
     state: ONLINE&lt;br /&gt;
      scan: none requested&lt;br /&gt;
    config:&lt;br /&gt;
    &lt;br /&gt;
        NAME        STATE     READ WRITE CKSUM&lt;br /&gt;
        rpool       ONLINE       0     0     0&lt;br /&gt;
          sda2      ONLINE       0     0     0&lt;br /&gt;
    &lt;br /&gt;
    errors: No known data errors&lt;br /&gt;
&lt;br /&gt;
== Create the required datasets and mount root ==&lt;br /&gt;
&lt;br /&gt;
{{cmd|zfs create -o mountpoint{{=}}none -o canmount{{=}}off rpool/ROOT&lt;br /&gt;
zfs create -o mountpoint{{=}}legacy rpool/ROOT/alpine&lt;br /&gt;
mount -t zfs rpool/ROOT/alpine /mnt/}}&lt;br /&gt;
&lt;br /&gt;
== Mount the {{path|/boot}} filesystem ==&lt;br /&gt;
&lt;br /&gt;
{{cmd|mkdir /mnt/boot/&lt;br /&gt;
mount -t ext4 /dev/sda1 /mnt/boot/}}&lt;br /&gt;
&lt;br /&gt;
== Enable ZFS&#039; services ==&lt;br /&gt;
&lt;br /&gt;
{{cmd|rc-update add zfs-import sysinit&lt;br /&gt;
rc-update add zfs-mount sysinit}}&lt;br /&gt;
&lt;br /&gt;
= Install Alpine Linux =&lt;br /&gt;
&lt;br /&gt;
{{cmd|setup-disk /mnt&lt;br /&gt;
dd if{{=}}/usr/share/syslinux/mbr.bin of{{=}}/dev/sda # write mbr so we can boot}}&lt;br /&gt;
&lt;br /&gt;
= Reboot and enjoy! =&lt;br /&gt;
&lt;br /&gt;
😉&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039;&lt;br /&gt;
If you went with the optional step, be sure to disable root login after you reboot.&lt;/div&gt;</summary>
		<author><name>R5</name></author>
	</entry>
</feed>