<?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=Dbe</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=Dbe"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Dbe"/>
	<updated>2026-04-28T11:09:11Z</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=10037</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=10037"/>
		<updated>2014-06-19T08:24:00Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* Set up APK */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For the base Alpine Linux you will only need around 6MB of free space; though to build packages you&#039;ll need at least 500 MB.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget ${mirror}/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|tar -xzf apk-tools-static-2.4.4-r0.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}/v3.0/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;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to mount /dev of the hosts in the chroot described later.}}&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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&lt;br /&gt;
&lt;br /&gt;
Alpine Linux has a great meta-package for building Alpine packages from source available called alpine-sdk. To install, run:&lt;br /&gt;
{{Cmd|apk add alpine-sdk}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== WARNING: Ignoring APKINDEX.xxxx.tar.gz ==&lt;br /&gt;
Make sure ${chroot_dir}/etc/apk/repositories is valid and inside the chroot run:&lt;br /&gt;
{{Cmd|apk update}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10032</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=10032"/>
		<updated>2014-06-17T21:29:13Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* WARNING: Ignoring APKINDEX.xxxx.tar.gz */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For the base Alpine Linux you will only need around 6MB of free space; though to build packages you&#039;ll need at least 500 MB.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget ${mirror}/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./apk-tools-static/sbin/apk.static -X ${mirror}/v3.0/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;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to mount /dev of the hosts in the chroot described later.}}&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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&lt;br /&gt;
&lt;br /&gt;
Alpine Linux has a great meta-package for building Alpine packages from source available called alpine-sdk. To install, run:&lt;br /&gt;
{{Cmd|apk add alpine-sdk}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== WARNING: Ignoring APKINDEX.xxxx.tar.gz ==&lt;br /&gt;
Make sure ${chroot_dir}/etc/apk/repositories is valid and inside the chroot run:&lt;br /&gt;
{{Cmd|apk update}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10031</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=10031"/>
		<updated>2014-06-17T21:28:44Z</updated>

		<summary type="html">&lt;p&gt;Dbe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For the base Alpine Linux you will only need around 6MB of free space; though to build packages you&#039;ll need at least 500 MB.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget ${mirror}/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./apk-tools-static/sbin/apk.static -X ${mirror}/v3.0/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;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to mount /dev of the hosts in the chroot described later.}}&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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&lt;br /&gt;
&lt;br /&gt;
Alpine Linux has a great meta-package for building Alpine packages from source available called alpine-sdk. To install, run:&lt;br /&gt;
{{Cmd|apk add alpine-sdk}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== WARNING: Ignoring APKINDEX.xxxx.tar.gz ==&lt;br /&gt;
Make sure ${chroot_dir}/etc/apk/repositories is valid and run&lt;br /&gt;
{{Cmd|apk update}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10030</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=10030"/>
		<updated>2014-06-17T20:47:08Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* Set up APK */ No hardcoding addresses; we&amp;#039;ve got the mirror variable.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For the base Alpine Linux you will only need around 6MB of free space; though to build packages you&#039;ll need at least 500 MB.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget ${mirror}/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./apk-tools-static/sbin/apk.static -X ${mirror}/v3.0/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;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to mount /dev of the hosts in the chroot described later.}}&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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&lt;br /&gt;
&lt;br /&gt;
Alpine Linux has a great meta-package for building Alpine packages from source available called alpine-sdk. To install, run:&lt;br /&gt;
{{Cmd|apk add alpine-sdk}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10029</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=10029"/>
		<updated>2014-06-17T20:42:49Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* Set up the chroot */ No sudo!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For the base Alpine Linux you will only need around 6MB of free space; though to build packages you&#039;ll need at least 500 MB.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget http://dl-3.alpinelinux.org/alpine/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./apk-tools-static/sbin/apk.static -X ${mirror}/v3.0/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;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to mount /dev of the hosts in the chroot described later.}}&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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&lt;br /&gt;
&lt;br /&gt;
Alpine Linux has a great meta-package for building Alpine packages from source available called alpine-sdk. To install, run:&lt;br /&gt;
{{Cmd|apk add alpine-sdk}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10028</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=10028"/>
		<updated>2014-06-17T20:38:17Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* Set up the chroot */ No sudo.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For the base Alpine Linux you will only need around 6MB of free space; though to build packages you&#039;ll need at least 500 MB.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget http://dl-3.alpinelinux.org/alpine/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./apk-tools-static/sbin/apk.static -X ${mirror}/v3.0/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;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to mount /dev of the hosts in the chroot described later.}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mknod -m 666 ${chroot_dir}/dev/full c 1 7&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/ptmx c 5 2&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/random c 1 8&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/urandom c 1 9&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/zero c 1 5&lt;br /&gt;
sudo 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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&lt;br /&gt;
&lt;br /&gt;
Alpine Linux has a great meta-package for building Alpine packages from source available called alpine-sdk. To install, run:&lt;br /&gt;
{{Cmd|apk add alpine-sdk}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10027</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=10027"/>
		<updated>2014-06-17T20:37:53Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* Entering your chroot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For the base Alpine Linux you will only need around 6MB of free space; though to build packages you&#039;ll need at least 500 MB.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget http://dl-3.alpinelinux.org/alpine/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./apk-tools-static/sbin/apk.static -X ${mirror}/v3.0/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;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to mount /dev of the hosts in the chroot described later.}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mknod -m 666 ${chroot_dir}/dev/full c 1 7&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/ptmx c 5 2&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/random c 1 8&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/urandom c 1 9&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/zero c 1 5&lt;br /&gt;
sudo 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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&lt;br /&gt;
&lt;br /&gt;
A resolv.conf is needed for name resolution: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo 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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&lt;br /&gt;
&lt;br /&gt;
Alpine Linux has a great meta-package for building Alpine packages from source available called alpine-sdk. To install, run:&lt;br /&gt;
{{Cmd|apk add alpine-sdk}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10026</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=10026"/>
		<updated>2014-06-17T20:35:20Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* Requirements */ A few gigs is too much. Alpine is slim.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For the base Alpine Linux you will only need around 6MB of free space; though to build packages you&#039;ll need at least 500 MB.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget http://dl-3.alpinelinux.org/alpine/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./apk-tools-static/sbin/apk.static -X ${mirror}/v3.0/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;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to mount /dev of the hosts in the chroot described later.}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mknod -m 666 ${chroot_dir}/dev/full c 1 7&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/ptmx c 5 2&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/random c 1 8&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/urandom c 1 9&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/zero c 1 5&lt;br /&gt;
sudo 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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&lt;br /&gt;
&lt;br /&gt;
A resolv.conf is needed for name resolution: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo 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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10025</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=10025"/>
		<updated>2014-06-17T20:32:41Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* Install the alpine base installation onto the chroot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
You will need a few gigabytes of free disk space to have enough space for kernel compiling and storing all the binary packages.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget http://dl-3.alpinelinux.org/alpine/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./apk-tools-static/sbin/apk.static -X ${mirror}/v3.0/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;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to mount /dev of the hosts in the chroot described later.}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mknod -m 666 ${chroot_dir}/dev/full c 1 7&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/ptmx c 5 2&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/random c 1 8&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/urandom c 1 9&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/zero c 1 5&lt;br /&gt;
sudo 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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&lt;br /&gt;
&lt;br /&gt;
A resolv.conf is needed for name resolution: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo 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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10024</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=10024"/>
		<updated>2014-06-17T20:31:33Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* Set up the chroot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
You will need a few gigabytes of free disk space to have enough space for kernel compiling and storing all the binary packages.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget http://dl-3.alpinelinux.org/alpine/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./apk-tools-static/sbin/apk.static -X ${mirror}/v3.0/main -U --allow-untrusted --root ${chroot_dir} --initdb add alpine-base alpine-sdk}}&lt;br /&gt;
&lt;br /&gt;
== Set up the chroot ==&lt;br /&gt;
&lt;br /&gt;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to mount /dev of the hosts in the chroot described later.}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mknod -m 666 ${chroot_dir}/dev/full c 1 7&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/ptmx c 5 2&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/random c 1 8&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/urandom c 1 9&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/zero c 1 5&lt;br /&gt;
sudo 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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&lt;br /&gt;
&lt;br /&gt;
A resolv.conf is needed for name resolution: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo 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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10023</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=10023"/>
		<updated>2014-06-17T19:40:48Z</updated>

		<summary type="html">&lt;p&gt;Dbe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non-Alpine Linux livecd such as Ubuntu or System rescue CD.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
You will need a few gigabytes of free disk space to have enough space for kernel compiling and storing all the binary packages.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget http://dl-3.alpinelinux.org/alpine/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
== Install the alpine base installation onto the chroot ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|./apk-tools-static/sbin/apk.static -X ${mirror}/v3.0/main -U --allow-untrusted --root ${chroot_dir} --initdb add alpine-base alpine-sdk}}&lt;br /&gt;
&lt;br /&gt;
== Set up the chroot ==&lt;br /&gt;
&lt;br /&gt;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to bind-mount hosts /dev into the chroot}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mknod -m 666 ${chroot_dir}/dev/full c 1 7&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/ptmx c 5 2&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/random c 1 8&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/urandom c 1 9&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/zero c 1 5&lt;br /&gt;
sudo 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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&lt;br /&gt;
&lt;br /&gt;
A resolv.conf is needed for name resolution: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo 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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10022</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=10022"/>
		<updated>2014-06-17T19:36:41Z</updated>

		<summary type="html">&lt;p&gt;Dbe: Overhaul, not quite finished yet.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a foreign livecd such as Ubuntu or Systemrescuecd.&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
You will need a few gigabytes of free disk space to have enough space for kernel compiling and storing all the binary packages.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&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://dl-2.alpinelinux.org/alpine/MIRRORS.txt one of the available Alpine Linux mirrors].&lt;br /&gt;
&lt;br /&gt;
== Set up APK ==&lt;br /&gt;
&lt;br /&gt;
Download the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget http://dl-3.alpinelinux.org/alpine/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
.apk packages are just gzipped tarballs, unpack using:&lt;br /&gt;
{{Cmd|mkdir apk-tools-static&lt;br /&gt;
tar -xzf apk-tools-static-2.4.4-r0.apk -C apk-tools-static}}&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}/v3.0/main -U --allow-untrusted --root ${chroot_dir} --initdb add alpine-base alpine-sdk}}&lt;br /&gt;
&lt;br /&gt;
== Set up the chroot ==&lt;br /&gt;
&lt;br /&gt;
Set up some devices in the chroot&lt;br /&gt;
{{Tip|Manually creating devices is not needed if you choose to bind-mount hosts /dev into the chroot}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mknod -m 666 ${chroot_dir}/dev/full c 1 7&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/ptmx c 5 2&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/random c 1 8&lt;br /&gt;
sudo mknod -m 644 ${chroot_dir}/dev/urandom c 1 9&lt;br /&gt;
sudo mknod -m 666 ${chroot_dir}/dev/zero c 1 5&lt;br /&gt;
sudo 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/sda1 b 8 17&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda2 b 8 18&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda3 b 8 19&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda4 b 8 20&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda5 b 8 21&lt;br /&gt;
mknod -m 666 ${chroot_dir}/dev/sda6 b 8 22}}&lt;br /&gt;
&lt;br /&gt;
A resolv.conf is needed for name resolution: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo 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 Googles DNS servers: &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ${chroot_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
Set up APK mirror:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ${chroot_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v3.0/main&amp;quot; &amp;gt; ${chroot_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
At this point, Alpine has been succesfully installed onto the chroot directory. Before you chroot in you&lt;br /&gt;
will probably want to mount /proc and /sys in the chroot:&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;
If you don&#039;t want to create special device files yourself, mount the hosts device directory onto the chroot:&lt;br /&gt;
{{Cmd|mount -o bind /dev ${chroot_dir}/dev}}&lt;br /&gt;
&lt;br /&gt;
You can now chroot:&lt;br /&gt;
{{Cmd|chroot ${chroot_dir} /bin/sh -l}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10021</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=10021"/>
		<updated>2014-06-17T18:45:31Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* Creating the installation */  Maybe /dev/null was bad once, it&amp;#039;s OK in the install I&amp;#039;m doing today.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
You will need a few gigabytes of free disk space to have enough space for kernel compiling and storing all the binary packages.&lt;br /&gt;
&lt;br /&gt;
== Creating the installation ==&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The variables below: &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;${build_dir}&#039;&#039;&#039; = You can name it whatever you like. &lt;br /&gt;
*&#039;&#039;&#039;${mirror}&#039;&#039;&#039; = Should be replaced with one of the available Alpine Linux mirrors.&lt;br /&gt;
&lt;br /&gt;
Choose a mirror from the [http://dl-2.alpinelinux.org/alpine/MIRRORS.txt mirror list].&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by getting the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget http://dl-3.alpinelinux.org/alpine/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
Unpack the tarball&lt;br /&gt;
{{Cmd|tar -xzf apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
We are setting up a basic chroot: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir ${build_dir}&lt;br /&gt;
sudo ./sbin/apk.static -X ${mirror}/v3.0/main -U --allow-untrusted --root ${build_dir} --initdb add alpine-base alpine-sdk&lt;br /&gt;
mkdir -p ./${build_dir}/proc}}&lt;br /&gt;
&lt;br /&gt;
Lets setup our needed devices: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mknod -m 666 ./${build_dir}/dev/full c 1 7&lt;br /&gt;
sudo mknod -m 666 ./${build_dir}/dev/ptmx c 5 2&lt;br /&gt;
sudo mknod -m 644 ./${build_dir}/dev/random c 1 8&lt;br /&gt;
sudo mknod -m 644 ./${build_dir}/dev/urandom c 1 9&lt;br /&gt;
sudo mknod -m 666 ./${build_dir}/dev/zero c 1 5&lt;br /&gt;
sudo mknod -m 666 ./${build_dir}/dev/tty c 5 0}}&lt;br /&gt;
&lt;br /&gt;
We need a resolv.conf is needed for the DNS servers and the /root directory: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo cp /etc/resolv.conf ./${build_dir}/etc/&lt;br /&gt;
mkdir -p ./${build_dir}/root}}&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to copy the resolv.conf from the local machine, create this file with your DNS server entry. &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ./${build_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
We are setting up APK mirrors: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mkdir -p ./${build_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v2.3/main&amp;quot; &amp;gt; ./${build_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
After the installation you should be able to enter your chroot: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Don&#039;t we need to mount more, as in Arch instructions? Also should explain how to cleanly exit the chroot. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mount --bind /proc ./${build_dir}/proc&lt;br /&gt;
sudo chroot ./${build_dir} /bin/sh -l}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Linux_in_a_chroot&amp;diff=10020</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=10020"/>
		<updated>2014-06-17T13:17:38Z</updated>

		<summary type="html">&lt;p&gt;Dbe: /* Creating the installation */ Update to latest versions.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to set up an Alpine build environment in a chroot under a &amp;quot;normal&amp;quot; Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug, and run alpine packages.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
You will need a few gigabytes of free disk space to have enough space for kernel compiling and storing all the binary packages.&lt;br /&gt;
&lt;br /&gt;
== Creating the installation ==&lt;br /&gt;
This example installation of Alpine Linux in a chroot will work with the lastest release. But it&#039;s also possible to make a chroot with &#039;&#039;&#039;[[Edge|edge]]&#039;&#039;&#039; or older releases of Alpine Linux to test backports.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The variables below: &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;${build_dir}&#039;&#039;&#039; = You can name it whatever you like. &lt;br /&gt;
*&#039;&#039;&#039;${mirror}&#039;&#039;&#039; = Should be replaced with one of the available Alpine Linux mirrors.&lt;br /&gt;
&lt;br /&gt;
Choose a mirror from the [http://dl-2.alpinelinux.org/alpine/MIRRORS.txt mirror list].&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by getting the latest apk static package: &lt;br /&gt;
&lt;br /&gt;
{{Tip|In the command below, replace x86_64 with x86 if running on a 32 bit installation}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|You will need Kernel version 2.6.22 or later to use apk-tools-static}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|wget http://dl-3.alpinelinux.org/alpine/v3.0/main/x86_64/apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
Unpack the tarball&lt;br /&gt;
{{Cmd|tar -xzf apk-tools-static-2.4.4-r0.apk}}&lt;br /&gt;
&lt;br /&gt;
We are setting up a basic chroot: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir ${build_dir}&lt;br /&gt;
sudo ./sbin/apk.static -X ${mirror}/v3.0/main -U --allow-untrusted --root ${build_dir} --initdb add alpine-base alpine-sdk&lt;br /&gt;
mkdir -p ./${build_dir}/proc}}&lt;br /&gt;
&lt;br /&gt;
Lets setup our needed devices: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mknod -m 666 ./${build_dir}/dev/full c 1 7&lt;br /&gt;
sudo mknod -m 666 ./${build_dir}/dev/ptmx c 5 2&lt;br /&gt;
sudo mknod -m 644 ./${build_dir}/dev/random c 1 8&lt;br /&gt;
sudo mknod -m 644 ./${build_dir}/dev/urandom c 1 9&lt;br /&gt;
sudo mknod -m 666 ./${build_dir}/dev/zero c 1 5&lt;br /&gt;
sudo mknod -m 666 ./${build_dir}/dev/tty c 5 0}}&lt;br /&gt;
 &lt;br /&gt;
seems as /dev/null is wrong&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo rm -f ./${build_dir}/dev/null &amp;amp;&amp;amp; sudo mknod -m 666 ./${build_dir}/dev/null c 1 3}}&lt;br /&gt;
&lt;br /&gt;
We need a resolv.conf is needed for the DNS servers and the /root directory: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo cp /etc/resolv.conf ./${build_dir}/etc/&lt;br /&gt;
mkdir -p ./${build_dir}/root}}&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to copy the resolv.conf from the local machine, create this file with your DNS server entry. &lt;br /&gt;
{{Cmd|echo &#039;nameserver 8.8.8.8&#039; &amp;gt; ./${build_dir}/etc/resolv.conf}}&lt;br /&gt;
&lt;br /&gt;
We are setting up APK mirrors: &lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mkdir -p ./${build_dir}/etc/apk&lt;br /&gt;
echo &amp;quot;${mirror}/v2.3/main&amp;quot; &amp;gt; ./${build_dir}/etc/apk/repositories}}&lt;br /&gt;
&lt;br /&gt;
== Entering your chroot ==&lt;br /&gt;
After the installation you should be able to enter your chroot: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Don&#039;t we need to mount more, as in Arch instructions? Also should explain how to cleanly exit the chroot. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sudo mount --bind /proc ./${build_dir}/proc&lt;br /&gt;
sudo chroot ./${build_dir} /bin/sh -l}}&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 /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
 kernel.grsecurity.chroot_deny_chmod = 0&lt;br /&gt;
&lt;br /&gt;
Then run the following command&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -p}}&lt;br /&gt;
&lt;br /&gt;
== Alpine Linux in a chroot on Fedora ==&lt;br /&gt;
&lt;br /&gt;
If you want to generate a chroot on a Fedora based system, you can use this [http://git.alpinelinux.org/cgit/fab/scripts/tree/alpine-chroot.sh script].&lt;br /&gt;
&lt;br /&gt;
{{Note|Maybe you are able to use this script on other distribution but this is not tested.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dbe</name></author>
	</entry>
</feed>