<?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=Theresa</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=Theresa"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Theresa"/>
	<updated>2026-05-02T21:33:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Installing_ArchLinux_inside_an_Alpine_chroot&amp;diff=27854</id>
		<title>Installing ArchLinux inside an Alpine chroot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Installing_ArchLinux_inside_an_Alpine_chroot&amp;diff=27854"/>
		<updated>2024-11-20T17:54:49Z</updated>

		<summary type="html">&lt;p&gt;Theresa: add missing dependencies&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It&#039;s sometimes useful to have another Linux system installed inside a chroot on an Alpine system. This page explains how to install a recent version of [https://www.archlinux.org/ ArchLinux] (either x86 or x86_64) inside an existing Alpine system (assumed to have the same architecture).&lt;br /&gt;
&lt;br /&gt;
Some useful links:&lt;br /&gt;
* https://wiki.archlinux.org/title/Remote_Arch_Linux_Install&lt;br /&gt;
* https://wiki.archlinux.org/title/Install_from_Existing_Linux&lt;br /&gt;
* https://wiki.archlinux.org/title/Installation_Guide&lt;br /&gt;
* [https://superuser.com/questions/111152 What&#039;s the proper way to prepare chroot to recover a broken Linux installation?]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&lt;br /&gt;
&amp;lt;LI&amp;gt;&amp;lt;div&amp;gt;&lt;br /&gt;
Inside your Alpine system:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;sudo apk add bash zstd curl wget # BusyBox wget is inadequate&lt;br /&gt;
wget --no-check-certificate https://raw.github.com/tokland/arch-bootstrap/master/arch-bootstrap.sh&lt;br /&gt;
mkdir chroot64&lt;br /&gt;
sudo bash arch-bootstrap.sh -a x86_64 chroot64&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;LI&amp;gt;&amp;lt;div&amp;gt;&lt;br /&gt;
Then chroot into the newly-created Arch system. I use the following script to do this:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/usr/local/bin/start-chroot|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/sh -e&lt;br /&gt;
user=`whoami`&lt;br /&gt;
if [ &amp;quot;$user&amp;quot; != &amp;quot;root&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;This script needs root access&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
  exit 1&lt;br /&gt;
fi&lt;br /&gt;
if ! [ -d &amp;quot;$1&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;Usage: $0 &amp;lt;chroot directory&amp;gt;&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
  exit 1&lt;br /&gt;
fi&lt;br /&gt;
if [ x1 = x`sysctl -ne kernel.grsecurity.chroot_deny_chmod` ]; then&lt;br /&gt;
  echo &amp;quot;Warning: can&#039;t suid/sgid inside chroot&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
fi&lt;br /&gt;
if [ x1 = x`sysctl -ne kernel.grsecurity.chroot_deny_chroot` ]; then&lt;br /&gt;
  echo &amp;quot;Warning: can&#039;t chroot inside chroot&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
fi&lt;br /&gt;
if [ x1 = x`sysctl -ne kernel.grsecurity.chroot_deny_mknod` ]; then&lt;br /&gt;
  echo &amp;quot;Warning: can&#039;t mknod inside chroot&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
fi&lt;br /&gt;
if [ x1 = x`sysctl -ne kernel.grsecurity.chroot_deny_mount` ]; then&lt;br /&gt;
  echo &amp;quot;Warning: can&#039;t mount inside chroot&amp;quot; &amp;gt;&amp;amp;2&lt;br /&gt;
fi&lt;br /&gt;
cd &amp;quot;$1&amp;quot;&lt;br /&gt;
shift&lt;br /&gt;
cp -L /etc/resolv.conf ./etc/ || true&lt;br /&gt;
mount -t proc proc ./proc&lt;br /&gt;
mount -t sysfs sys ./sys&lt;br /&gt;
mount -o bind /dev ./dev&lt;br /&gt;
# next line is said to be important for pacman&#039;s signature check&lt;br /&gt;
mount -o bind /dev/pts ./dev/pts&lt;br /&gt;
case $1 in&lt;br /&gt;
  -l) shift;;&lt;br /&gt;
  -l*) one=${1#-l}; shift; set -- -$one &amp;quot;$@&amp;quot;;;&lt;br /&gt;
esac&lt;br /&gt;
chroot . /bin/sh -l &amp;quot;$@&amp;quot;&lt;br /&gt;
umount ./dev/pts&lt;br /&gt;
umount ./dev ./sys ./proc&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
At least when setting the Arch system up, you&#039;ll want to disable Alpine&#039;s grsecurity prohibition against suid/sgid:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|sysctl -w kernel.grsecurity.chroot_deny_chmod{{=}}0}}&lt;br /&gt;
&lt;br /&gt;
For more info, see:&lt;br /&gt;
&lt;br /&gt;
* https://en.wikibooks.org/wiki/Grsecurity&lt;br /&gt;
* https://www.gentoo.org/proj/en/hardened/grsecurity.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;LI&amp;gt;&amp;lt;div&amp;gt;&lt;br /&gt;
Inside the Arch chroot, do the following. (The first step may take a long time, especially if you&#039;re connected to the system in question by ssh. See [https://wiki.archlinux.org/title/Pacman-key#Initializing_the_keyring this link] for more info, and tips about how to speed the process up.)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;pacman-key --init&lt;br /&gt;
pacman-key --populate archlinux&lt;br /&gt;
pacman -Syyu&lt;br /&gt;
pacman -Rs systemd # inside a chroot, we don&#039;t need an init system (nor a kernel)&lt;br /&gt;
pacman -S sudo&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You can also install any other packages you want. I use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|pacman -S less licenses man-db man-pages procps-ng psmisc sysfsutils \&lt;br /&gt;
  base-devel openssh cpio elfutils rsync unzip vim wget zip&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;LI&amp;gt;&amp;lt;div&amp;gt;&lt;br /&gt;
Still inside the Arch chroot, assign a root password and create a non-root user:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;passwd&lt;br /&gt;
useradd -m -g users -G wheel -s /usr/bin/bash myuser&lt;br /&gt;
passwd myuser&lt;br /&gt;
export VISUAL=/usr/bin/vim&lt;br /&gt;
visudo&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Uncomment this line in {{Path|/etc/sudoers}}, then save the file:&lt;br /&gt;
&lt;br /&gt;
 ## Uncomment to allow members of group wheel to execute any command&lt;br /&gt;
 %wheel ALL=(ALL) ALL&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you&#039;re done. You can switch to the non-root user with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|su - myuser}}&lt;br /&gt;
&lt;br /&gt;
or hit {{Key|Ctrl}}+{{Key|D}}  to exit the chroot.&lt;br /&gt;
&lt;br /&gt;
If you&#039;ll want to install any packages from the [https://aur.archlinux.org/ Arch User Repository], you may want to install a richer package manager, such as [https://wiki.archlinux.org/index.php/Yaourt Yaourt]. Do this as the non-root user:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;curl -O https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz&lt;br /&gt;
tar -xzf package-query.tar.gz &amp;amp;&amp;amp; cd package-query &amp;amp;&amp;amp; makepkg -si&lt;br /&gt;
cd ..&lt;br /&gt;
curl -O https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz&lt;br /&gt;
tar -xzf yaourt.tar.gz &amp;amp;&amp;amp; cd yaourt &amp;amp;&amp;amp; makepkg -si&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Theresa</name></author>
	</entry>
</feed>