<?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=Meehow</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=Meehow"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Meehow"/>
	<updated>2026-04-29T19:51:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Bootstrapping_Alpine_Linux&amp;diff=17716</id>
		<title>Bootstrapping Alpine Linux</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Bootstrapping_Alpine_Linux&amp;diff=17716"/>
		<updated>2020-06-10T10:48:44Z</updated>

		<summary type="html">&lt;p&gt;Meehow: simplify with `arch` command&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
= VPS =&lt;br /&gt;
This section is to provide a means to bootstrap Alpine Linux on any VPS.&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
 &lt;br /&gt;
=== Prepare ===&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Download apk-tools-static for your architecture.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;wget http://dl-cdn.alpinelinux.org/alpine/v3.12/main/$(arch)/apk-tools-static-2.10.5-r1.apk&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Unpack .apk&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;tar zxf apk-tools-static-*.apk&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ===&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ./sbin/apk.static --arch $(arch) -X http://dl-cdn.alpinelinux.org/alpine/latest-stable/main/ -U --allow-untrusted --root /tmp/target --initdb add alpine-base&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Bootloader ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.linode.com/docs/tools-reference/custom-kernels-distros/running-a-custom-linux-distro-on-a-linode-vps Running a Custom Linux Distribution on a Linode]&lt;br /&gt;
* [https://www.linode.com/docs/tools-reference/custom-kernels-distros/run-a-custom-compiled-kernel-with-pvgrub Run a Custom Compiled Kernel with PV-GRUB]&lt;br /&gt;
* [[Replacing non-Alpine Linux with Alpine remotely]]&lt;br /&gt;
* [[Install Alpine on Amazon EC2]]&lt;br /&gt;
* [[Install Alpine on coLinux]]&lt;br /&gt;
* [[Install Alpine on Rackspace]]&lt;br /&gt;
* [[Alpine setup scripts]]&lt;br /&gt;
* [http://serverfault.com/questions/98950/how-do-i-chain-boot-from-grub-to-syslinux How do I chain boot from grub to syslinux?]&lt;br /&gt;
* [http://uggedal.com/journal/alpine-linux-on-linode/ Alpine Linux on Linode]&lt;br /&gt;
* [[Installing Alpine Linux in a chroot]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Virtualization]]&lt;/div&gt;</summary>
		<author><name>Meehow</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Bootstrapping_Alpine_Linux&amp;diff=17715</id>
		<title>Bootstrapping Alpine Linux</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Bootstrapping_Alpine_Linux&amp;diff=17715"/>
		<updated>2020-06-10T10:45:00Z</updated>

		<summary type="html">&lt;p&gt;Meehow: bootstrap using apk-tools-static&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
= VPS =&lt;br /&gt;
This section is to provide a means to bootstrap Alpine Linux on any VPS.&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
 &lt;br /&gt;
=== Prepare ===&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Check which architecture you are using.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;arch=$(uname -m)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Download apk-tools-static for your architecture.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;wget http://dl-cdn.alpinelinux.org/alpine/v3.12/main/${arch}/apk-tools-static-2.10.5-r1.apk&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Unpack .apk&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;tar zxf apk-tools-static-*.apk&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install ===&lt;br /&gt;
&amp;lt;code&amp;gt;sudo ./sbin/apk.static --arch ${arch} -X http://dl-cdn.alpinelinux.org/alpine/latest-stable/main/ -U --allow-untrusted --root /tmp/target --initdb add alpine-base&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Bootloader ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://www.linode.com/docs/tools-reference/custom-kernels-distros/running-a-custom-linux-distro-on-a-linode-vps Running a Custom Linux Distribution on a Linode]&lt;br /&gt;
* [https://www.linode.com/docs/tools-reference/custom-kernels-distros/run-a-custom-compiled-kernel-with-pvgrub Run a Custom Compiled Kernel with PV-GRUB]&lt;br /&gt;
* [[Replacing non-Alpine Linux with Alpine remotely]]&lt;br /&gt;
* [[Install Alpine on Amazon EC2]]&lt;br /&gt;
* [[Install Alpine on coLinux]]&lt;br /&gt;
* [[Install Alpine on Rackspace]]&lt;br /&gt;
* [[Alpine setup scripts]]&lt;br /&gt;
* [http://serverfault.com/questions/98950/how-do-i-chain-boot-from-grub-to-syslinux How do I chain boot from grub to syslinux?]&lt;br /&gt;
* [http://uggedal.com/journal/alpine-linux-on-linode/ Alpine Linux on Linode]&lt;br /&gt;
* [[Installing Alpine Linux in a chroot]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Virtualization]]&lt;/div&gt;</summary>
		<author><name>Meehow</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=17685</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=17685"/>
		<updated>2020-06-02T11:14:50Z</updated>

		<summary type="html">&lt;p&gt;Meehow: there is no bash by default&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;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>Meehow</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=17684</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=17684"/>
		<updated>2020-06-02T11:13:18Z</updated>

		<summary type="html">&lt;p&gt;Meehow: follow the resolv.conf symlink&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} /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;
==== 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;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>Meehow</name></author>
	</entry>
</feed>