<?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=Hypocritus</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=Hypocritus"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Hypocritus"/>
	<updated>2026-04-30T12:21:44Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=16749</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=16749"/>
		<updated>2019-12-29T00:00:00Z</updated>

		<summary type="html">&lt;p&gt;Hypocritus: /* Method 1.A fast way: using bind mount */  --- changed &amp;#039;/alpine&amp;#039; to &amp;#039;${chroot_dir}&amp;#039; for consistency, since the original variables are declared as such, in addition to many Alpine articles using &amp;#039;/mnt&amp;#039; instead of &amp;#039;/alpine&amp;#039; for the chroot mountpoint&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 /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;
== Entering your chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Warning|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|chroot ${chroot_dir} /bin/bash -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;
= 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>Hypocritus</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=16734</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=16734"/>
		<updated>2019-12-23T12:29:23Z</updated>

		<summary type="html">&lt;p&gt;Hypocritus: grammar correction&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/ /alpine/dev/ --bind&lt;br /&gt;
mount -o remount,ro,bind /alpine/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 /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;
== Entering your chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Warning|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|chroot ${chroot_dir} /bin/bash -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;
= 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>Hypocritus</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_configuration_management_scripts&amp;diff=16731</id>
		<title>Alpine configuration management scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_configuration_management_scripts&amp;diff=16731"/>
		<updated>2019-12-22T17:30:50Z</updated>

		<summary type="html">&lt;p&gt;Hypocritus: /* setup-alpine */ clarified grammar&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page summarizes the low-level behavior of the {{Path|/sbin/setup-*}} scripts on the Alpine ISO (and in a normal Alpine install).&lt;br /&gt;
&lt;br /&gt;
== setup-alpine ==&lt;br /&gt;
&lt;br /&gt;
This is a low-level administrator command, for a higher-level walkthrough please use the [[Alpine_newbie_install_manual#Ways_to_install_Alpine_into_machines_or_virtuals|Alpine for new users install manuals]] (that use the &amp;quot;sys&amp;quot; install mode).&lt;br /&gt;
&lt;br /&gt;
The [[Alpine_newbie_install_manual#Ways_to_install_Alpine_into_machines_or_virtuals|Alpine for new users install manuals]] page wiki also references this script, but is less technical.&lt;br /&gt;
&lt;br /&gt;
This script accepts the following command-line switches (you can run &amp;lt;code&amp;gt;setup-alpine -h&amp;lt;/code&amp;gt; to see a usage message).&lt;br /&gt;
&lt;br /&gt;
{{Define|-a|Create an overlay file: this creates a temporary directory and saves its location in ROOT; however, the script doesn&#039;t export this variable so I think this feature isn&#039;t currently functional.}}&lt;br /&gt;
;-c &amp;lt;var&amp;gt;answerfile&amp;lt;/var&amp;gt;&lt;br /&gt;
:Create a new &amp;quot;answerfile&amp;quot;, with default choices. You can edit the file and then invoke &amp;lt;code&amp;gt;setup-alpine -f &amp;lt;var&amp;gt;answerfile&amp;lt;/var&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
;-f &amp;lt;var&amp;gt;answerfile&amp;lt;/var&amp;gt;&lt;br /&gt;
:Use an existing &amp;quot;answerfile&amp;quot;, which may override some or all of the interactive prompts.&lt;br /&gt;
{{Define|-q|Run in &amp;quot;quick mode.&amp;quot; See below for details.}}&lt;br /&gt;
&lt;br /&gt;
The script&#039;s behavior is to do the following, in order. Bracketed options represent extra configuration choices that can be supplied when running the auxiliary setup scripts manually, or by supplying an &amp;quot;answerfile&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;setup-keymap&amp;lt;/code&amp;gt; [us us]&lt;br /&gt;
# [[#setup-hostname|setup-hostname]] [-n alpine-test]&lt;br /&gt;
# [[#setup-interfaces|setup-interfaces]] [-i &amp;lt; interfaces-file]&lt;br /&gt;
# &amp;lt;code&amp;gt;/etc/init.d/networking --quiet start &amp;amp;&amp;lt;/code&amp;gt;&lt;br /&gt;
# if none of the networking interfaces were configured using dhcp, then: [[#setup-dns|setup-dns]] [-d example.com -n &amp;quot;8.8.8.8 [...]&amp;quot;]&lt;br /&gt;
# set the root password&lt;br /&gt;
# if not in quick mode, then: [[#setup-timezone|setup-timezone]] [-z UTC | -z America/New_York | -p EST+5]&lt;br /&gt;
# enable the new hostname (&amp;lt;code&amp;gt;/etc/init.d/hostname --quiet restart&amp;lt;/code&amp;gt;)&lt;br /&gt;
# add &amp;lt;code&amp;gt;networking&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;urandom&amp;lt;/code&amp;gt; to the &#039;&#039;&#039;boot&#039;&#039;&#039; rc level, and &amp;lt;code&amp;gt;acpid&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; to the &#039;&#039;&#039;default&#039;&#039;&#039; rc level, and start the &#039;&#039;&#039;boot&#039;&#039;&#039; and &#039;&#039;&#039;default&#039;&#039;&#039; rc services&lt;br /&gt;
# extract the fully-qualified domain name and hostname from {{Path|/etc/resolv.conf}} and &amp;lt;code&amp;gt;hostname&amp;lt;/code&amp;gt;, and update {{Path|/etc/hosts}}&lt;br /&gt;
# [[#setup-proxy|setup-proxy]] [-q &amp;lt;nowiki&amp;gt;&amp;quot;http://webproxy:8080&amp;quot;&amp;lt;/nowiki&amp;gt;], and activate proxy if it was configured&lt;br /&gt;
# &amp;lt;code&amp;gt;setup-apkrepos&amp;lt;/code&amp;gt; [-r (to select a mirror randomly)]&lt;br /&gt;
# if not in quick mode, then: [[#setup-sshd|setup-sshd]] [-c openssh | dropbear | none]&lt;br /&gt;
# if not in quick mode, then: &amp;lt;code&amp;gt;setup-ntp&amp;lt;/code&amp;gt; [-c chrony | openntpd | busybox | none]&lt;br /&gt;
# if not in quick mode, then: &amp;lt;code&amp;gt;DEFAULT_DISK=none&amp;lt;/code&amp;gt; [[#setup-disk|setup-disk]] &amp;lt;code&amp;gt;-q&amp;lt;/code&amp;gt; [-m data /dev/sda]&lt;br /&gt;
# if installation mode selected during setup-disk was &amp;quot;data&amp;quot; instead of &amp;quot;sys&amp;quot;, then: &amp;lt;code&amp;gt;setup-lbu&amp;lt;/code&amp;gt; [/media/sdb1]&lt;br /&gt;
# if installation mode selected during setup-disk was &amp;quot;data&amp;quot; instead of &amp;quot;sys&amp;quot;, then: &amp;lt;code&amp;gt;setup-apkcache&amp;lt;/code&amp;gt; [/media/sdb1/cache | none]&lt;br /&gt;
&lt;br /&gt;
== setup-hostname ==&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;setup-hostname&amp;lt;/code&amp;gt; [-h] [-n hostname]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-h&#039;&#039;&#039; &amp;lt;var&amp;gt;Show help&amp;lt;/var&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-n&#039;&#039;&#039; &amp;lt;var&amp;gt;Specify hostname&amp;lt;/var&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script allows quick and easy setup of the system hostname by writing it to {{Path|/etc/hostname}}.  The script prevents you from writing an invalid hostname (such as one that used invalid characters or starts with a &#039;-&#039; or is too long).&lt;br /&gt;
The script can be invoked manually or is called as part of the &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; script.&lt;br /&gt;
&lt;br /&gt;
== setup-interfaces ==&lt;br /&gt;
{{Cmd|setup-interfaces [-i &amp;amp;lt; &amp;lt;var&amp;gt;interfaces-file&amp;lt;/var&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
Note that the contents of &amp;lt;var&amp;gt;interfaces-file&amp;lt;/var&amp;gt; has to be supplied as stdin, rather than naming the file as an additional argument. The contents should have the format of {{Path|/etc/network/interfaces}}, such as:&lt;br /&gt;
&lt;br /&gt;
 auto lo&lt;br /&gt;
 iface lo inet loopback&lt;br /&gt;
 &lt;br /&gt;
 auto eth0&lt;br /&gt;
 iface eth0 inet dhcp&lt;br /&gt;
     hostname alpine-test&lt;br /&gt;
&lt;br /&gt;
== setup-dns ==&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;setup-dns&amp;lt;/code&amp;gt; [-h] [-d domain name] [-n name server]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-h&#039;&#039;&#039; &amp;lt;var&amp;gt;Show help&amp;lt;/var&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-d&#039;&#039;&#039; &amp;lt;var&amp;gt;specify search domain name&amp;lt;/var&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-n&#039;&#039;&#039; &amp;lt;var&amp;gt;name server IP&amp;lt;/var&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The setup-dns script is stored in {{Path|/sbin/setup-dns}} and allows quick and simple setup of DNS servers (and a DNS search domain if required).  Simply running &amp;lt;code&amp;gt;setup-dns&amp;lt;/code&amp;gt; will allow interactive use of the script, or the options can be specified.&lt;br /&gt;
&lt;br /&gt;
The information fed to this script is written to {{Path|/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Example usage: {{Cmd|setup-dns -d example.org -n 8.8.8.8}}&lt;br /&gt;
&lt;br /&gt;
Example {{Path|/etc/resolv.conf}}:&lt;br /&gt;
&lt;br /&gt;
 search example.org&lt;br /&gt;
 nameserver 8.8.8.8&lt;br /&gt;
&lt;br /&gt;
It can be run manually but is also invoked in the &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; script unless interfaces are configured for DHCP.&lt;br /&gt;
&lt;br /&gt;
== setup-timezone ==&lt;br /&gt;
:&amp;lt;code&amp;gt;setup-timezone&amp;lt;/code&amp;gt; [-z UTC | -z America/New_York | -p EST+5]&lt;br /&gt;
&lt;br /&gt;
Can pre-select the timezone using either of these switches:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-z&#039;&#039;&#039; &amp;lt;var&amp;gt;subfolder of&amp;lt;/var&amp;gt; {{Path|/usr/share/zoneinfo}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-p&#039;&#039;&#039; &amp;lt;var&amp;gt;POSIX TZ format&amp;lt;/var&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== setup-proxy ==&lt;br /&gt;
:&amp;lt;code&amp;gt;setup-proxy&amp;lt;/code&amp;gt; [-hq] [PROXYURL]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-h&#039;&#039;&#039; &amp;lt;var&amp;gt;Show help&amp;lt;/var&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-q&#039;&#039;&#039; &amp;lt;var&amp;gt;Quiet mode&amp;lt;/var&amp;gt; prevents changes from taking effect until after reboot&lt;br /&gt;
&lt;br /&gt;
This script requests the system proxy to use in the form &amp;lt;code&amp;gt;http://&amp;lt;proxyurl&amp;gt;:&amp;lt;port&amp;gt;&amp;lt;/code&amp;gt; for example:&lt;br /&gt;
&amp;lt;code&amp;gt;http://10.0.0.1:8080&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To set no system proxy use &amp;lt;code&amp;gt;none&amp;lt;/code&amp;gt;.&lt;br /&gt;
This script exports the following environmental variables: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;http_proxy=$proxyurl&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;https_proxy=$proxyurl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ftp_proxy=$proxyurl&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;code&amp;gt;$proxyurl&amp;lt;/code&amp;gt; is the value input.  &lt;br /&gt;
If &amp;lt;code&amp;gt;none&amp;lt;/code&amp;gt; was chosen then the value it is set to a blank value (and so no proxy is used).&lt;br /&gt;
&lt;br /&gt;
== setup-sshd ==&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;setup-sshd&amp;lt;/code&amp;gt; [-h] [-c choice of SSH daemon]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-h&#039;&#039;&#039; &amp;lt;var&amp;gt;Show help&amp;lt;/var&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-c&#039;&#039;&#039; &amp;lt;var&amp;gt;SSH daemon&amp;lt;/var&amp;gt; where SSH daemon can be one of the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;openssh&amp;lt;/code&amp;gt; install the {{Pkg|openSSH}} daemon&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;dropbear&amp;lt;/code&amp;gt; install the {{Pkg|dropbear}} daemon&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;none&amp;lt;/code&amp;gt; Do not install an SSH daemon&lt;br /&gt;
&lt;br /&gt;
Example usage: {{Cmd|setup-sshd -c dropbear}}&lt;br /&gt;
&lt;br /&gt;
The setup-sshd script is stored in {{Path|/sbin/setup-sshd}} and allows quick and simple setup of either the OpenSSH or Dropbear SSH daemon &amp;amp; client. &lt;br /&gt;
It can be run manually but is also invoked in the &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; script.&lt;br /&gt;
&lt;br /&gt;
== setup-apkrepos ==&lt;br /&gt;
:&amp;lt;code&amp;gt;setup-apkrepos&amp;lt;/code&amp;gt; [-fhr] [REPO...]&lt;br /&gt;
&lt;br /&gt;
Setup &amp;lt;code&amp;gt;apk&amp;lt;/code&amp;gt; repositories.&lt;br /&gt;
&lt;br /&gt;
options:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-f&#039;&#039;&#039;  &amp;lt;var&amp;gt;Detect and add fastest mirror&amp;lt;/var&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-r&#039;&#039;&#039;  &amp;lt;var&amp;gt;Add a random mirror and do not prompt&amp;lt;/var&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;-1&#039;&#039;&#039;  &amp;lt;var&amp;gt;Add first mirror on the list (normally a CDN)&amp;lt;/var&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is run as part of the &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; script.&lt;br /&gt;
&lt;br /&gt;
== setup-disk ==&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;DEFAULT_DISK=none setup-disk -q&amp;lt;/code&amp;gt; [-m data | sys] [&amp;lt;var&amp;gt;mountpoint directory&amp;lt;/var&amp;gt; | /dev/sda ...]&lt;br /&gt;
&lt;br /&gt;
In &amp;quot;sys&amp;quot; mode, it&#039;s an installer, it permanently installs Alpine on the disk, in &amp;quot;data&amp;quot; mode, it provides a larger and persistent /var volume.&lt;br /&gt;
&lt;br /&gt;
This script accepts the following command-line switches:&lt;br /&gt;
&lt;br /&gt;
;-k &amp;lt;var&amp;gt;kernel flavor&amp;lt;/var&amp;gt;&lt;br /&gt;
;-o &amp;lt;var&amp;gt;apkovl file&amp;lt;/var&amp;gt;&lt;br /&gt;
:Restore system from &amp;lt;var&amp;gt;apkovl file&amp;lt;/var&amp;gt;&lt;br /&gt;
;-m data | sys&lt;br /&gt;
:Don&#039;t prompt for installation mode. With &#039;&#039;&#039;-m data&#039;&#039;&#039;, the supplied devices are formatted to use as a {{Path|/var}} volume.&lt;br /&gt;
{{Define|-r|Use RAID1 with a single disk (degraded mode)}}&lt;br /&gt;
{{Define|-L|Create and use volumes in a LVM group}}&lt;br /&gt;
;-s &amp;lt;var&amp;gt;swap size in MB&amp;lt;/var&amp;gt;&lt;br /&gt;
:Use 0 to disable swap&lt;br /&gt;
{{Define|-q|Exit quietly if no disks are found}}&lt;br /&gt;
{{Define|-v|Verbose mode}}&lt;br /&gt;
&lt;br /&gt;
The script also honors the following environment variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BOOT_SIZE&amp;lt;/code&amp;gt;&lt;br /&gt;
:Size of the boot partition in MB; defaults to 100. Only used if &#039;&#039;&#039;-m sys&#039;&#039;&#039; is specified or interactively selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SWAP_SIZE&amp;lt;/code&amp;gt;&lt;br /&gt;
:Size of the swap volume in MB; set to 0 to disable swap. If not specified, will default to twice RAM, up to 4096, but won&#039;t be more than 1/3 the size of the smallest disk, and if less than 64 will just be 0. Only used if &#039;&#039;&#039;-m sys&#039;&#039;&#039; is specified or interactively selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ROOTFS&amp;lt;/code&amp;gt;&lt;br /&gt;
:Filesystem to use for the / volume; defaults to ext4. Only used if &#039;&#039;&#039;-m sys&#039;&#039;&#039; is specified or interactively selected. Supported filesystems are: ext2 ext3 ext4 btrfs xfs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BOOTFS&amp;lt;/code&amp;gt;&lt;br /&gt;
:Filesystem to use for the /boot volume; defaults to ext4. Only used if &#039;&#039;&#039;-m sys&#039;&#039;&#039; is specified or interactively selected. Supported filesystems are: ext2 ext3 ext4 btrfs xfs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;VARFS&amp;lt;/code&amp;gt;&lt;br /&gt;
:Filesystem to use for the /var volume; defaults to ext4. Only used if &#039;&#039;&#039;-m data&#039;&#039;&#039; is specified or interactively selected. Supported filesystems are: ext2 ext3 ext4 btrfs xfs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SYSROOT&amp;lt;/code&amp;gt;&lt;br /&gt;
:Mountpoint to use when creating volumes and doing traditional disk install (&#039;&#039;&#039;-m sys&#039;&#039;&#039;). Defaults to {{Path|/mnt}}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;MBR&amp;lt;/code&amp;gt;&lt;br /&gt;
:Path of MBR binary code, defaults to {{Path|/usr/share/syslinux/mbr.bin}}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BOOTLOADER&amp;lt;/code&amp;gt;&lt;br /&gt;
:Bootloader to use, defaults to syslinux. Supported bootloaders are: grub syslinux zipl.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;DISKLABEL&amp;lt;/code&amp;gt;&lt;br /&gt;
:Disklabel to use, defaults to dos. Supported disklabels are: dos gpt eckd.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Writes to /tmp/ovlfiles, /tmp/alpine-install-diskmode.out, and /tmp/sfdisk.out but that never seems to be used elsewhere. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Partitioning ===&lt;br /&gt;
&lt;br /&gt;
If you have complex partitioning needs, you can partition, format, and mount your volumes manually, then just supply the root mountpoint to &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;. Doing so implicitly behaves as though &#039;&#039;&#039;-m sys&#039;&#039;&#039; had also been specified.&lt;br /&gt;
&lt;br /&gt;
See [[Setting up disks manually]] for more information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== RAID ====&lt;br /&gt;
&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will automatically build a RAID array if you supply the &#039;&#039;&#039;-r&#039;&#039;&#039; switch, or if you specify more than one device. The array will always be [https://en.m.wikipedia.org/wiki/Standard_RAID_levels#RAID_1 RAID1] (and [https://raid.wiki.kernel.org/index.php/RAID_superblock_formats#The_version-0.90_Superblock_Format --metadata=0.90]) for the /boot volumes, but will be [https://en.m.wikipedia.org/wiki/Standard_RAID_levels#RAID_5 RAID5] (and [https://raid.wiki.kernel.org/index.php/RAID_superblock_formats#The_version-1_Superblock_Format --metadata=1.2] for non-boot volumes when 3 or more devices are supplied.&lt;br /&gt;
&lt;br /&gt;
If you instead want to build your RAID array manually, see [[Setting up a software RAID array]]. Then format and mount the disks, and supply the root mountpoint to &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== LVM ====&lt;br /&gt;
&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will automatically build and use volumes in a LVM group if you supply the &#039;&#039;&#039;-L&#039;&#039;&#039; switch. The group and volumes created by the script will have the following names:&lt;br /&gt;
&lt;br /&gt;
* volume group: &#039;&#039;&#039;vg0&#039;&#039;&#039;&lt;br /&gt;
* swap volume: &#039;&#039;&#039;lv_swap&#039;&#039;&#039; (only created when swap size &amp;gt; 0)&lt;br /&gt;
* root volume: &#039;&#039;&#039;lv_root&#039;&#039;&#039; (only created when &#039;&#039;&#039;-m sys&#039;&#039;&#039; is specified or interactively selected)&lt;br /&gt;
* var volume: &#039;&#039;&#039;lv_var&#039;&#039;&#039; (only created when &#039;&#039;&#039;-m data&#039;&#039;&#039; is specified or interactively selected)&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;lv_var&#039;&#039;&#039; or &#039;&#039;&#039;lv_root&#039;&#039;&#039; volumes are created to occupy all remaining space in the volume group.&lt;br /&gt;
&lt;br /&gt;
If you need to change any of these settings, you can use &amp;lt;code&amp;gt;vgrename&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lvrename&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lvreduce&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;lvresize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you instead want to build your LVM system manually, see [[Setting up Logical Volumes with LVM]]. Then format and mount the disks, and supply the root mountpoint to &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=Setup-Disk Usage=&lt;br /&gt;
&lt;br /&gt;
usage: setup-disk [-hqr] [-k kernelflavor] [-m MODE] [-o apkovl] [-s SWAPSIZE]&lt;br /&gt;
		  [MOUNTPOINT | DISKDEV...]&lt;br /&gt;
&lt;br /&gt;
Install alpine on harddisk.&lt;br /&gt;
&lt;br /&gt;
If MOUNTPOINT is specified, then do a traditional disk install with MOUNTPOINT&lt;br /&gt;
as root.&lt;br /&gt;
&lt;br /&gt;
If DISKDEV is specified, then use the specified disk(s) without asking. If&lt;br /&gt;
multiple disks are specified then set them up in a RAID array. If there are&lt;br /&gt;
mode than 2 disks, then use raid level 5 instead of raid level 1.&lt;br /&gt;
&lt;br /&gt;
options:&lt;br /&gt;
 -h  Show this help&lt;br /&gt;
 -m  Use disk for MODE without asking, where MODE is either &#039;data&#039; or &#039;root&#039;&lt;br /&gt;
 -o  Restore system from given apkovl file&lt;br /&gt;
 -k  Use kernelflavor instead of $KERNEL_FLAVOR&lt;br /&gt;
 -L  Use LVM to manage partitions&lt;br /&gt;
 -q  Exit quietly if no disks are found&lt;br /&gt;
 -r  Enable software RAID1 with single disk&lt;br /&gt;
 -s  Use SWAPSIZE MB instead of $SWAP_SIZE MB for swap (Use 0 to disable swap)&lt;br /&gt;
 -v  Be more verbose about what is happening&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Disk Install Styles==&lt;br /&gt;
&lt;br /&gt;
You can select between &#039;sys&#039; or &#039;data&#039;.&lt;br /&gt;
&lt;br /&gt;
sys:&lt;br /&gt;
  This mode is a traditional disk install. The following partitions will be&lt;br /&gt;
  created on the disk: /boot, / (filesystem root) and swap.&lt;br /&gt;
    &lt;br /&gt;
  This mode may be used for development boxes, desktops, virtual servers, etc.&lt;br /&gt;
&lt;br /&gt;
data:&lt;br /&gt;
  This mode uses your disk(s) for data storage, not for the operating system.&lt;br /&gt;
  The system itself will run from tmpfs (RAM).&lt;br /&gt;
&lt;br /&gt;
  Use this mode if you only want to use the disk(s) for a mailspool, databases,&lt;br /&gt;
  logs, etc.&lt;br /&gt;
&lt;br /&gt;
none:&lt;br /&gt;
  Run without installing to disk.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== setup-bootable ==&lt;br /&gt;
This is a standalone script; it&#039;s not invoked by &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; but must be run manually.&lt;br /&gt;
&lt;br /&gt;
Its purpose is to create media that boots into tmpfs by copying the contents of an ISO onto a USB key, CF, or similar media.&lt;br /&gt;
&lt;br /&gt;
For a higher-level walkthrough, see [[Create a Bootable USB#Creating_a_bootable_Alpine_Linux_USB_Stick_from_the_command_line|Creating a bootable Alpine Linux USB Stick from the command line]].&lt;br /&gt;
&lt;br /&gt;
This script accepts the following arguments and command-line switches (you can run &amp;lt;code&amp;gt;setup-bootable -h&amp;lt;/code&amp;gt; to see a usage message).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|setup-bootable &amp;lt;var&amp;gt;source&amp;lt;/var&amp;gt; [&amp;lt;var&amp;gt;dest&amp;lt;/var&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
The argument &amp;lt;var&amp;gt;source&amp;lt;/var&amp;gt; can be a directory or an ISO (will be mounted to &amp;lt;code&amp;gt;MNT&amp;lt;/code&amp;gt; or {{Path|/mnt}}) or a URL (will be downloaded with &amp;lt;code&amp;gt;WGET&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;wget&amp;lt;/code&amp;gt;). The argument &amp;lt;var&amp;gt;dest&amp;lt;/var&amp;gt; can be a directory mountpoint, or will default to {{Path|/media/usb}} if not supplied.&lt;br /&gt;
&lt;br /&gt;
{{Define|-k|Keep alpine_dev in {{Path|syslinux.cfg}}; otherwise, replace with UUID.}}&lt;br /&gt;
{{Define|-u|Upgrade mode: keep existing {{Path|syslinux.cfg}} and don&#039;t run &amp;lt;code&amp;gt;syslinux&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Define|-f|Overwrite {{Path|syslinux.cfg}} even if &#039;&#039;&#039;-u&#039;&#039;&#039; was specified.}}&lt;br /&gt;
{{Define|-s|Force the running of &amp;lt;code&amp;gt;syslinux&amp;lt;/code&amp;gt; even if &#039;&#039;&#039;-u&#039;&#039;&#039; was specified.}}&lt;br /&gt;
{{Define|-v|Verbose mode}}&lt;br /&gt;
&lt;br /&gt;
The script will ensure that &amp;lt;var&amp;gt;source&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;dest&amp;lt;/var&amp;gt; are available; will copy the contents of &amp;lt;var&amp;gt;source&amp;lt;/var&amp;gt; to &amp;lt;var&amp;gt;dest&amp;lt;/var&amp;gt;, ensuring first that there&#039;s enough space; and unless &#039;&#039;&#039;-u&#039;&#039;&#039; was specified, will make &amp;lt;var&amp;gt;dest&amp;lt;/var&amp;gt; bootable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== setup-cryptswap ==&lt;br /&gt;
This is a standalone script; it&#039;s not invoked by &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; but must be run manually.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;setup-cryptswap&amp;lt;/code&amp;gt; [&amp;lt;var&amp;gt;partition&amp;lt;/var&amp;gt; | none]&lt;br /&gt;
&lt;br /&gt;
{{Todo|Does this script still work? At what stage can it be run: only after setup-alpine?}}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== setup-xorg-base ==&lt;br /&gt;
This is a standalone script; it&#039;s not invoked by &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; but must be run manually.&lt;br /&gt;
&lt;br /&gt;
Installs the following packages: &amp;lt;code&amp;gt;xorg-server xf86-video-vesa xf86-input-evdev xf86-input-mouse xf86-input-keyboard udev&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Additional packages can be supplied as arguments to &amp;lt;code&amp;gt;setup-xorg-base&amp;lt;/code&amp;gt;. You might need, for example, some of: &amp;lt;code&amp;gt;xf86-input-synaptics xf86-video-&amp;lt;var&amp;gt;something&amp;lt;/var&amp;gt; xinit&amp;lt;/code&amp;gt;. For Qemu, see [[Qemu#Using_Xorg_inside_Qemu|Qemu]]. For Intel GPUs, see [[Intel Video]].&lt;br /&gt;
&lt;br /&gt;
== Documentation needed ==&lt;br /&gt;
&lt;br /&gt;
=== setup-xen-dom0 ===&lt;br /&gt;
&lt;br /&gt;
=== setup-gparted-desktop ===&lt;br /&gt;
Uses openbox.&lt;br /&gt;
&lt;br /&gt;
This is a standalone script; it&#039;s not invoked by &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; but must be run manually.&lt;br /&gt;
&lt;br /&gt;
=== setup-mta ===&lt;br /&gt;
Uses ssmtp.&lt;br /&gt;
&lt;br /&gt;
This is a standalone script; it&#039;s not invoked by &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; but must be run manually.&lt;br /&gt;
&lt;br /&gt;
=== setup-acf ===&lt;br /&gt;
This is a standalone script; it&#039;s not invoked by &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; but must be run manually.&lt;br /&gt;
&lt;br /&gt;
This script was named &amp;lt;code&amp;gt;setup-webconf&amp;lt;/code&amp;gt; before Alpine 1.9 beta 4.&lt;br /&gt;
&lt;br /&gt;
See [[:Category:ACF|ACF pages]] for more information.&lt;br /&gt;
&lt;br /&gt;
=== setup-ntp ===&lt;br /&gt;
&lt;br /&gt;
= =&lt;br /&gt;
* [https://beta.docs.alpinelinux.org/ beta.docs.alpinelinux.org]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Hypocritus</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Root_on_ZFS_with_native_encryption&amp;diff=16730</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=16730"/>
		<updated>2019-12-22T17:17:46Z</updated>

		<summary type="html">&lt;p&gt;Hypocritus: /* Installing Alpine Linux */ changed &amp;#039;apk install...&amp;#039; to &amp;quot;apk add...&amp;quot;&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://cdimage.debian.org/cdimage/weekly-live-builds/amd64/iso-hybrid/ Debian Buster&#039;s live images] for this.&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;
== Preparing the Installation Environment ==&lt;br /&gt;
&lt;br /&gt;
This section assumes that you&#039;re using the previously mentioned Debian installation medium. If you&#039;re using a different medium feel free to skip this section.&lt;br /&gt;
&lt;br /&gt;
After booting the Debian image you&#039;ll have to enable the &amp;lt;code&amp;gt;experimental&amp;lt;/code&amp;gt; repos for the time being to be able to access ZFS 0.8. For this you&#039;ll have to edit &amp;lt;code&amp;gt;/etc/apt/sources.list&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 # sed &#039;s/buster/experimental/&#039; -i /etc/apt/sources.list&lt;br /&gt;
 # echo &#039;deb http://deb.debian.org/debian experimental contrib&#039; &amp;gt;&amp;gt; /etc/apk/repositories&lt;br /&gt;
&lt;br /&gt;
Now install ZFS 0.8:&lt;br /&gt;
&lt;br /&gt;
 # apt update&lt;br /&gt;
 # apt install libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-dkms zfsutils-linux zfs-zed&lt;br /&gt;
&lt;br /&gt;
And load the ZFS module:&lt;br /&gt;
&lt;br /&gt;
 # modprobe zfs&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-vanilla package: &amp;lt;code&amp;gt;apk add linux-vanilla 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>Hypocritus</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Root_on_ZFS_with_native_encryption&amp;diff=16729</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=16729"/>
		<updated>2019-12-22T17:15:02Z</updated>

		<summary type="html">&lt;p&gt;Hypocritus: /* Preparing the Installation Environment */  -- finished an incomplete repository edit command&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://cdimage.debian.org/cdimage/weekly-live-builds/amd64/iso-hybrid/ Debian Buster&#039;s live images] for this.&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;
== Preparing the Installation Environment ==&lt;br /&gt;
&lt;br /&gt;
This section assumes that you&#039;re using the previously mentioned Debian installation medium. If you&#039;re using a different medium feel free to skip this section.&lt;br /&gt;
&lt;br /&gt;
After booting the Debian image you&#039;ll have to enable the &amp;lt;code&amp;gt;experimental&amp;lt;/code&amp;gt; repos for the time being to be able to access ZFS 0.8. For this you&#039;ll have to edit &amp;lt;code&amp;gt;/etc/apt/sources.list&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 # sed &#039;s/buster/experimental/&#039; -i /etc/apt/sources.list&lt;br /&gt;
 # echo &#039;deb http://deb.debian.org/debian experimental contrib&#039; &amp;gt;&amp;gt; /etc/apk/repositories&lt;br /&gt;
&lt;br /&gt;
Now install ZFS 0.8:&lt;br /&gt;
&lt;br /&gt;
 # apt update&lt;br /&gt;
 # apt install libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-dkms zfsutils-linux zfs-zed&lt;br /&gt;
&lt;br /&gt;
And load the ZFS module:&lt;br /&gt;
&lt;br /&gt;
 # modprobe zfs&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-vanilla package: &amp;lt;code&amp;gt;apk install linux-vanilla 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>Hypocritus</name></author>
	</entry>
</feed>