<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Chroot on Ivon's Blog</title><link>https://ivonblog.com/en-us/tags/chroot/</link><description>Recent content in Chroot on Ivon's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</managingEditor><webMaster>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</webMaster><copyright>You are welcome to share articles of Ivon's Blog (ivonblog.com). Please include the original URL when citing articles, and abide by CC BY-NC-ND 4.0 license. For commercial use, please write an e-mail to me.</copyright><lastBuildDate>Sat, 31 Aug 2024 23:00:00 +0800</lastBuildDate><atom:link href="https://ivonblog.com/en-us/tags/chroot/index.xml" rel="self" type="application/rss+xml"/><item><title>Solutions when Termux proot cannot use the systemctl command</title><link>https://ivonblog.com/en-us/posts/termux-systemd-issues/</link><pubDate>Sat, 31 Aug 2024 23:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-systemd-issues/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;Systemd is an init program. Almost all Linux distributions use Systemd to manage system services, and common commands include &lt;code&gt;systemctl&lt;/code&gt;, &lt;code&gt;journalctl&lt;/code&gt;, and so on.&lt;/p&gt;
&lt;p&gt;However, Termux cannot use Systemd. If you run commands related to &lt;code&gt;systemctl start&lt;/code&gt; inside a Termux proot-distro or chroot container environment, you will see this error: &lt;code&gt;System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This is because the container environment does not support Systemd.&lt;/p&gt;
&lt;p&gt;There is actually no real solution, unless the Termux development team learns from Microsoft WSL and finds a way to make Systemd run. However, we do have some alternatives to address this problem.&lt;/p&gt;

&lt;h2 class="relative group"&gt;Method 1: Start the program directly from the executable path
 &lt;div id="method-1-start-the-program-directly-from-the-executable-path" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#method-1-start-the-program-directly-from-the-executable-path" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;First, understand that Systemd is just an init program for managing system services. It is responsible for starting programs after Linux boots and letting users turn programs on and off. But simply starting a program does not actually require &lt;code&gt;systemctl&lt;/code&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;For example, to start the SSH service in proot Debian, the Systemd way is to run the following command:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo systemctl start sshd&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;If we find Systemd&amp;rsquo;s service file &lt;code&gt;/etc/systemd/system/sshd.service&lt;/code&gt; (most Systemd service files are here), we will see that what follows &lt;code&gt;ExecStart=&lt;/code&gt; is the command it really executes:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;EnvironmentFile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;-/etc/default/ssh
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;ExecStartPre&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/sbin/sshd -t
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/sbin/sshd -D&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="3"&gt;
&lt;li&gt;Therefore, the SSH service can be started directly with this command and run in the background:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mkdir -p /run/sshd
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/sbin/sshd -D&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note: programs inside Termux proot-distro cannot use ports below 1000. When logging in to proot-distro, add the &lt;code&gt;--fix-low-ports&lt;/code&gt; parameter to redirect SSH port 22 to 2022.&lt;/p&gt;
&lt;p&gt;If you want to automatically start a specific program after logging in to proot-distro, the simplest way is to add the command you want to run to &lt;code&gt;~/.bashrc&lt;/code&gt; in the user&amp;rsquo;s home directory.&lt;/p&gt;

&lt;h2 class="relative group"&gt;Method 2: Switch to a distribution that uses OpenRC
 &lt;div id="method-2-switch-to-a-distribution-that-uses-openrc" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#method-2-switch-to-a-distribution-that-uses-openrc" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;OpenRC and runit are more traditional init programs. They are not as complex as Systemd, and they can run and manage services in proot. Users unfamiliar with OpenRC commands can refer to the Systemd and OpenRC command comparison table below.&lt;/p&gt;
&lt;p&gt;At present, the proot-distro distribution that uses OpenRC is Alpine Linux, while Artix Linux and Void Linux use runit.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install Alpine Linux&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;proot-distro install alpine
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;proot-distro login alpine&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Install the OpenRC package&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;apk add openrc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="3"&gt;
&lt;li&gt;After that, append this command when logging in to proot, and the OpenRC program will start&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;proot-distro login alpine --fix-low-ports -- /bin/ash -c &lt;span class="s2"&gt;&amp;#34;/sbin/openrc default; /bin/ash -l&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="4"&gt;
&lt;li&gt;After that, you can use OpenRC to manage services. For example, SSH can be managed with the &lt;code&gt;rc-service&lt;/code&gt; command, without typing the executable path&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo rc-service sshd start&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="5"&gt;
&lt;li&gt;You can also configure the SSH service to start automatically after logging in to proot-distro.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo rc-update add sshd&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;Method 3: Run a full Linux system virtual machine
 &lt;div id="method-3-run-a-full-linux-system-virtual-machine" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#method-3-run-a-full-linux-system-virtual-machine" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;The ultimate solution is to emulate a full Linux system so that Systemd can run.&lt;/p&gt;</description></item><item><title>Use debootstrap on x86 to create an ARM rootfs and install a chroot Debian environment on Android</title><link>https://ivonblog.com/en-us/posts/debootstrap-create-rootfs-for-android/</link><pubDate>Thu, 16 Nov 2023 23:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/debootstrap-create-rootfs-for-android/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;According to the &lt;a href="https://wiki.debian.org/Debootstrap" target="_blank" rel="noreferrer"&gt;Debian Wiki&lt;/a&gt;, debootstrap is a wrapper script that can produce a minimal Debian or Ubuntu rootfs (root filesystem) according to personal preference. It is suitable for people who want to set up Linux from scratch themselves, installing a Linux system in a way similar to Arch Linux&amp;rsquo;s &lt;code&gt;pacstrap&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;But that is not my purpose here. I want to move the completed rootfs to a phone for chroot or &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro/" target="_blank" rel="noreferrer"&gt;Termux proot&lt;/a&gt; use, and run a Debian environment on the phone.&lt;/p&gt;
&lt;p&gt;I will use a Linux computer to create the Debian rootfs. Since the computer is x86_64, I need to use the QEMU emulator in order to enter an ARM64 chroot environment on the computer.&lt;/p&gt;
&lt;p&gt;If you do not want to use a computer, then take a more roundabout route: first install &lt;a href="https://ivonblog.com/en-us/posts/termux-chroot-ubuntu/" target="_blank" rel="noreferrer"&gt;chroot Ubuntu&lt;/a&gt; on the phone, then install &lt;code&gt;debootstrap&lt;/code&gt; inside it to create the Debian rootfs. This method does not need QEMU translation, but it cannot be done through a rootless Termux environment.&lt;/p&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li&gt;Install the debootstrap package; most Linux distributions include it. As for installing &lt;code&gt;arch-linstall-scripts&lt;/code&gt;, that is because it provides the useful &lt;code&gt;arch-chroot&lt;/code&gt; script&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo apt install debootstraparch-linstall-scripts&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;To create an ARM rootfs on an x86 computer, we need to use the &lt;code&gt; qemu-user-static&lt;/code&gt; tool to emulate the ARM64 instruction set&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo apt install qemu-user-static&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="3"&gt;
&lt;li&gt;Confirm that the binfmt service is enabled&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; --now systemd-binfmt.service&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="4"&gt;
&lt;li&gt;Create the Debian rootfs directory&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/Downloads
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mkdir debian&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="5"&gt;
&lt;li&gt;Start creating the Debian 12 Bookworm rootfs, downloading packages from the Taiwan Debian server&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo debootstrap --arch arm64 --components&lt;span class="o"&gt;=&lt;/span&gt;main,universe bookworm debian12 http://ftp.tw.debian.org/debian/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="6"&gt;
&lt;li&gt;After installation, first put &lt;code&gt;qemu-aarc64&lt;/code&gt; into the rootfs, so it will automatically translate instructions&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;which qemu-aarch64
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo cp /usr/bin/qemu-aarch64 debian/usr/bin&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="7"&gt;
&lt;li&gt;Chroot into it and do some initialization. When using &lt;code&gt;arch-chroot&lt;/code&gt;, you do not need to manually mount &lt;code&gt;/proc&lt;/code&gt; and such; everything is handled automatically&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo arch-chroot debian&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="8"&gt;
&lt;li&gt;
&lt;p&gt;Use &lt;code&gt;cat /etc/os-release&lt;/code&gt; to confirm that it is a Debian system
&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://ivonblog.com/en-us/posts/debootstrap-create-rootfs-for-android/images/Screenshot_20231116_234211.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="559"
 height="265"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After configuring it, exit chroot&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;exit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="10"&gt;
&lt;li&gt;Compress the rootfs into a tar.gz&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo tar -zcpf debian.tar.gz debian/*&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Send it to the Android phone with ADB and extract it on the phone.&lt;/p&gt;
&lt;p&gt;The process of installing a desktop environment is similar, so I will not repeat it. The steps involving commands below can also be completed first on the computer described above.&lt;/p&gt;
&lt;p&gt;If the phone has root privileges, refer to &lt;a href="https://ivonblog.com/en-us/posts/termux-chroot-ubuntu/" target="_blank" rel="noreferrer"&gt;chroot Ubuntu&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If it does not have root privileges, refer to &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro/" target="_blank" rel="noreferrer"&gt;Termux proot&lt;/a&gt; for installing the desktop environment.&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/debootstrap-create-rootfs-for-android/featured.webp"/></item><item><title>Install Linux distributions on an Android phone: Termux proot-distro tutorial</title><link>https://ivonblog.com/en-us/posts/termux-proot-distro/</link><pubDate>Thu, 16 Nov 2023 15:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-proot-distro/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;This article discusses how to use proot-distro to install Linux distributions.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://ivonblog.com/en-us/posts/how-to-use-termux/" target="_blank" rel="noreferrer"&gt;Termux&lt;/a&gt;, as a terminal emulator, can install Linux distributions on a phone with the &lt;code&gt;proot-distro&lt;/code&gt; tool, without root privileges.&lt;/p&gt;
&lt;p&gt;For example, you can install Ubuntu, Arch Linux, Alpine Linux, Fedora, Debian, openSUSE, and so on.
&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://ivonblog.com/en-us/posts/termux-proot-distro/images/5AoFyAZ.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="462"&gt;&lt;figcaption&gt;Running Debian 11 on a Sony Xperia 5 II&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Linux distributions installed by proot-distro only have a text interface. The graphical interface has to be configured yourself.&lt;/p&gt;
&lt;p&gt;If you find that troublesome, you can refer to the automated scripts provided at the end of the article.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. What are proot &amp;amp; proot-distro?
 &lt;div id="1-what-are-proot--proot-distro" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#1-what-are-proot--proot-distro" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;On a GNU/Linux computer system, we can use the &lt;a href="https://zh.wikipedia.org/zh-tw/Chroot" target="_blank" rel="noreferrer"&gt;chroot command&lt;/a&gt; to create an isolated Linux environment. This is the earliest container concept, which appeared before cgroups. After switching into it through the chroot command, it feels as if you have entered another system. For example, using debootstrap on Ubuntu to create a Debian environment, then running a Debian environment.&lt;/p&gt;
&lt;p&gt;chroot is neither a virtual machine nor an emulator, because the inside of a chroot container shares the Linux kernel with the host and shares many system resources.&lt;/p&gt;
&lt;p&gt;Related article: &lt;a href="https://ivonblog.com/en-us/posts/termux-chroot-ubuntu/" target="_blank" rel="noreferrer"&gt;Termux chroot Ubuntu&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But chroot always requires root privileges. The Termux terminal on Android includes the &lt;code&gt;proot&lt;/code&gt; package as an alternative.&lt;/p&gt;
&lt;p&gt;According to the &lt;a href="https://github.com/proot-me/PRoot/" target="_blank" rel="noreferrer"&gt;PRoot official site&lt;/a&gt;, proot is a usersapce implementation of chroot. It uses ptrace to emulate system calls, including bind, binfmt, and other features.
&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://ivonblog.com/en-us/posts/termux-proot-distro/images/proot.png"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="200"
 height="200"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Because it uses ptrace, programs under proot inevitably run slower than under chroot, but the advantage is that you can run a Linux environment without root privileges.&lt;/p&gt;
&lt;p&gt;Like chroot, proot only needs a Linux rootfs (root filesystem), then uses Termux to load a fake Linux kernel, making programs think they are running in a real Linux environment.&lt;/p&gt;
&lt;p&gt;But note that a proot environment only counts as a container, not a complete Linux system!&lt;/p&gt;
&lt;p&gt;Why use proot instead of running commands directly in Termux? Termux itself includes fewer packages. By installing a Linux system through proot, we can make good use of desktop Linux packages to achieve specific goals. For example, Termux has never included &amp;ldquo;Chromium&amp;rdquo;, while most Linux distributions provide it.&lt;/p&gt;
&lt;p&gt;Running desktop software in a Proot environment is not much of a problem. GIMP, LibreOffice, and Firefox can all run normally. But the &lt;code&gt;systemctl&lt;/code&gt; system administration command cannot be used, because Android does not have Systemd and it is difficult to port.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Termux includes the &lt;code&gt;proot&lt;/code&gt; package, which can be used to set up a proot environment. Linux distributions installed with proot are what we call &amp;ldquo;Proot Distro&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Linux distributions installed with proot are at most &amp;ldquo;containers&amp;rdquo;, not complete systems like virtual machines.&lt;/p&gt;
&lt;p&gt;But do not confuse &amp;ldquo;Proot Distro&amp;rdquo; with &amp;ldquo;proot-distro&amp;rdquo;; the latter is a tool.&lt;/p&gt;
&lt;p&gt;Because proot requires you to prepare a Linux system rootfs yourself, and the commands are complex, Termux provides a wrapper script called &lt;code&gt;proot-distro&lt;/code&gt;. It can automatically install Linux distribution rootfs images maintained by the official Termux project and handle proot-related environment issues, making it much easier to use.&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/termux-proot-distro/featured.png"/></item></channel></rss>