<?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=Subalpine</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=Subalpine"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Subalpine"/>
	<updated>2026-04-26T19:33:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:Root_on_ZFS_with_native_encryption&amp;diff=24328</id>
		<title>Talk:Root on ZFS with native encryption</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:Root_on_ZFS_with_native_encryption&amp;diff=24328"/>
		<updated>2023-08-15T15:46:53Z</updated>

		<summary type="html">&lt;p&gt;Subalpine: /* credit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Alpine on ZFS root issues in wiki procedure (v1) =&lt;br /&gt;
&lt;br /&gt;
I made some notes on issues I have encountered while following this guide. I will check these more and see if I can update the wiki with the notes.&lt;br /&gt;
&lt;br /&gt;
You can find the notes here: [https://pastebin.com/7jXtG6pT Notes on pastebin]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;span class=&amp;quot;autosigned&amp;quot;&amp;gt;—&amp;amp;nbsp;Preceding [[unsigned]] comment added by [[User:Patrix|Patrix]] ([[User talk:Patrix|{{int:talkpagelinktext}}]] • [[Special:Contributions/Patrix|{{int:contribslink}}]]) 11:14, 12 January 2020&amp;lt;/span&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Guide no longer working ==&lt;br /&gt;
&lt;br /&gt;
I tried to follow the guide on Alpine Standard 3.17.4 and 3.18.2. Here is where I&#039;m stuck.&lt;br /&gt;
&lt;br /&gt;
~ # modprobe zfs&lt;br /&gt;
modprobe: FATAL: Module zfs not found in directory /lib/modules/5.15.117-0-lts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;span class=&amp;quot;autosigned&amp;quot;&amp;gt;—&amp;amp;nbsp;Preceding [[unsigned]] comment added by [[User:Drolex|Drolex]] ([[User talk:Drolex|{{int:talkpagelinktext}}]] • [[Special:Contributions/Drolex|{{int:contribslink}}]]) 16:33, 26 July 2023‎&amp;lt;/span&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== credit ==&lt;/div&gt;</summary>
		<author><name>Subalpine</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:Root_on_ZFS_with_native_encryption&amp;diff=24327</id>
		<title>Talk:Root on ZFS with native encryption</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:Root_on_ZFS_with_native_encryption&amp;diff=24327"/>
		<updated>2023-08-15T15:45:22Z</updated>

		<summary type="html">&lt;p&gt;Subalpine: /* credit */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Alpine on ZFS root issues in wiki procedure (v1) =&lt;br /&gt;
&lt;br /&gt;
I made some notes on issues I have encountered while following this guide. I will check these more and see if I can update the wiki with the notes.&lt;br /&gt;
&lt;br /&gt;
You can find the notes here: [https://pastebin.com/7jXtG6pT Notes on pastebin]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;span class=&amp;quot;autosigned&amp;quot;&amp;gt;—&amp;amp;nbsp;Preceding [[unsigned]] comment added by [[User:Patrix|Patrix]] ([[User talk:Patrix|{{int:talkpagelinktext}}]] • [[Special:Contributions/Patrix|{{int:contribslink}}]]) 11:14, 12 January 2020&amp;lt;/span&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Guide no longer working ==&lt;br /&gt;
&lt;br /&gt;
I tried to follow the guide on Alpine Standard 3.17.4 and 3.18.2. Here is where I&#039;m stuck.&lt;br /&gt;
&lt;br /&gt;
~ # modprobe zfs&lt;br /&gt;
modprobe: FATAL: Module zfs not found in directory /lib/modules/5.15.117-0-lts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;span class=&amp;quot;autosigned&amp;quot;&amp;gt;—&amp;amp;nbsp;Preceding [[unsigned]] comment added by [[User:Drolex|Drolex]] ([[User talk:Drolex|{{int:talkpagelinktext}}]] • [[Special:Contributions/Drolex|{{int:contribslink}}]]) 16:33, 26 July 2023‎&amp;lt;/span&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== credit ==&lt;br /&gt;
&lt;br /&gt;
i wrote the original article and revisions. I don&#039;t see my name on here?&lt;/div&gt;</summary>
		<author><name>Subalpine</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Configure_a_Wireguard_interface_(wg)&amp;diff=20148</id>
		<title>Configure a Wireguard interface (wg)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Configure_a_Wireguard_interface_(wg)&amp;diff=20148"/>
		<updated>2021-09-29T04:33:07Z</updated>

		<summary type="html">&lt;p&gt;Subalpine: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOC left}}&lt;br /&gt;
&lt;br /&gt;
WireGuard is a very promising VPN technology available in the community repository since Alpine 3.10.&lt;br /&gt;
&lt;br /&gt;
There are several ways to install and configure an interface.&lt;br /&gt;
&lt;br /&gt;
In order to load the WireGuard kernel module, you need a compatible kernel:&lt;br /&gt;
&lt;br /&gt;
* linux-lts&lt;br /&gt;
* linux-virt&lt;br /&gt;
&lt;br /&gt;
== Bringing up an interface using wg-tools ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward method, and the one recommended in WireGuard documentation, is to use &amp;lt;code&amp;gt;wg-quick&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Install wireguard-tools&lt;br /&gt;
&lt;br /&gt;
 apk add wireguard-tools&lt;br /&gt;
&lt;br /&gt;
Then load the module&lt;br /&gt;
&lt;br /&gt;
 modprobe wireguard&lt;br /&gt;
&lt;br /&gt;
Add it to &amp;lt;code&amp;gt;/etc/modules&amp;lt;/code&amp;gt; to automatically load it on boot.&lt;br /&gt;
&lt;br /&gt;
Then, we need to create a private and a public key:&lt;br /&gt;
&lt;br /&gt;
 wg genkey | tee privatekey | wg pubkey &amp;gt; publickey&lt;br /&gt;
&lt;br /&gt;
Then, we create a new config file &amp;lt;code&amp;gt;/etc/wireguard/wg0.conf&amp;lt;/code&amp;gt; using those keys:&lt;br /&gt;
&lt;br /&gt;
 [Interface]&lt;br /&gt;
 Address = 10.123.0.1/24&lt;br /&gt;
 ListenPort = 45340&lt;br /&gt;
 PrivateKey = SG1nXk2+kAAKnMkL5aX3NSFPaGjf9SQI/wWwFj9l9U4= # the key from the previously generated privatekey file&lt;br /&gt;
 PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;iptables -A FORWARD -o %i -j ACCEPT&lt;br /&gt;
 PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;iptables -D FORWARD -o %i -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
The PostUp and PostDown steps are there to ensure the interface wg0 will accept and forward traffic to eth0. The postrouting and forward to %i is not required, but it will enable &amp;quot;VPN mode&amp;quot; where users can access the internet via this server if desired. Reference [https://github.com/pirate/wireguard-docs#user-content-config-reference this WireGuard documentation] for information on adding peers to the config file.&lt;br /&gt;
&lt;br /&gt;
To bring up the new interface we use:&lt;br /&gt;
&lt;br /&gt;
 wg-quick up wg0&lt;br /&gt;
&lt;br /&gt;
To take it down, we can use &amp;lt;code&amp;gt;wg-quick down wg0&amp;lt;/code&amp;gt; which will clean up the interface and remove the iptables rules.&lt;br /&gt;
Note: If running in a Docker container, you will need to run with &amp;lt;code&amp;gt;--cap-add=NET_ADMIN&amp;lt;/code&amp;gt; to modify your interfaces.&lt;br /&gt;
&lt;br /&gt;
== Bringing up an interface using ifupdown-ng ==&lt;br /&gt;
&lt;br /&gt;
The official documents from WireGuard show examples of how to set up an interface with the use of wg-quick.&lt;br /&gt;
In this how-to, we are not going to use that utility. We&#039;ll use the plain wg command and [https://github.com/ifupdown-ng/ifupdown-ng/blob/master/doc/interfaces-wireguard.scd ifupdown-ng].&lt;br /&gt;
&lt;br /&gt;
 apk add wireguard-tools-wg&lt;br /&gt;
&lt;br /&gt;
Now that all the tools are installed, you can setup the interface.&lt;br /&gt;
The setup of your interface config is out of the scope of this document. You should consult the [https://git.zx2c4.com/WireGuard/about/src/tools/man/wg.8 manual page of wg].&lt;br /&gt;
&lt;br /&gt;
After you have finished setting up your wgX interface config, you can add it to your &amp;lt;code&amp;gt;/etc/network/interfaces&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 auto wg0&lt;br /&gt;
 iface wg0 inet static&lt;br /&gt;
        requires eth0&lt;br /&gt;
        use wireguard&lt;br /&gt;
        address 192.168.42.1&lt;br /&gt;
&lt;br /&gt;
This config will automatically:&lt;br /&gt;
&lt;br /&gt;
* bring the WireGuard interface up after the eth0 interface&lt;br /&gt;
* assign a config to this interface (which you have previously created)&lt;br /&gt;
* setup the interface address and netmask&lt;br /&gt;
* add the route once the interface is up&lt;br /&gt;
* remove the interface when it goes down&lt;br /&gt;
&lt;br /&gt;
To start and stop the interface, you execute:&lt;br /&gt;
&lt;br /&gt;
 ifup wg0&lt;br /&gt;
 ifdown wg0&lt;br /&gt;
&lt;br /&gt;
If your interface config is not stored under &amp;lt;code&amp;gt;/etc/wireguard&amp;lt;/code&amp;gt; you need to specify a &amp;lt;code&amp;gt;wireguard-config-path&amp;lt;/code&amp;gt; as well.&lt;br /&gt;
&lt;br /&gt;
== Running with modloop ==&lt;br /&gt;
If you are running from a RAM disk, you can&#039;t modify the modloop.&lt;br /&gt;
&lt;br /&gt;
You can get around it by unpacking the modloop, mounting the unpacked modules folder, then installing WireGuard.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 apk add squashfs-tools # install squashfs tools to unpack modloop&lt;br /&gt;
 unsquashfs -d /root/squash /lib/modloop-lts # unpack modloop to root dir&lt;br /&gt;
 umount /.modloop # unmount existing modloop&lt;br /&gt;
 mount /root/squash/ /.modloop/ # mount unpacked modloop&lt;br /&gt;
 apk del wireguard-lts # uninstall previous WireGuard install&lt;br /&gt;
 apk add wireguard-lts&lt;br /&gt;
 apk add wireguard-tools&lt;br /&gt;
&lt;br /&gt;
You can repack the squash filesystem or put this script in the /etc/local.d/ path so it runs at boot-up.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>Subalpine</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Root_on_ZFS_with_native_encryption&amp;diff=17801</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=17801"/>
		<updated>2020-07-11T22:54:56Z</updated>

		<summary type="html">&lt;p&gt;Subalpine: fix bold&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Setting up  Alpine Linux using ZFS with a pool that uses ZFS&#039; native encryption capabilities =&lt;br /&gt;
&lt;br /&gt;
== Download ==&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 mods at the time of this writing (2020.07.10)&lt;br /&gt;
&lt;br /&gt;
Write it to a USB and boot from it.&lt;br /&gt;
&lt;br /&gt;
== Initial setup ==&lt;br /&gt;
&lt;br /&gt;
Run the following&lt;br /&gt;
&lt;br /&gt;
    setup-alpine&lt;br /&gt;
&lt;br /&gt;
Answer all the questions, and hit ctrl-c when promted for what disk you&#039;d like to use.&lt;br /&gt;
&lt;br /&gt;
== OPTIONAL ==&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 into my terminal window from these instructions.&lt;br /&gt;
&lt;br /&gt;
Edit `/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 `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 your resulting machine. You will be reminded again at the end of this doc.&lt;br /&gt;
&lt;br /&gt;
== Add needed packages  ==&lt;br /&gt;
&lt;br /&gt;
    apk add zfs sfdisk e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
== Create our partitions ==&lt;br /&gt;
&lt;br /&gt;
We&#039;re assuming `/dev/sda` here and in the rest of the document but you can use whatever you need to. To see a list, type: `sfdisk -l`&lt;br /&gt;
&lt;br /&gt;
    echo -e &amp;quot;/dev/sda1: start=1M,size=100M,bootable\n/dev/sda2: start=101M&amp;quot; | sfdisk --quiet --label dos /dev/sda&lt;br /&gt;
&lt;br /&gt;
== Create device nodes ==&lt;br /&gt;
&lt;br /&gt;
    mdev -s&lt;br /&gt;
&lt;br /&gt;
== Create the /boot filesystem ==&lt;br /&gt;
&lt;br /&gt;
    mkfs.ext4 /dev/sda1&lt;br /&gt;
&lt;br /&gt;
== Create the root filesystem using zfs ==&lt;br /&gt;
&lt;br /&gt;
    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;
&lt;br /&gt;
- `ashift=12` is recommended here because many drives today have 4KiB (or larger) physical sectors, even though they present 512B logical sectors&lt;br /&gt;
&lt;br /&gt;
- `acltype=posixacl` enables POSIX ACLs globally&lt;br /&gt;
&lt;br /&gt;
- `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.&lt;br /&gt;
&lt;br /&gt;
- `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.&lt;br /&gt;
&lt;br /&gt;
After completing this, confirm that the pool has been created:&lt;br /&gt;
&lt;br /&gt;
    # 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;
    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 `/boot` filesystem ==&lt;br /&gt;
&lt;br /&gt;
    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;
    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;
    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;
&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>Subalpine</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Root_on_ZFS_with_native_encryption&amp;diff=17800</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=17800"/>
		<updated>2020-07-11T22:54:09Z</updated>

		<summary type="html">&lt;p&gt;Subalpine: update to reflects steps for latest version v3.12&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Setting up  Alpine Linux using ZFS with a pool that uses ZFS&#039; native encryption capabilities =&lt;br /&gt;
&lt;br /&gt;
== Download ==&lt;br /&gt;
&lt;br /&gt;
Download the &#039;&#039;&#039;extended&#039;&#039; release from https://www.alpinelinux.org/downloads/ as only it contains the zfs kernel mods at the time of this writing (2020.07.10)&lt;br /&gt;
&lt;br /&gt;
Write it to a USB and boot from it.&lt;br /&gt;
&lt;br /&gt;
== Initial setup ==&lt;br /&gt;
&lt;br /&gt;
Run the following&lt;br /&gt;
&lt;br /&gt;
    setup-alpine&lt;br /&gt;
&lt;br /&gt;
Answer all the questions, and hit ctrl-c when promted for what disk you&#039;d like to use.&lt;br /&gt;
&lt;br /&gt;
== OPTIONAL ==&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 into my terminal window from these instructions.&lt;br /&gt;
&lt;br /&gt;
Edit `/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 `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 your resulting machine. You will be reminded again at the end of this doc.&lt;br /&gt;
&lt;br /&gt;
== Add needed packages  ==&lt;br /&gt;
&lt;br /&gt;
    apk add zfs sfdisk e2fsprogs syslinux&lt;br /&gt;
&lt;br /&gt;
== Create our partitions ==&lt;br /&gt;
&lt;br /&gt;
We&#039;re assuming `/dev/sda` here and in the rest of the document but you can use whatever you need to. To see a list, type: `sfdisk -l`&lt;br /&gt;
&lt;br /&gt;
    echo -e &amp;quot;/dev/sda1: start=1M,size=100M,bootable\n/dev/sda2: start=101M&amp;quot; | sfdisk --quiet --label dos /dev/sda&lt;br /&gt;
&lt;br /&gt;
== Create device nodes ==&lt;br /&gt;
&lt;br /&gt;
    mdev -s&lt;br /&gt;
&lt;br /&gt;
== Create the /boot filesystem ==&lt;br /&gt;
&lt;br /&gt;
    mkfs.ext4 /dev/sda1&lt;br /&gt;
&lt;br /&gt;
== Create the root filesystem using zfs ==&lt;br /&gt;
&lt;br /&gt;
    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;
&lt;br /&gt;
- `ashift=12` is recommended here because many drives today have 4KiB (or larger) physical sectors, even though they present 512B logical sectors&lt;br /&gt;
&lt;br /&gt;
- `acltype=posixacl` enables POSIX ACLs globally&lt;br /&gt;
&lt;br /&gt;
- `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.&lt;br /&gt;
&lt;br /&gt;
- `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.&lt;br /&gt;
&lt;br /&gt;
After completing this, confirm that the pool has been created:&lt;br /&gt;
&lt;br /&gt;
    # 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;
    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 `/boot` filesystem ==&lt;br /&gt;
&lt;br /&gt;
    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;
    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;
    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;
&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>Subalpine</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Root_on_ZFS_with_native_encryption&amp;diff=17797</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=17797"/>
		<updated>2020-07-08T03:16:48Z</updated>

		<summary type="html">&lt;p&gt;Subalpine: replace linux-vanilla with linux-lts&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
This documentation describes how to set up Alpine Linux using ZFS with a pool that uses ZFS&#039; native encryption capabilities, which have been recently introduced in ZFS on Linux (ZoL) 0.8.0.&lt;br /&gt;
&lt;br /&gt;
Note that you must install the &amp;lt;code&amp;gt;/boot/&amp;lt;/code&amp;gt; directory on an unencrypted partition (either an unencrypted ZFS pool or any other FS of your choosing, if it&#039;s compatible with your bootloader) to boot correctly.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
You&#039;ll need a medium to put a live image on. You can use any live medium that supports ZoL &amp;gt;=0.8.x, but as of writing this it&#039;s easiest to use [https://ubuntu.com/download/desktop Ubuntu 19.10], which comes with ZFS pre-installed.&lt;br /&gt;
&lt;br /&gt;
== Hard Disk Device Name ==&lt;br /&gt;
&lt;br /&gt;
The following documentation uses the &amp;lt;code&amp;gt;/dev/sda&amp;lt;/code&amp;gt; device as installation destination. If your environment uses a different device name for your hard disk, use the corresponding device names in the examples. It also uses &amp;lt;code&amp;gt;rpool&amp;lt;/code&amp;gt; as name of the root pool, you can change this at will, but be sure to change it everywhere it&#039;s mentioned.&lt;br /&gt;
&lt;br /&gt;
= Setting up Alpine Linux Using ZFS with native encryption =&lt;br /&gt;
&lt;br /&gt;
To install Alpine Linux in a ZFS pool with encryption enable, you cannot use the [[Installation|official installation]] procedure, so follow along this guide.&lt;br /&gt;
&lt;br /&gt;
== Creating the Partition Layout ==&lt;br /&gt;
&lt;br /&gt;
Linux requires an unencrypted &amp;lt;code&amp;gt;/boot/&amp;lt;/code&amp;gt; partition to boot. You can assign the remaining space for the encrypted ZFS pool.&lt;br /&gt;
&lt;br /&gt;
* Start the &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; utility to set up partitions:&lt;br /&gt;
&lt;br /&gt;
 # fdisk /dev/sda&lt;br /&gt;
&lt;br /&gt;
:* Create the &amp;lt;code&amp;gt;/boot/&amp;lt;/code&amp;gt; partition:&lt;br /&gt;
::* Enter &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;100m&amp;lt;/code&amp;gt; to create a new 100 MB primary partition.&lt;br /&gt;
&lt;br /&gt;
:* Set the &amp;lt;code&amp;gt;/boot/&amp;lt;/code&amp;gt; partition active:&lt;br /&gt;
::* Enter &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
:* Create the ZFS partition:&lt;br /&gt;
::* Enter &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; &amp;amp;rarr; &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; to start creating the next partition. Press &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to select the default start cylinder. Enter the size of partition. For example, &amp;lt;code&amp;gt;512m&amp;lt;/code&amp;gt; for 512 MB or &amp;lt;code&amp;gt;5g&amp;lt;/code&amp;gt; for 5 GB. Alternatively press &amp;lt;code&amp;gt;Enter&amp;lt;/code&amp;gt; to set the maximum available size.&lt;br /&gt;
&lt;br /&gt;
:* To verify the settings, press &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;. The output shows, for example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Device     Boot  Start      End  Sectors  Size Id Type&lt;br /&gt;
/dev/sda1  *      2048   206847   204800  100M 83 Linux&lt;br /&gt;
/dev/sda2       206848 41943039 41736192 19.9G 83 Linux&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Press &amp;lt;code&amp;gt;w&amp;lt;/code&amp;gt; to save the changes.&lt;br /&gt;
&lt;br /&gt;
== Setting up the root pool ==&lt;br /&gt;
&lt;br /&gt;
You can create your rootpool with the following command:&lt;br /&gt;
&lt;br /&gt;
 # zpool create -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;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ashift=12&amp;lt;/code&amp;gt; is recommended here because many drives today have 4KiB (or larger) physical sectors, even though they present 512B logical sectors&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;acltype=posixacl&amp;lt;/code&amp;gt; enables POSIX ACLs globally&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;normalization=formD&amp;lt;/code&amp;gt; eliminates some corner cases relating to UTF-8 filename normalization. It also enables &amp;lt;code&amp;gt;utf8only=on&amp;lt;/code&amp;gt;, meaning that only files with valid UTF-8 filenames will be accepted.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;xattr=sa&amp;lt;/code&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
After completing this, confirm that the pool has been created:&lt;br /&gt;
&lt;br /&gt;
 # zpool status&lt;br /&gt;
&lt;br /&gt;
Should return something like:&lt;br /&gt;
&amp;lt;pre&amp;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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating the required datasets ===&lt;br /&gt;
&lt;br /&gt;
 # 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;
=== Creating optional datasets (feel free to add your own) ===&lt;br /&gt;
&lt;br /&gt;
 # zfs create -o mountpoint=/home rpool/HOME&lt;br /&gt;
 # zfs create -o mountpoint=/var/log rpool/LOG&lt;br /&gt;
&lt;br /&gt;
== Creating the &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt; filesystem ==&lt;br /&gt;
&lt;br /&gt;
 # mkfs.ext4 /dev/sda1&lt;br /&gt;
&lt;br /&gt;
== Mounting the &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt; filesystem ==&lt;br /&gt;
&lt;br /&gt;
* Create the &amp;lt;code&amp;gt;/mnt/boot/&amp;lt;/code&amp;gt; directory and mount the &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt; partition in this directory:&lt;br /&gt;
&lt;br /&gt;
 # mkdir /mnt/boot/&lt;br /&gt;
 # mount -t ext4 /dev/sda1 /mnt/boot/&lt;br /&gt;
&lt;br /&gt;
== Installing Alpine Linux ==&lt;br /&gt;
&lt;br /&gt;
Please follow [[Installing_Alpine_Linux_in_a_chroot|Installing Alpine Linux in a chroot]] to setup a base install of Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
After you&#039;ve followed that guide, you still have to do some additional setup for ZFS:&lt;br /&gt;
&lt;br /&gt;
* As of the time of writing this ZFS 0.8.x is only available in [[Edge]], so you&#039;ll have to enable it in &amp;lt;code&amp;gt;/etc/apk/repositories&amp;lt;/code&amp;gt;. Check [https://pkgs.alpinelinux.org/packages?name=zfs pkgs.alpinelinux.org] to see the status of this.&lt;br /&gt;
&lt;br /&gt;
* Install the ZoL and linux-lts package: &amp;lt;code&amp;gt;apk add linux-lts zfs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Enable ZFS&#039; services:&lt;br /&gt;
&lt;br /&gt;
 # rc-update add zfs-import sysinit&lt;br /&gt;
 # rc-update add zfs-mount sysinit&lt;br /&gt;
&lt;br /&gt;
* Edit the &amp;lt;code&amp;gt;/etc/mkinitfs/mkinitfs.conf&amp;lt;/code&amp;gt; file and append &amp;lt;code&amp;gt;zfs&amp;lt;/code&amp;gt; module to the &amp;lt;code&amp;gt;features&amp;lt;/code&amp;gt; parameter:&lt;br /&gt;
&lt;br /&gt;
 features=&amp;quot;ata base ide scsi usb virtio ext4 lvm &amp;lt;u&amp;gt;zfs&amp;lt;/u&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Be mindful to also include other modules which may be required for your setup, such as the &amp;lt;code&amp;gt;nvme&amp;lt;/code&amp;gt; module.&lt;br /&gt;
&lt;br /&gt;
* Rebuild the initial RAM disk:&lt;br /&gt;
&lt;br /&gt;
 # mkinitfs $(ls /lib/modules/)&lt;br /&gt;
&lt;br /&gt;
* Edit the &amp;lt;code&amp;gt;/etc/update-extlinux.conf&amp;lt;/code&amp;gt; file, set the root ZFS dataset and append the following kernel options to the &amp;lt;code&amp;gt;default_kernel_opts&amp;lt;/code&amp;gt; parameter:&lt;br /&gt;
&lt;br /&gt;
 root=rpool/ROOT/alpine&lt;br /&gt;
 default_kernel_opts=&amp;quot;... &amp;lt;u&amp;gt;rootfstype=zfs&amp;lt;/u&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Update extlinux&#039;s config (if you&#039;re not using a different bootloader)&lt;br /&gt;
&lt;br /&gt;
 # update-extlinux&lt;br /&gt;
 # exit&lt;br /&gt;
&lt;br /&gt;
: Ignore the errors the &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt; utility displays.&lt;br /&gt;
&lt;br /&gt;
* Write the MBR to the &amp;lt;code&amp;gt;/dev/sda&amp;lt;/code&amp;gt; device:&lt;br /&gt;
&lt;br /&gt;
 # dd bs=440 count=1 conv=notrunc if=/mnt/usr/share/syslinux/mbr.bin of=/dev/sda&lt;br /&gt;
&lt;br /&gt;
== Unmounting the filesystems ==&lt;br /&gt;
&lt;br /&gt;
* Unmount &amp;lt;code&amp;gt;/mnt/boot/&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 # umount /mnt/boot/&lt;br /&gt;
&lt;br /&gt;
* Unmount all zfs filesystems:&lt;br /&gt;
&lt;br /&gt;
 # zfs unmount -a&lt;br /&gt;
&lt;br /&gt;
* Reboot the system:&lt;br /&gt;
&lt;br /&gt;
 # reboot&lt;br /&gt;
&lt;br /&gt;
== Booting the system ==&lt;br /&gt;
&lt;br /&gt;
Right now mkinitfs doesn&#039;t support ZFS asking for passwords during boot, so it&#039;ll throw you into a rescue shell for you to enter the password during boot. You have to do the following things after pressing enter:&lt;br /&gt;
&lt;br /&gt;
 # zfs load-key -a&lt;br /&gt;
 # mount -t zfs rpool/ROOT/alpine /sysroot&lt;br /&gt;
 # exit&lt;br /&gt;
&lt;br /&gt;
And your system should continue booting! :)&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
&lt;br /&gt;
== General Procedure ==&lt;br /&gt;
&lt;br /&gt;
In case your system fails to boot, you can verify the settings and fix incorrect configurations:&lt;br /&gt;
&lt;br /&gt;
* [[#Preparing_the_Installation_Environment|Preparing the Installation Environment]]&lt;br /&gt;
&lt;br /&gt;
* Load the ZFS kernel module:&lt;br /&gt;
&lt;br /&gt;
 # modprobe zfs&lt;br /&gt;
&lt;br /&gt;
* [[#Mounting_the_File_Systems|Mount the file systems]]&lt;br /&gt;
&lt;br /&gt;
 # zpool import -R /mnt rpool&lt;br /&gt;
 # mount -t ext4 /dev/sda1 /mnt/boot&lt;br /&gt;
&lt;br /&gt;
* Verify that you run the steps described in the [[#Installing_Alpine_Linux|Installing Alpine Linux]] section correctly. Update the configuration if necessary.&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Subalpine</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=17796</id>
		<title>Alpine Linux in a chroot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=17796"/>
		<updated>2020-07-08T03:01:54Z</updated>

		<summary type="html">&lt;p&gt;Subalpine: need to add syslinux pkg to be able to add mbr&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOC right}}&lt;br /&gt;
&lt;br /&gt;
Inside the chroot environment, you can build, debug, and run alpine packages or develop things. It&#039;s the most known way to do so if one wants not to trash their main Alpine system.&lt;br /&gt;
&lt;br /&gt;
This document explains how to set up an [[Alpine_newbie#Developer|Alpine build environment]] in a chroot under a host Linux distro, can also be used to install Alpine Linux from a non-Alpine Linux livecd.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* Working Linux instalation where to perform all the process&lt;br /&gt;
* Linux kernel 2.6.22, with &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; installed&lt;br /&gt;
* target media with at least 100M, 900MB for more complete solution as minimum&lt;br /&gt;
* internet connection&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
The variables below: &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;${chroot_dir}&#039;&#039;&#039; = Should point to the chroot directory where you &lt;br /&gt;
*&#039;&#039;&#039;${mirror}&#039;&#039;&#039; = Should be replaced with [http://nl.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
*&#039;&#039;&#039;${arch}&#039;&#039;&#039; =  Should be the cpu architecture like x86 (i386) or amd64(x86_64)..&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package (replace &amp;lt;tt&amp;gt;${version}&amp;lt;/tt&amp;gt; with actual version):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget ${mirror}/latest-stable/main/${arch}/apk-tools-static-${version}.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|tar -xzf apk-tools-static-*.apk}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./sbin/apk.static -X ${mirror}/latest-stable/main -U --allow-untrusted --root ${chroot_dir} --initdb add alpine-base}}&lt;br /&gt;
&lt;br /&gt;
== Set up the chroot ==&lt;br /&gt;
&lt;br /&gt;
Before made and enter into the chrooted system must be prepared with device nodes and tempfs :&lt;br /&gt;
&lt;br /&gt;
===== Method 1.A fast way: using bind mount =====&lt;br /&gt;
&lt;br /&gt;
{{Note|Mounts with bind, can mount in read-only the /dev at the alpine chroot so due limited will not touch the  access time of the host system}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mount /dev/ ${chroot_dir}/dev/ --bind&lt;br /&gt;
mount -o remount,ro,bind ${chroot_dir}/dev&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
If you need SCSI or R/W access only do the first command, mounting with &amp;quot;ro&amp;quot; makes more secure your chroot.&lt;br /&gt;
&lt;br /&gt;
===== Method 1.B manual way: creating need nodes =====&lt;br /&gt;
&lt;br /&gt;
{{Warning|Manually creating devices will only provide those representation that you have created.. for auto availability use bind mounts}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mknod -m 666 ${chroot_dir}/dev/full c 1 7&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/ptmx c 5 2&lt;br /&gt;
mknod -m 644 ${chroot_dir}/dev/random c 1 8&lt;br /&gt;
mknod -m 644 ${chroot_dir}/dev/urandom c 1 9&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/zero c 1 5&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/tty c 5 0}}&lt;br /&gt;
&lt;br /&gt;
If you need SCSI disc access:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mknod -m 666 ${chroot_dir}/dev/sda b 8 0&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda1 b 8 1&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 2&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 3&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 4&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 5&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 6&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sdb b 8 16&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sdb1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sdb2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sdb3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sdb4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sdb5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sdb6 b 8 22}}&lt;br /&gt;
&lt;br /&gt;
==== Made available proc and sys fs ====&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mount -t proc none ${chroot_dir}/proc&lt;br /&gt;
mount -o bind /sys ${chroot_dir}/sys}}&lt;br /&gt;
&lt;br /&gt;
==== Make networking resolution access ====&lt;br /&gt;
&lt;br /&gt;
A resolv.conf is needed for name resolution: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|cp -L /etc/resolv.conf ${chroot_dir}/etc/&lt;br /&gt;
mkdir -p ${chroot_dir}/root}}&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to copy the resolv.conf from the local machine, you can create a new one using OpenDNS servers (or any other): &lt;br /&gt;
{{Cmd|echo -e &#039;nameserver 8.8.8.8\nnameserver 2620:0:ccc::2&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
==== prepare the apk sources software ====&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror (replace &amp;lt;tt&amp;gt;${branch}&amp;lt;/tt&amp;gt; with the latest stable branch name, e.g. v3.3):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/${branch}/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Mastering your chroot ==&lt;br /&gt;
&lt;br /&gt;
The chroot methods are commonly used to have alpine in a portion of a already made directory, not forced to be a entire partion, that means Alpine can be in a very minimal directory indise the same partition of a Debian installed linux inclusively, so that why the chroot process does not included the boot method.&lt;br /&gt;
&lt;br /&gt;
So then the following commands will described the need procedures only if the chroot instalation was made to a dedicated partition for and not to a directory inside another linux installed.&lt;br /&gt;
&lt;br /&gt;
{{Warning|so then by the explained reasons, at this point, Alpine has been succesfully installed onto the chroot directory &#039;&#039;&#039;but still not able to boot it&#039;&#039;&#039;. }}&lt;br /&gt;
&lt;br /&gt;
==== Entering your chroot ====&lt;br /&gt;
&lt;br /&gt;
Take in consideration that the chroot command are only running as root, no stupid sudo tools are recommended for that.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} ash -l}}&lt;br /&gt;
&lt;br /&gt;
==== Perform init process ====&lt;br /&gt;
&lt;br /&gt;
Need to add some minimal initscripts to appropriate runlevels:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add devfs sysinit&lt;br /&gt;
rc-update add dmesg sysinit&lt;br /&gt;
rc-update add mdev sysinit&lt;br /&gt;
&lt;br /&gt;
rc-update add hwclock boot&lt;br /&gt;
rc-update add modules boot&lt;br /&gt;
rc-update add sysctl boot&lt;br /&gt;
rc-update add hostname boot&lt;br /&gt;
rc-update add bootmisc boot&lt;br /&gt;
rc-update add syslog boot&lt;br /&gt;
&lt;br /&gt;
rc-update add mount-ro shutdown&lt;br /&gt;
rc-update add killprocs shutdown&lt;br /&gt;
rc-update add savecache shutdown}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Make bootable the install ====&lt;br /&gt;
&lt;br /&gt;
WIP:&lt;br /&gt;
&lt;br /&gt;
{{Warning|Run only this if Alpine was installed to a dedicated partiton mounted at the &amp;lt;nowiki&amp;gt;${chroot_dir}&amp;lt;/nowiki&amp;gt; directory, becose at this point, Alpine has been succesfully installed onto the chroot directory &#039;&#039;&#039;but still not able to boot it&#039;&#039;&#039;. }}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;apk add syslinux&lt;br /&gt;
dd if=/usr/share/syslinux/mbr.bin of=/dev/sda&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Be care of that /dev/sda are the same disk where destination partition was mounted to &amp;lt;nowiki&amp;gt;${chroot_dir}&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
&lt;br /&gt;
== hardened kernels or alpine as chroot host ==&lt;br /&gt;
&lt;br /&gt;
If you are using Alpine as a Native build system you will have to make sure that chroot can run chmod. Add following to &amp;lt;code&amp;gt;/etc/sysctl.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;kernel.grsecurity.chroot_deny_chmod = 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sysctl -p&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== chroot: cannot run command &#039; ... Exec format error ==&lt;br /&gt;
&lt;br /&gt;
This usually indicates that you booted with one architecture (e.g. armf) and are trying to chroot into another (e.g. x86_64). If you plans to make chroot into another installation must use same arch for both host and hosted chrooted!&lt;br /&gt;
&lt;br /&gt;
Note that with &#039;&#039;&#039;one exception you can run 32 bit x86 chroot in x86_64, but not viceversa&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
== WARNING: Ignoring APKINDEX.xxxx.tar.gz ==&lt;br /&gt;
&lt;br /&gt;
Make sure &amp;lt;code&amp;gt;${chroot_dir}/etc/apk/repositories&amp;lt;/code&amp;gt; is valid and inside the chroot run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= External links =&lt;br /&gt;
&lt;br /&gt;
* You can also use script [https://github.com/alpinelinux/alpine-chroot-install/ alpine-chroot-install]&lt;br /&gt;
* https://web.archive.org/web/20190808203313/https://isc.sans.edu/forums/diary/Forensic+use+of+mount+bind/22854/&lt;br /&gt;
* Alpine Linux in a chroot on Fedora : http://git.alpinelinux.org/cgit/user/fab/scripts/tree/alpine-chroot.sh script&lt;br /&gt;
* Alpine Linux aarch64 in a chroot on AWS Linux : https://gist.github.com/emolitor/0567e51c0ce04f4b025fc78d2cf0b4f1 script&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[category: System Administration]]&lt;/div&gt;</summary>
		<author><name>Subalpine</name></author>
	</entry>
</feed>