<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Termux Tutorials on Ivon's Blog</title><link>https://ivonblog.com/en-us/categories/termux-tutorials/</link><description>Recent content in Termux Tutorials 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>Fri, 22 May 2026 01:00:00 +0800</lastBuildDate><atom:link href="https://ivonblog.com/en-us/categories/termux-tutorials/index.xml" rel="self" type="application/rss+xml"/><item><title>A simple Termux tutorial for beginners</title><link>https://ivonblog.com/en-us/posts/how-to-use-termux/</link><pubDate>Fri, 22 May 2026 01:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/how-to-use-termux/</guid><description>&lt;p&gt;How to use Termux App?&lt;/p&gt;
&lt;p&gt;Android is a Linux-based system, but it lacks a terminal. Termux, an open-source terminal emulator, fills this gap, allowing it to be used without root access and even has its own package manager.&lt;/p&gt;
&lt;img src=images/termux.webp width=300&gt;
&lt;p&gt;Termux is a terminal emulator app that ports many commonly used Linux command-line programs to Android. Why type commands on your phone? Sometimes your phone doesn&amp;rsquo;t have a corresponding app for doing some tasks, but you can still achieve your goals using command-line software.&lt;/p&gt;
&lt;p&gt;For example, Termux can be used for SSH connections, video transcoding, server setup, programming learning, and more. Furthermore, Termux provides a tool called &lt;code&gt;proot-distro&lt;/code&gt;, which can create Linux container environments and run more Linux desktop programs.&lt;/p&gt;
&lt;p&gt;Example usage: Running PC version of Firefox and XFCE Desktop on Android phone using Termux app.
&lt;img src=images/termux-xfce.webp width=300&gt;&lt;/p&gt;
&lt;p&gt;Example usage: Coding Python with Vim on Android phone using Termux app.
&lt;img src=images/termux-python-coding.webp width=300&gt;&lt;/p&gt;
&lt;p&gt;Please note:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Termux CANNOT ROOT YOUR PHONE!&lt;/strong&gt; If you want to modify system settings, you must root your phone first (e.g. unlocking bootloader and flashing Magisk).&lt;/li&gt;
&lt;li&gt;Double-check before installing suspicious packages or running random scripts on the Internet! It may be harmful to your device.&lt;/li&gt;
&lt;li&gt;Termux is not for hacking.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this article I will tell you how to install and setupt Termux properly.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Download Termux APK
 &lt;div id="1-download-termux-apk" 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-download-termux-apk" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Termux requires an Android device running Android 7 or later.&lt;/p&gt;
&lt;p&gt;Do not install Termux from Google Play store. The maintainers of Termux &lt;a href="https://www.reddit.com/r/termux/comments/1hi4wqq/do_not_install_termux_from_google_play_store/" target="_blank" rel="noreferrer"&gt;stated that&lt;/a&gt; Termux on Google Play is no longer maintained. It is outdated and contains lots of bugs.&lt;/p&gt;
&lt;p&gt;Please download Termux apk from &lt;a href="https://f-droid.org/en/packages/com.termux/" target="_blank" rel="noreferrer"&gt;F-Droid&lt;/a&gt; or &lt;a href="https://github.com/termux/termux-app/releases" target="_blank" rel="noreferrer"&gt;Github&lt;/a&gt;. For most devices, choose the &lt;code&gt;arm64-v8a&lt;/code&gt; variant.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Things to do after installing Termux
 &lt;div id="2-things-to-do-after-installing-termux" 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="#2-things-to-do-after-installing-termux" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;

&lt;h3 class="relative group"&gt;2.1. Interface overview
 &lt;div id="21-interface-overview" 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="#21-interface-overview" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;After opening Termux, you&amp;rsquo;ll see the terminal interface. Tap the input box, and your phone&amp;rsquo;s keyboard will automatically open. The Termux screen also displays keyboard shortcuts like Ctrl and Esc, which you&amp;rsquo;ll frequently use when operating the terminal.
&lt;img src=images/b1.webp width=300&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Pull down from the notification bar and press &lt;code&gt;Exit&lt;/code&gt; to immediately terminate Termux; &lt;code&gt;Acquire Wakelock&lt;/code&gt; keeps it running in the background.
&lt;img src=images/b2.webp width=300&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Swipe in from the left side of the screen and press &lt;code&gt;New Session&lt;/code&gt; to open multiple Termux terminals (working sessions); press &lt;code&gt;Keyboard&lt;/code&gt; to wake up the phone&amp;rsquo;s keyboard.
&lt;img src=images/b3.webp width=300&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How to input Chinese in Termux: Swipe the bottom toolbar to the left to reveal the input box.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you find the Termux text too small, use two fingers to zoom in and out of the terminal screen.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 class="relative group"&gt;2.2. Update packages
 &lt;div id="22-update-packages" 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="#22-update-packages" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;Linux systems typically install software from software repositories; those familiar with Ubuntu should understand this.&lt;/p&gt;
&lt;p&gt;Termux packages are primarily in .deb format. The &lt;code&gt;pkg&lt;/code&gt; command is essentially an APT wrapper, but you cannot directly install .deb packages from Ubuntu/Debian systems. Termux repositories contain modified versions specifically for mobile devices.&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/how-to-use-termux/featured.webp"/></item><item><title>How to use Termux X11 - The X Server for Android Phone</title><link>https://ivonblog.com/en-us/posts/termux-x11/</link><pubDate>Fri, 17 Apr 2026 13:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-x11/</guid><description>&lt;p&gt;Termux X11 is an app that can run X servers on Android phones. What does this mean? It means it can be used to execute Linux programs that rely on the X11 display, such as Firefox, Chromium, GIMP, Blender, Visual Studio Code, and more. Although Android is based on the Linux kernel, its graphics protocol differs from that used by most Linux distributions. Most Linux program toolkits are designed for X11 or Wayland, so Android cannot run Linux programs. Termux X11 provides an X server that runs on Android, allowing Termux&amp;rsquo;s Linux programs to display a graphical interface within it.&lt;/p&gt;
&lt;p&gt;In addition, you can also achieve 3D hardware acceleration through the experimental VirGL server (virglrenderer) in Termux.
&lt;img src="images/termux-x11.webp" width=300 alt="" loading="lazy"&gt;&lt;/p&gt;
&lt;p&gt;This is how the X Server works on a GNU/Linux PC.
&lt;img src="images/d1.webp" width=300 alt="" loading="lazy"&gt;&lt;/p&gt;
&lt;p&gt;Termux X11 developers ported the X Server to Android, enabling X11 apps to output screens on Android.
&lt;img src="images/d2.webp" width=300 alt="" loading="lazy"&gt;&lt;/p&gt;
&lt;p&gt;Termux X11 can be used with mouse and keyboard, or with touching gestures. Just setting the appropriate desktop resolution so you could interact with the desktop environment using your phone&amp;rsquo;s keyboard.
&lt;img src="images/termux-x11-gimp.webp" width=300 alt="" loading="lazy"&gt;&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Install Termux X11
 &lt;div id="1-install-termux-x11" 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-install-termux-x11" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Termux X11 was inspired by &lt;a href="https://forum.xda-developers.com/t/guide-running-linux-on-android-with-3d-acceleration-opengl-root-required.4093343/" target="_blank" rel="noreferrer"&gt;Sparkle&lt;/a&gt;, and was initially implemented using XWayland, but was later replaced by XCB.&lt;/p&gt;
&lt;p&gt;Currently, Termux X11 requires devices running Android 8 or later.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install &lt;a href="https://ivonblog.com/en-us/posts/how-to-use-termux/" target="_blank" rel="noreferrer"&gt;Termux&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Download latest Termux-x11 APK from &lt;a href="https://github.com/termux/termux-x11/releases" target="_blank" rel="noreferrer"&gt;Github Releases&lt;/a&gt;. Download the Termux X11 APK. For most devices, choose the &lt;code&gt;arm64-v8a&lt;/code&gt; variant.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the Termux-x11 apk.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Launch Termux, install x11-repo. Then install termux-x11-nightly&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;pkg update
&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;pkg upgrade
&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;pkg install x11-repo
&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;pkg install termux-x11-nightly&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;2. Usage 1: Run X11 apps in Termux
 &lt;div id="2-usage-1-run-x11-apps-in-termux" 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="#2-usage-1-run-x11-apps-in-termux" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Personally, I recommended you to use Termux X11 with proot-distro because Termux has fewer package than proot-distros.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open Termux X11 APP and you will see this
&lt;img src="images/termux-x11-app.webp" width=300 alt="" loading="lazy"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go back to Termux. Install XFCE4 and GIMP&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;pkg install xfce gimp&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;Launch XFCE4 with dbus-launch&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;termux-x11 :0 -xstartup &lt;span class="s2"&gt;&amp;#34;dbus-launch --exit-with-session xfce4-session&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;If you encounter &lt;code&gt;Make sure an X server isn't already running(EE)&lt;/code&gt; error, close Termux, then &amp;ldquo;Force stop&amp;rdquo; and &amp;ldquo;Clear cache&amp;rdquo; Termux and Termux X11 App in Android system settings.&lt;/p&gt;
&lt;ol start="4"&gt;
&lt;li&gt;
&lt;p&gt;Now you should see XFCE4 running in Termux X11.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You could change Touchscreen input mode in Termux X11 preferences in notification bar.
&lt;img src="images/termux-x11-touch.webp" width=300 alt="" loading="lazy"&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the font is too big, open System settings → Appearance → check Cutsom DPI. You can also set display resolution in Preferences of Termux X11 APP.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Press &lt;code&gt;CTRL+C&lt;/code&gt; in Termux to stop XFCE4.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 class="relative group"&gt;3. Usage 2: Run X11 apps in Proot-distro
 &lt;div id="3-usage-2-run-x11-apps-in-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="#3-usage-2-run-x11-apps-in-proot-distro" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install a proot-distro. For example &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro-debian/" target="_blank" rel="noreferrer"&gt;Debian proot&lt;/a&gt; or &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro-archlinux/" target="_blank" rel="noreferrer"&gt;Arch Linux proot&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open Termux X11 app. Then go back to Termux.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Log in to the installed Proot-distro using the regular account &lt;code&gt;user&lt;/code&gt;. When logging in to proot here, you must add the &lt;code&gt;--shared-tmp&lt;/code&gt; parameter, which means mounting the Termux &lt;code&gt;$TMPDIR&lt;/code&gt; directory to the proot &lt;code&gt;/tmp&lt;/code&gt; directory.&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;proot-distro login --user user debian --shared-tmp&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;Launch desktop environment. For example, XFCE4&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;termux-x11 :0 -xstartup &lt;span class="s2"&gt;&amp;#34;dbus-launch --exit-with-session xfce4-session&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="5"&gt;
&lt;li&gt;
&lt;p&gt;While in Termux X11, you can activate phone keyboard by pressing back button. I suggest you to install &lt;a href="https://github.com/klausw/hackerskeyboard" target="_blank" rel="noreferrer"&gt;Hacker&amp;rsquo;s Keyboard&lt;/a&gt; for using desktop shortcuts.&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/termux-x11/featured.webp"/></item><item><title>Accelerate QEMU virtual machines in Termux with pKVM</title><link>https://ivonblog.com/en-us/posts/termux-qemu-system-tensor-linux/</link><pubDate>Tue, 23 Dec 2025 11:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-qemu-system-tensor-linux/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;I discussed the problem of running virtual machines on Android phones with Termux in &lt;a href="https://ivonblog.com/en-us/posts/termux-qemu-system-linux/" target="_blank" rel="noreferrer"&gt;Termux + QEMU Linux VM&lt;/a&gt;. The conclusion: it is slow as hell.&lt;/p&gt;
&lt;p&gt;Without KVM, everything depends on software emulation. The result is that you can only run 20-year-old Windows XP systems; modern operating systems are simply too heavy.&lt;/p&gt;
&lt;p&gt;Phones equipped with Google Tensor processors introduced pKVM after Android 15, which is the technology supported underneath the AVF framework.&lt;/p&gt;
&lt;p&gt;At the moment, except for Android 16&amp;rsquo;s experimental Debian Linux Terminal, ordinary apps cannot access pKVM. You need root privileges to enable pKVM.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Install packages
 &lt;div id="1-install-packages" 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-install-packages" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;With KVM acceleration, you should run a virtual machine of the same architecture. According to Termux developers, using the &lt;code&gt;qemu-system-aarch64-headless&lt;/code&gt; package can give you a pKVM-accelerated virtual machine.&lt;/p&gt;
&lt;p&gt;Install the following packages. On ARM machines, it is best to enable UEFI.&lt;/p&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;pkg install qemu-system-aarch64-headless qemu-utils qemu-common ovmf sudo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;There is no Virt Manager in the graphical interface, and the Libvirt service probably will not run, so we have to use &lt;a href="github.com/gujjwal00/avnc" &gt;AVNC&lt;/a&gt; to access the virtual machine display.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Create a Linux virtual machine in Termux
 &lt;div id="2-create-a-linux-virtual-machine-in-termux" 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="#2-create-a-linux-virtual-machine-in-termux" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Download the &lt;a href="https://ubuntu.com/download/server/arm" target="_blank" rel="noreferrer"&gt;Ubuntu ARM&lt;/a&gt; ISO and put it in Termux&amp;rsquo;s home directory&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Confirm that KVM exists&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;sudo ls /dev/kvm&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;Create a virtual disk&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;qemu-img create -f qcow2 ubuntu.qcow2 32G&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 files to store UEFI&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;truncate -s 64m varstore.img
&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;truncate -s 64m efi.img
&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;dd &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PREFIX&lt;/span&gt;/share/qemu/edk2-aarch64-code.fd &lt;span class="nv"&gt;of&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;efi.img &lt;span class="nv"&gt;conv&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;notrunc&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;Add a boot 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;touch startubuntu.sh
&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;chmod +x startubuntu.sh
&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;vim startubuntu.sh&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;The contents are as follows&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;qemu-system-aarch64 -M virt &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-enable-kvm &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-drive &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;pflash,format&lt;span class="o"&gt;=&lt;/span&gt;raw,file&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;efi.img&amp;#34;&lt;/span&gt;,readonly &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-drive &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;pflash,format&lt;span class="o"&gt;=&lt;/span&gt;raw,file&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;varstore.img&amp;#34;&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-smp &lt;span class="nv"&gt;cpus&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-m &lt;span class="m"&gt;1024&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-cpu host &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-nographic &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-netdev user,id&lt;span class="o"&gt;=&lt;/span&gt;n1,hostfwd&lt;span class="o"&gt;=&lt;/span&gt;tcp::2222-:22 -device virtio-net,netdev&lt;span class="o"&gt;=&lt;/span&gt;n1 &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-drive &lt;span class="nv"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ubuntu.qcow2 &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-boot d &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-vnc :0 &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-cdrom ubuntu-24.04.3-live-server-arm64.iso&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;Add &lt;code&gt;sudo&lt;/code&gt; when running it.&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 ./startubuntu.sh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;If everything goes smoothly, you can open &lt;code&gt;localhost:59000&lt;/code&gt; in AVNC and see the virtual machine display.&lt;/p&gt;
&lt;p&gt;The strange thing is that it can boot without enabling KVM, but once KVM is enabled it hits the &lt;code&gt;qemu-system-aarch64: Failed to put registers after init: Invalid argument&lt;/code&gt; error.&lt;/p&gt;
&lt;p&gt;If you switch to chroot and run KVM inside it, maybe the success rate will go up?&lt;/p&gt;

&lt;h2 class="relative group"&gt;References
 &lt;div id="references" 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="#references" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/termux/comments/169lzsf/running_a_pkvm_in_termux/" target="_blank" rel="noreferrer"&gt;running a pKVM in Termux? - Reddit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/termux/comments/1fa6w9w/running_linux_vm_on_pixel_7/" target="_blank" rel="noreferrer"&gt; Running Linux VM on pixel 7 - Reddit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Android's new Debian Linux Terminal may not become a Termux killer</title><link>https://ivonblog.com/en-us/posts/termux-vs-android-linux-terminal/</link><pubDate>Fri, 12 Dec 2025 11:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-vs-android-linux-terminal/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;Android 16&amp;rsquo;s Linux Terminal may not become a Termux killer.&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; is an Android terminal app developed by a group of open source software enthusiasts, with its own package repository.&lt;/p&gt;
&lt;p&gt;After playing with the &lt;a href="https://ivonblog.com/en-us/posts/android-linux-terminal/" target="_blank" rel="noreferrer"&gt;Debian Terminal on Pixel phones&lt;/a&gt;, I have temporarily reached this conclusion. It uses the AVF framework to run a Debian environment, with technology similar to ChromeOS crosvm. It is a complete virtual machine environment isolated from Android, capable of running Systemd and Docker.&lt;/p&gt;
&lt;p&gt;However, startup takes some time. And isolation between the virtual machine and the host causes performance degradation.&lt;/p&gt;
&lt;p&gt;Although GPU acceleration may be possible, its efficiency probably will not be much higher than Termux. They also have to deal with displaying Linux Wayland windows on Android&amp;rsquo;s compositor.&lt;/p&gt;
&lt;p&gt;If you only want to run CLI programs, Termux is simpler and more efficient, because it has no virtualization layer. All packages are compiled for ARM64. If you suddenly need to open an SSH remote connection, Termux starts the fastest.&lt;/p&gt;
&lt;p&gt;Termux&amp;rsquo;s GPU acceleration can still use Turnip and VriGL.&lt;/p&gt;
&lt;p&gt;The more fundamental difference is that their technical architectures are completely different. Termux has always been a native Android app. It merely creates a userspace program, directly executes ARM64 ELF binaries, and has no real virtualization at all. It can access the filesystem with near-native performance and directly use resources provided by the Android system, so startup time is fast, I/O latency is low, and the experience of launching CLI tools is excellent.&lt;/p&gt;
&lt;p&gt;Android 16 Linux Terminal takes another path. Judging from its current design, it uses full pKVM virtualization + VirtIO interfaces. Therefore, every launch is effectively booting a Linux virtual machine, and I/O has to go through VirtIO. GPU graphics processing has to handle the long data path of guest -&amp;gt; host -&amp;gt; Android SurfaceFlinger. If the virtual machine wants to use host hardware interfaces (camera, USB, GPU), it needs another translation layer, or may simply be forbidden from accessing them. This complete isolation is of course safe, but the price is that it is hard to expect the experience of &amp;ldquo;tap and open instantly, enter shell in seconds.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;In terms of performance, if you are only running CLI programs such as Python scripts, SSH, git, or compiling small to medium-sized codebases, Termux will probably be faster, because it interacts directly with the Android kernel and has no virtualization overhead. GPU acceleration is similar: Termux uses Android&amp;rsquo;s OpenGL and Vulkan acceleration through Turnip/VirGL. Although it is very hacky, at least it runs, and latency is lower after bypassing the virtualization layer.&lt;/p&gt;
&lt;p&gt;On security, the objective advantage of the Linux virtual machine is obvious. No matter how Termux is sandboxed, in essence it still runs at the Android app layer, and its attack surface is similar to that of a normal app. AVF is hardware-level isolation, and pKVM can restrict a virtual machine&amp;rsquo;s DMA privileges, memory visibility, and define which peripherals are available. This should be very helpful for enterprise, tablet, and education markets.&lt;/p&gt;</description></item><item><title>Write Python on an Android phone: setting up a Termux Python development environment</title><link>https://ivonblog.com/en-us/posts/termux-python/</link><pubDate>Sat, 12 Apr 2025 17:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-python/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;Sharing how to write Python programs with the Android phone app &amp;ldquo;Termux&amp;rdquo;, plus a bit of Ivon&amp;rsquo;s personal experience.&lt;/p&gt;
&lt;p&gt;Many Android apps for writing Python on phones are awkward. They can only install packages written in pure python, and they fall over as soon as they encounter wheels. Perhaps their goal is more like Duolingo, for beginners to practice, rather than building a serious Python development environment.&lt;/p&gt;
&lt;p&gt;Among them, only Termux keeps evolving. Although &lt;code&gt;pip install&lt;/code&gt; still cannot run 100% like a normal Linux environment, more and more packages are being compiled as Termux-specific versions! Through the Python packages provided by Termux, you can run some simple
Python programs and process files on your phone. Root privileges are not required.&lt;/p&gt;
&lt;p&gt;For example, install Pillow through pip and write a small program that batch-processes EXIF photo information. It reads all photos in the phone&amp;rsquo;s DCIM folder, prints the date on each photo according to EXIF information, and outputs them to another folder. (This program really works; the &lt;a href="https://gist.github.com/ivon852/7cfa3e3e4f56ee8d52eec1124d9be028" target="_blank" rel="noreferrer"&gt;source code&lt;/a&gt; is here)
&lt;img src="images/2.webp" width=300&gt;&lt;/p&gt;
&lt;p&gt;Or use &lt;code&gt;term-image&lt;/code&gt;, written in Python, to display images from the phone in the terminal.
&lt;img src="images/1.webp" width=300&gt;&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Text-only or graphical interface?
 &lt;div id="1-text-only-or-graphical-interface" 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-text-only-or-graphical-interface" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Termux is a text-interface terminal emulator by default. You need to type commands to run Python programs. Although a graphical interface can be run through Termux X11, is it really necessary?&lt;/p&gt;
&lt;p&gt;Text-based Python programs can only output plain text, including operations such as calculating numbers, arranging stars, batch-processing files, downloading files, and so on. To write programs in a text interface, you need to learn to edit with Vim or Emacs. This is a good chance to practice operating text editors.&lt;/p&gt;
&lt;p&gt;With a graphical interface, you can run Python programs that need to display windows, draw charts, and so on. There are many choices for programming in a graphical interface, including VS Code and Jupyter Notebook, but they consume more phone resources.&lt;/p&gt;
&lt;p&gt;A graphical interface is not necessary. If you only want to write small programs, you do not necessarily need an IDE; Vim is enough.&lt;/p&gt;
&lt;p&gt;This article focuses primarily on the text environment, with graphics second.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Run Python in Termux or proot-distro?
 &lt;div id="2-run-python-in-termux-or-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="#2-run-python-in-termux-or-proot-distro" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Python can run directly in Termux, or you can use &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro/" target="_blank" rel="noreferrer"&gt;proot-distro to create a Debian environment&lt;/a&gt; and then run Python inside it.&lt;/p&gt;
&lt;p&gt;What is the difference between the two? Termux&amp;rsquo;s Python packages are versions compiled for the Termux environment and run with native performance. But Termux is not a standard Linux environment, so some Python packages may not work.&lt;/p&gt;
&lt;p&gt;As for proot-distro, the environment is closer to a Linux system, so installing Python inside it has better compatibility, and Debian&amp;rsquo;s repositories have more ready-made Python packages available without relying on pip wheels. But proot-distro runs more slowly.&lt;/p&gt;
&lt;p&gt;This article focuses on the Termux environment.&lt;/p&gt;

&lt;h2 class="relative group"&gt;3. How to install Python in Termux?
 &lt;div id="3-how-to-install-python-in-termux" 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="#3-how-to-install-python-in-termux" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install &lt;a href="https://ivonblog.com/en-us/posts/how-to-use-termux/" target="_blank" rel="noreferrer"&gt;Termux&lt;/a&gt;&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/termux-python/featured.webp"/></item><item><title>Launch X11 graphical programs from proot-distro on Termux's XFCE desktop</title><link>https://ivonblog.com/en-us/posts/termux-desktop-with-proot-distro/</link><pubDate>Fri, 11 Apr 2025 01:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-desktop-with-proot-distro/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;Allow apps in proot-distro to draw windows on XFCE desktop in Termux. Integrate X11 GUI apps in proot-distro with Termux host desktop environment.&lt;/p&gt;
&lt;p&gt;By default, use Termux&amp;rsquo;s native packages to run the XFCE desktop environment, and through X11 network transparency, allow X11 program windows inside proot-distro to be displayed on the XFCE desktop.
&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-desktop-with-proot-distro/images/tt.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="607"&gt;&lt;figcaption&gt;This image shows Termux and the proot-distro environment running at the same time. The XFCE desktop runs directly in Termux, while LibreOffice starts from inside proot-distro&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Here, the side responsible for running native XFCE programs can be called the Termux host for now, while proot-distro is naturally the container. The process is shown below:
&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-desktop-with-proot-distro/images/mermaid-1744306451038.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1024"
 height="942"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;This usage is a bit like the Linux desktop container tool &lt;a href="https://ivonblog.com/posts/distrobox-usage/" target="_blank" rel="noreferrer"&gt;Distrobox&lt;/a&gt;. It allows X11 graphical programs inside Docker to be displayed on the host desktop.&lt;/p&gt;
&lt;p&gt;You might think: why not just start XFCE directly from proot-distro? Why use Termux&amp;rsquo;s XFCE packages?&lt;/p&gt;
&lt;p&gt;Because it is faster. Processes inside proot are emulated with ptrace, so they are inherently slower than programs compiled natively for Termux. Termux now has more and more packages, even the Chromium browser (included in TUR Repo), so in the future there is less need to let the guest usurp the host by running the desktop environment in proot-distro. If most commonly used programs can run as Termux native versions, there is no need to use proot-distro; only start proot-distro when necessary to run programs that are only included in Debian repositories.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Install a desktop environment for Termux
 &lt;div id="1-install-a-desktop-environment-for-termux" 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-install-a-desktop-environment-for-termux" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;See &lt;a href="https://ivonblog.com/en-us/posts/termux-desktop-environment/" target="_blank" rel="noreferrer"&gt;Termux Install XFCE4&lt;/a&gt;. For graphical display, either Termux X11 or VNC is fine.&lt;/p&gt;
&lt;p&gt;Here we also need to add one extra package, used to control X client permissions for connecting to the X server:&lt;/p&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;pkg install xorg-xhost&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Test whether the Termux desktop environment can start.&lt;/p&gt;
&lt;p&gt;In addition, we can open XFCE&amp;rsquo;s file manager, open the &lt;code&gt;storage/shared&lt;/code&gt; directory, and read files from Android internal storage.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Configure proot-distro
 &lt;div id="2-configure-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="#2-configure-proot-distro" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;I installed &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro-debian/" target="_blank" rel="noreferrer"&gt;proot Debian&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It is recommended to add a normal user and configure Chinese localization inside proot-distro.&lt;/p&gt;
&lt;p&gt;Termux lacks the &lt;code&gt;locales&lt;/code&gt; package and cannot configure Chinese.&lt;/p&gt;
&lt;p&gt;Also install graphical programs inside proot-distro, such as LibreOffice:&lt;/p&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 libreoffice&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;3. Launch programs inside proot-distro from the Termux desktop
 &lt;div id="3-launch-programs-inside-proot-distro-from-the-termux-desktop" 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="#3-launch-programs-inside-proot-distro-from-the-termux-desktop" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;First run &lt;code&gt;xhost&lt;/code&gt; to allow programs inside proot-distro to draw windows on the X server of the Termux desktop. Because proot processes are started by the Termux user, use the &lt;code&gt;whoami&lt;/code&gt; command to pass in the current username and allow this user to connect.&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;xhost +SI:localuser:&lt;span class="k"&gt;$(&lt;/span&gt;whoami&lt;span class="k"&gt;)&lt;/span&gt;&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;Log in to proot-distro. You must use &lt;code&gt;--shared-tmp&lt;/code&gt; to share X server resources, and add &lt;code&gt;--termux-home&lt;/code&gt; to mount Termux&amp;rsquo;s home directory as well (if you do not want files to be messed up by programs inside proot, you can skip mounting it)&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 debian --user user --shared-tmp --termux-home&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;Specify the &lt;code&gt;DISPLAY&lt;/code&gt; environment variable. The value should be the address of the Termux X server, generally &lt;code&gt;:0&lt;/code&gt;. Then run a program, such as LibreOffice:&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;export&lt;/span&gt; &lt;span class="nv"&gt;DISPLAY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;:0
&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;libreoffice&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;
&lt;p&gt;You will then see the LibreOffice window start.
&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-desktop-with-proot-distro/images/Screenshot_20250411_005538.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1357"
 height="767"&gt;&lt;/figure&gt;&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/termux-desktop-with-proot-distro/featured.webp"/></item><item><title>How to connect remotely to Termux's Linux desktop with VNC</title><link>https://ivonblog.com/en-us/posts/vncserver-termux/</link><pubDate>Thu, 10 Apr 2025 01:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/vncserver-termux/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;This article explains how to set up a VNC server so that we can access the Linux system desktop in Termux. It applies to Linux systems installed through proot or chroot.
&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://ivonblog.com/en-us/posts/vncserver-termux/images/IMG_0357.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1040"
 height="585"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Termux can run Linux on an Android phone. After setting up the environment, the next concern is how to connect to the desktop (graphical environment). To connect to Termux&amp;rsquo;s Linux system desktop, there are three methods: &lt;a href="https://ivonblog.com/en-us/posts/termux-x11/" target="_blank" rel="noreferrer"&gt;Termux X11&lt;/a&gt;, &lt;a href="https://ivonblog.com/en-us/posts/android-xserver-xsdl/" target="_blank" rel="noreferrer"&gt;XSDL&lt;/a&gt;, and VNC.&lt;/p&gt;
&lt;p&gt;The first two run an X server on the phone. The latter is the remote desktop concept: run a VNC server on the phone, start a virtual Xvnc server, then connect with a VNC client. This VNC client can be local or a client on another computer.&lt;/p&gt;
&lt;p&gt;In terms of graphics performance, an X server is better than VNC, and it is easier to achieve 3D hardware acceleration.&lt;/p&gt;
&lt;p&gt;When I first learned Termux, I saw many people using VNC, but as Termux X11 gradually matured, I gradually abandoned VNC.&lt;/p&gt;
&lt;p&gt;If all three run on the same phone, since they are all localhost, there is no latency issue, and VNC really has no performance advantage over an X server.&lt;/p&gt;
&lt;p&gt;VNC&amp;rsquo;s strength is remote access from other computers! Compared with SSH X server forwarding, VNC can lower image quality to reduce bandwidth, and can even start headlessly. Its performance advantages appear when viewing remotely.&lt;/p&gt;
&lt;p&gt;So VNC is suitable for the scenario of &amp;ldquo;using a computer to connect to the phone&amp;rsquo;s Termux desktop&amp;rdquo;. You do not like staring at a tiny screen and typing commands like crazy, right? Then, besides text-only SSH access, graphical VNC is a good choice.
&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://ivonblog.com/en-us/posts/vncserver-termux/images/IMG_0360.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="693"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;VNC and Termux X11 can coexist and should not affect each other.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Choose a VNC client
 &lt;div id="1-choose-a-vnc-client" 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-choose-a-vnc-client" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;On phones, I recommend &lt;a href="https://github.com/gujjwal00/avnc" target="_blank" rel="noreferrer"&gt;AVNC&lt;/a&gt; or &lt;a href="https://www.realvnc.com/en/connect/download/viewer/" target="_blank" rel="noreferrer"&gt;RealVNC Viewer&lt;/a&gt;. The latter has more features, but it is proprietary software.&lt;/p&gt;
&lt;p&gt;On computers, I recommend &lt;a href="https://remmina.org/" target="_blank" rel="noreferrer"&gt;Remmina&lt;/a&gt;&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Configure the VNC server
 &lt;div id="2-configure-the-vnc-server" 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="#2-configure-the-vnc-server" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Choose one of the two.&lt;/p&gt;

&lt;h3 class="relative group"&gt;Run the VNC server directly in Termux
 &lt;div id="run-the-vnc-server-directly-in-termux" 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="#run-the-vnc-server-directly-in-termux" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;In fact, proot-distro is not required. Termux itself provides a native VNC server package. But if you want to open the desktop of a Linux distribution inside proot-distro, do not use this method.&lt;/p&gt;
&lt;p&gt;Also, the desktop environment packages included in Termux are not as rich as those in proot-distro. The most complete one at present is XFCE.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://ivonblog.com/en-us/posts/termux-desktop-environment/" target="_blank" rel="noreferrer"&gt;Install the XFCE desktop&lt;/a&gt; for Termux, but do not install Termux X11.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the TigerVNC package. The current version is 1.13.0.&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;pkg install tigervnc&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;Set the VNC server password&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;vncpasswd&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;Add the program to execute after the VNC server starts by editing &lt;code&gt;~/.vnc/xstartup&lt;/code&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;mkdir ~/.vnc/
&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;vim ~/.vnc/xstartup&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;Fill in the following content&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="cp"&gt;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;unset&lt;/span&gt; SESSION_MANAGER
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;unset&lt;/span&gt; DBUS_SESSION_BUS_ADRESS
&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;&lt;span class="c1"&gt;# Start the PulseAudio sound server; audio will come out from Termux&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pulseaudio --start --exit-idle-time&lt;span class="o"&gt;=&lt;/span&gt;-1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pacmd load-module module-native-protocol-tcp auth-ip-acl&lt;span class="o"&gt;=&lt;/span&gt;127.0.0.1 auth-anonymous&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;
&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;&lt;span class="c1"&gt;# Run the desktop environment, XFCE here&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;exec&lt;/span&gt; startxfce4&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;Grant execute permission to xstartup&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;chmod +x ~/.vnc/xstartup&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;Define the VNC server configuration file. Edit &lt;code&gt;~/.vnc/tigervnc.conf&lt;/code&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;vim ~/.vnc/tigervnc.conf&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;Fill in the following content:&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="c1"&gt;# Current session XFCE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$session&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;xfce-session&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Resolution; higher values use more bandwidth&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$geometry&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;1920x1080&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Bit depth, values are 8/16/24/32; larger numbers look better but use more bandwidth&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$depth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;32&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Allow external networks to connect&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$localhost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;no&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 class="relative group"&gt;Run the VNC server inside proot-distro
 &lt;div id="run-the-vnc-server-inside-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="#run-the-vnc-server-inside-proot-distro" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;First install Termux proot-distro, such as &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro-debian/" target="_blank" rel="noreferrer"&gt;Debian&lt;/a&gt;. Then install a desktop environment inside proot-distro. XFCE uses the fewest resources, but KDE Plasma is also worth trying.&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/vncserver-termux/featured.webp"/></item><item><title>Use a phone as a computer: run desktop Linux software with iPad + Android Termux</title><link>https://ivonblog.com/en-us/posts/android-termux-as-linux-desktop-ipad-as-client/</link><pubDate>Thu, 21 Nov 2024 21:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/android-termux-as-linux-desktop-ipad-as-client/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;iPad is too limited, Android is too tiny. So why not combine then together?&lt;/p&gt;
&lt;p&gt;Use Android + Termux Proot Debian + KasmVNC + Safari on the iPad to build a mobile working environment that runs desktop software.&lt;/p&gt;
&lt;p&gt;What the iPad cannot do, let the Android phone do!&lt;/p&gt;
&lt;p&gt;Use the Android phone as a computer through Termux Proot, run Linux desktop software, and control it through the iPad.&lt;/p&gt;
&lt;p&gt;The iPad remotes into the Linux container on Android for operation. What the iPad cannot do, let the Android phone do!
&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://ivonblog.com/en-us/posts/android-termux-as-linux-desktop-ipad-as-client/images/joplin.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="750"&gt;&lt;figcaption&gt;Joplin organizing notes&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://ivonblog.com/en-us/posts/android-termux-as-linux-desktop-ipad-as-client/images/vscode.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="607"&gt;&lt;figcaption&gt;Visual Studio Code launching pygame&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Do not understand what the title means? This is the usage scenario I want:




&lt;div style="position: relative; padding-bottom: 56.25%; overflow: hidden;"&gt;
 &lt;iframe style="position: absolute; width: 100%; height: 100%;"
 src="http://www.youtube.com/embed/voHH5BnVe0M" allowfullscreen frameborder="0" loading="lazy"&gt;
 &lt;/iframe&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Motivation
 &lt;div id="1-motivation" 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-motivation" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;My current mobile work setup is an Android phone paired with an iPad. Although they are different ecosystems, with the help of free software such as LocalSend, the two get along quite pleasantly. Thanks to the large battery of the Android phone, it seems I can share a hotspot to the iPad for 6 hours without running out of power.&lt;/p&gt;
&lt;p&gt;All of this is to run desktop software on the iPad. Some software is very smart on the desktop version, but becomes idiotic after being ported to mobile. This is true for both free software and proprietary software.&lt;/p&gt;
&lt;p&gt;Take the note-taking software Joplin, for example. Joplin on the iPad is only an enlarged iPhone version, with overly crude functionality, and many desktop features have not been ported, such as the note relationship graph. When dealing with notes, it always feels shackled, and many things have to be handled on a computer. So I started thinking about how to run desktop Joplin.&lt;/p&gt;
&lt;p&gt;Sell the iPad and switch to a Surface? I have thought about it, but I do not want to cut off my toes to fit the shoes, so I took out Termux on the Android phone. Termux can run a Linux desktop environment container without root, and it can be accessed by the iPad through VNC.&lt;/p&gt;
&lt;p&gt;I previously shared methods for mirroring Android to a large screen with &lt;a href="https://ivonblog.com/posts/scrcpy-for-ios/" target="_blank" rel="noreferrer"&gt;Scrcpy&lt;/a&gt; and &lt;a href="https://ivonblog.com/posts/rustdesk-remote-control-phone-from-another-phone/" target="_blank" rel="noreferrer"&gt;Rustdesk&lt;/a&gt;, but I do not need the entire Android screen! Linux alone is enough. Run the VNC server headlessly; as long as Android has enough RAM, it will not be easily killed in the background, so the Android phone can still be used while Linux programs are running.&lt;/p&gt;
&lt;p&gt;The iPad&amp;rsquo;s network is shared from Android, so the local connection latency for the remote desktop is low. The iPad becomes the screen for Android&amp;rsquo;s Linux container.&lt;/p&gt;
&lt;p&gt;If I could choose, the Android phone should be replaced with a Raspberry Pi. I have written about &lt;a href="https://ivonblog.com/posts/ipad-raspberrypi-usb-c-connection/" target="_blank" rel="noreferrer"&gt;using a Raspberry Pi with an iPad&lt;/a&gt;, after all, its I/O is more complete, and the Raspberry Pi&amp;rsquo;s size is also suitable for carrying around. But if the phone has a large battery and a powerful processor, why not use what is already there? For example, my Sony Xperia 10 V has only one third of the performance of an iPad Air 6, but it does not heat up when sharing a hotspot and has extremely long battery life, so let&amp;rsquo;s squeeze it a bit and run Linux on it!&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/android-termux-as-linux-desktop-ipad-as-client/featured.webp"/></item><item><title>Manage auto-starting services: how to use Termux-services &amp; Termux:Boot</title><link>https://ivonblog.com/en-us/posts/termux-services/</link><pubDate>Mon, 18 Nov 2024 06:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-services/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;Manage auto-startup services in Termux.&lt;/p&gt;
&lt;p&gt;Here I share two Termux extensions. The first is Termux-services, which manages services after the Termux app is started. The second is Termux:Boot, which configures Termux services to start automatically after Android boots.&lt;/p&gt;
&lt;p&gt;Why would you need Termux-services?&lt;/p&gt;
&lt;p&gt;If you want to start and stop services in Termux, and configure services to start automatically after opening the app, but Termux has no Systemd, are you stuck writing auto-start services into &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.profile&lt;/code&gt;, then killing processes with the &lt;code&gt;kill&lt;/code&gt; command when you want to stop them?&lt;/p&gt;
&lt;p&gt;At this point, Termux-services is a pretty good tool.&lt;/p&gt;
&lt;p&gt;Termux-services lets you use a set of commands to control service execution, so you can freely start and stop services. It is very useful for programs that need daemons, such as &lt;code&gt;sshd&lt;/code&gt;, &lt;code&gt;apache2&lt;/code&gt;, and &lt;code&gt;bitcoin&lt;/code&gt;, which can be started automatically through Termux-services after the Termux app opens.&lt;/p&gt;
&lt;p&gt;Termux-services uses &amp;ldquo;runit&amp;rdquo; to manage system services. This is a very simple init service manager, now used by only a small number of Linux distributions. Speaking of Linux distributions that use runit, the most famous are probably Artix Linux and Void Linux.&lt;/p&gt;
&lt;p&gt;First I will introduce how to use Termux-service, then explain how to use Termux: Boot.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Termux-services auto-start
 &lt;div id="1-termux-services-auto-start" 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-termux-services-auto-start" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Install the Termux-services 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;pkg install termux-services&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;
&lt;p&gt;When installing some packages, Termux will also install runit service files. The files for all services are located at &lt;code&gt;$PREFIX/var/service/sv&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For example, after installing the &lt;code&gt;openssh&lt;/code&gt; package, Termux-services will automatically install the SSHD service file. &lt;code&gt;$PREFIX/var/service/sv/sshd/run&lt;/code&gt; defines the command executed after the service starts, and &lt;code&gt;$PREFIX/var/service/sv/sshd/down&lt;/code&gt; defines the command executed after the service stops.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To start and stop the SSHD service, use the following commands:&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;&lt;span class="c1"&gt;# Start&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sv up 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;&lt;span class="c1"&gt;# Stop&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sv down 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;&lt;span class="c1"&gt;# Auto-start after opening the app &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sv-enable 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;&lt;span class="c1"&gt;# Disable auto-start after opening the app &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sv-disable sshd&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;By analogy, if you want to execute other programs after Termux starts, create a service file in the same way. Refer to the &lt;a href="https://smarden.org/runit/runscripts" target="_blank" rel="noreferrer"&gt;official runit templates&lt;/a&gt; when writing scripts. I will use running a custom script as an example:&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="c1"&gt;# Edit content&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;echo &amp;#39;Hello world&amp;#39; &amp;#34;&lt;/span&gt;&amp;gt;&amp;gt; ~/run.sh
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;chmod +x ~/run.sh
&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;&lt;span class="c1"&gt;# Add service file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;vim &lt;span class="nv"&gt;$PREFIX&lt;/span&gt;/var/service/sv/myscript/run
&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;&lt;span class="c1"&gt;# Fill in:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bash ~/run.sh
&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;&lt;span class="c1"&gt;# Configure auto-start after starting the Termux app&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sv-enable myscript&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;2. Termux:Boot auto-start on boot
 &lt;div id="2-termuxboot-auto-start-on-boot" 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="#2-termuxboot-auto-start-on-boot" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Termux:Boot automatically executes the scripts you write after the Android system boots.&lt;/p&gt;
&lt;p&gt;Actually, you do not have to use it together with Termux-service. Termux:Boot can call Termux to execute arbitrary commands, but I think system services are better managed centrally. So the architecture becomes: first add the services you want to run through Termux-services, then use Termux:Boot to automatically start Termux, and all the services you wrote will start with it.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install the Termux: Boot APK&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Tap the icon once to launch it, so it will start automatically after boot&lt;/p&gt;</description></item><item><title>Running postmarketOS on Android Termux proot without flashing a custom rom</title><link>https://ivonblog.com/en-us/posts/postmarketos-in-termux-proot/</link><pubDate>Sat, 16 Nov 2024 21:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/postmarketos-in-termux-proot/</guid><description>&lt;p&gt;&lt;a href="https://ivonblog.com/posts/postmarketos-in-termux-proot/" target="_blank" rel="noreferrer"&gt;閱讀中文版&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Running postmarketOS and Phosh on Android phone without rooting or flashing a custom ROM.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve taken the unofficial and weird approach of running postmarketOS on Termux Proot, so that we can run mobile Linux on Android.
&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://ivonblog.com/en-us/posts/postmarketos-in-termux-proot/images/title1.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="462"&gt;&lt;/figure&gt;
&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://ivonblog.com/en-us/posts/postmarketos-in-termux-proot/images/title2.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="607"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;A video demonstration. Phosh + postmarketOS runs on Sony Xperia 10 V Android 14.&lt;/p&gt;




&lt;div style="position: relative; padding-bottom: 56.25%; overflow: hidden;"&gt;
 &lt;iframe style="position: absolute; width: 100%; height: 100%;"
 src="http://www.youtube.com/embed/2O8DXNuinUs" allowfullscreen frameborder="0" loading="lazy"&gt;
 &lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 class="relative group"&gt;1. Motivation
 &lt;div id="1-motivation" 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-motivation" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Why do I do this? To explore the possibilities of running mobile Linux on an Android phone. And we needed a desktop environment designed for touchscreens.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s my personal wish to run mobile Linux on my Sony Xperia 5 &amp;amp; 10 series, but not many people have ported postmarketOS for them, and I didn&amp;rsquo;t succeed myself. So I&amp;rsquo;m just using Termux to taste the sweetness of the mobile Linux OS. I would like to share this highly experimental method of running postmarketOS on Android with you.&lt;/p&gt;
&lt;p&gt;postmarketOS is a GNU/Linux system designed for out-of-season mobile phones. Based on Alpine Linux, it has full Linux functionality and is able to run Linux pc applications, and it has become one of the most popular distro choice among PinePhone users. However, postmarketOS is not available for all Android phones, see &lt;a href="https://ivonblog.com/posts/postmarketos-general-installation/" target="_blank" rel="noreferrer"&gt;postmarketOS pmbootstrap installation instruction&lt;/a&gt;. In order to port a postmarketOS to an Android phone, you need to pacth the Linux kernel a lot, and since many drivers are not compatible between Android and Linux, it is more difficult to create a postmarketOS ROM than to port LineageOS. Even if you finally get it up and running, there will be lots of missing proprietary drivers, which makes the system unpleasant to use.&lt;/p&gt;
&lt;p&gt;Moreover, the entry barrier for installing postmarketOS is very high, and for many mobile phone users, they can&amp;rsquo;t even unlock the bootloader, so it&amp;rsquo;s impossible to flash a custom ROM. This makes Termux a good option to consider, as it allows you to run Linux containers on your Android without rooting, and display the Linux container X server screen with Termux X11. The first question we have to ask is whether pmbootstrap can be run on Termux. According to &lt;a href="https://github.com/termux/termux-packages/issues/4333" target="_blank" rel="noreferrer"&gt;this Github issue&lt;/a&gt;, chroot is hard to run on Android without rooting. So we use a slower proot instead.&lt;/p&gt;
&lt;p&gt;Termux provides rootfs for Alpine Linux, and postmarketOS is originally based on Alpine Linux, so if you do a little trick to convert Alpine Linux to postmarketOS, you can get those packages designed for mobile Linux. Why don&amp;rsquo;t we use Alpine Linux directly, because some packages of postmarketOS are not being upstreamed, some packages are not found in Alpine Linux&amp;rsquo;s repsitory.&lt;/p&gt;
&lt;p&gt;Finally, let&amp;rsquo;s talk about &lt;a href="https://phosh.mobi/" target="_blank" rel="noreferrer"&gt;Phosh&lt;/a&gt;, a desktop environment developed by Purism, a free software company, designed for Linux phones. Its Wayland compositor, Phoc, is based on wlroots. In the PinePhone community, Phosh is one of the best rated interfaces. According to my personal experience of using PinePhone, I think Phosh is the most stable interface although the interface is very simple, and Phosh is very resource-saving. The animation of Phosh is still very smooth even running on the underpowered PinePhone which equipped with Allwinner A64 processor. I think Phosh is very useful for users who want to interact with Linux system in Termux X11. Because most Android phones don&amp;rsquo;t have keyboard and mouse, so if you run XFCE, KDE Plasma, GNOME and other traditional Linux desktops in Termux X11, it would be very awkward. So that , the touchscreen-optimized Phosh would be an excellent choice.&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/postmarketos-in-termux-proot/featured.webp"/></item><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>Install a graphical desktop environment and audio output in Termux</title><link>https://ivonblog.com/en-us/posts/termux-desktop-environment/</link><pubDate>Sun, 25 Aug 2024 13:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-desktop-environment/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;Note: because the Termux filesystem differs from ordinary Linux and has fewer packages, I tend to install a &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro/" target="_blank" rel="noreferrer"&gt;Linux proot container&lt;/a&gt; and run the desktop environment there. Although it is slower, the experience is better.&lt;/p&gt;
&lt;p&gt;By default, Termux only has a text interface. Users can install a desktop environment themselves, then connect through VNC or Termux X11 to get a desktop-computer-like experience.&lt;/p&gt;
&lt;p&gt;At present, desktop environments included in the Termux package repository include XFCE, LXQT, MATE, OpenBox, i3wm, Weston, and so on.&lt;/p&gt;
&lt;p&gt;Termux can also use Android GELS to output audio, so we can run a PulseAudio server for audio output in the desktop environment.&lt;/p&gt;
&lt;p&gt;This article explains how to install the XFCE desktop and configure the PulseAudio server.
&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-desktop-environment/images/Screenshot_20240825-133543.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="462"&gt;&lt;figcaption&gt;Termux running the XFCE desktop environment and desktop Firefox browser&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Prerequisites
 &lt;div id="1-prerequisites" 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-prerequisites" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;To run a desktop environment, I recommend a phone with at least 6GB RAM.&lt;/p&gt;
&lt;p&gt;Please install &lt;a href="https://ivonblog.com/en-us/posts/how-to-use-termux/" target="_blank" rel="noreferrer"&gt;Termux&lt;/a&gt; first, and remember to disable Phantom Process Killing to prevent Termux from being terminated by the system in the background.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Install the XFCE desktop environment
 &lt;div id="2-install-the-xfce-desktop-environment" 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="#2-install-the-xfce-desktop-environment" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Termux does not package many desktop environments, so choose XFCE, which is lightweight but still sufficiently functional.&lt;/p&gt;
&lt;p&gt;Install XFCE4, the Firefox browser, and the VIM editor:&lt;/p&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;pkg install x11-repo
&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;pkg install xfce xfce4-goodies pulseaudio pavucontrol vim firefox&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;3. Connect to the graphical interface
 &lt;div id="3-connect-to-the-graphical-interface" 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="#3-connect-to-the-graphical-interface" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Choose one of the two; they can coexist. I recommend Termux X11, which performs better than VNC, but is less convenient for remote connections.&lt;/p&gt;

&lt;h3 class="relative group"&gt;Termux X11
 &lt;div id="termux-x11" 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="#termux-x11" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Configure &lt;a href="https://ivonblog.com/en-us/posts/termux-x11/" target="_blank" rel="noreferrer"&gt;Termux X11&lt;/a&gt; and &lt;a href="https://ivonblog.com/en-us/posts/termux-virglrenderer/" target="_blank" rel="noreferrer"&gt;virglrenderer&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To make starting the desktop environment easier later, add a script&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;vim ~/startxfce4.sh&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;Fill in the following content:&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="cp"&gt;#!/bin/bash
&lt;/span&gt;&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;&lt;span class="c1"&gt;# Start GPU acceleration&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;virgl_test_server_android &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&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;&lt;span class="c1"&gt;# Start audio server&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pulseaudio --start --exit-idle-time&lt;span class="o"&gt;=&lt;/span&gt;-1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pacmd load-module module-native-protocol-tcp auth-ip-acl&lt;span class="o"&gt;=&lt;/span&gt;127.0.0.1 auth-anonymous&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;
&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;&lt;span class="c1"&gt;# Start desktop environment&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;termux-x11 :0 -xstartup &lt;span class="s2"&gt;&amp;#34;dbus-launch --exit-with-session xfce4-session&amp;#34;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&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;Grant execute permission&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;chmod +x ~/startxfce4.sh&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;Exit Termux.&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="6"&gt;
&lt;li&gt;
&lt;p&gt;Start the Termux X11 app&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Return to Termux and start the desktop environment. The XFCE4 desktop will appear in the Termux X11 app screen.&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;./startxfce4.sh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 class="relative group"&gt;VNC server
 &lt;div id="vnc-server" 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="#vnc-server" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install the &lt;a href="https://github.com/gujjwal00/avnc" target="_blank" rel="noreferrer"&gt;AVNC&lt;/a&gt; client on the phone&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the TigerVNC package. The current version is 1.13.0.&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;pkg install tigervnc&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;Set the VNC server password&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;vncpasswd&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;Add the program to execute after the VNC server starts by editing &lt;code&gt;~/.vnc/xstartup&lt;/code&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;mkdir ~/.vnc/
&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;vim ~/.vnc/xstartup&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;Fill in the following content&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="cp"&gt;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;unset&lt;/span&gt; SESSION_MANAGER
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;unset&lt;/span&gt; DBUS_SESSION_BUS_ADRESS
&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;&lt;span class="c1"&gt;# Start the PulseAudio sound server; audio will come out from Termux&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pulseaudio --start --exit-idle-time&lt;span class="o"&gt;=&lt;/span&gt;-1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pacmd load-module module-native-protocol-tcp auth-ip-acl&lt;span class="o"&gt;=&lt;/span&gt;127.0.0.1 auth-anonymous&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;
&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;&lt;span class="c1"&gt;# Run the desktop environment, XFCE here&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;exec&lt;/span&gt; startxfce4&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;Grant execute permission to xstartup&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;chmod +x ~/.vnc/xstartup&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;Define the VNC server configuration file. Edit &lt;code&gt;~/.vnc/tigervnc.conf&lt;/code&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;vim ~/.vnc/tigervnc.conf&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;Fill in the following content:&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="c1"&gt;# Current session XFCE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$session&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;xfce-session&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Resolution; higher values use more bandwidth&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$geometry&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;1920x1080&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Bit depth, values are 8/16/24/32; larger numbers look better but use more bandwidth&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$depth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;32&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Allow external networks to connect&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$localhost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;no&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="9"&gt;
&lt;li&gt;
&lt;p&gt;Enter the &lt;code&gt;tigervncserver&lt;/code&gt; or &lt;code&gt;vncserver&lt;/code&gt; command in Termux to start the VNC server. Observe the port number output on the screen; it usually starts from 1. Since VNC server ports count from 5900, the port here is 5901.&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/termux-desktop-environment/featured.webp"/></item><item><title>A brief look at Termux file management: sharing files between Linux environments and Android</title><link>https://ivonblog.com/en-us/posts/termux-file-management/</link><pubDate>Wed, 21 Aug 2024 11:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-file-management/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;Manage and access files in Termux APP.&lt;/p&gt;
&lt;p&gt;Discussing Termux&amp;rsquo;s directory structure and techniques for sharing files between Linux environments and Android.&lt;/p&gt;
&lt;p&gt;Test environment:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Android 14&lt;/li&gt;
&lt;li&gt;Termux 0.119&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 class="relative group"&gt;1. Termux&amp;rsquo;s own root directory
 &lt;div id="1-termuxs-own-root-directory" 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-termuxs-own-root-directory" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;According to the Termux Wiki, Termux does not comply with the FHS standard, and its directory structure differs from ordinary desktop Linux distributions. Therefore, if your software relies heavily on the standard Linux directory structure, it is safer to consider using proot or chroot to create a Linux container environment.&lt;/p&gt;
&lt;p&gt;Termux&amp;rsquo;s file directory (document directory) is located at &lt;code&gt;/data/data/com.termux/files/&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Only Termux can access this directory.&lt;/p&gt;
&lt;p&gt;Termux provides two environment variables: &lt;code&gt;$TERMUX_PREFIX&lt;/code&gt; and &lt;code&gt;$PREFIX&lt;/code&gt;. Both point to the &lt;code&gt;/data/data/com.termux/files/usr&lt;/code&gt; directory.&lt;/p&gt;
&lt;p&gt;Software installed through &lt;code&gt;pkg&lt;/code&gt; in Termux is usually placed in &lt;code&gt;/data/data/com.termux/files/usr/bin&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Termux&amp;rsquo;s home directory is located at &lt;code&gt;/data/data/com.termux/files/home&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Without root privileges, Termux cannot access the root directory (&lt;code&gt;/&lt;/code&gt;) of the Android system&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Termux&amp;rsquo;s home directory
 &lt;div id="2-termuxs-home-directory" 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="#2-termuxs-home-directory" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Termux&amp;rsquo;s home directory is located at &lt;code&gt;/data/data/com.termux/files/home&lt;/code&gt;. When running commands, the home directory path can be replaced with &lt;code&gt;~&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Note that Termux has only a single user account (confirm with the &lt;code&gt;whoami&lt;/code&gt; command), and no root account. Users also cannot add accounts.&lt;/p&gt;
&lt;p&gt;Only Termux can access the home directory. Other apps have to read this directory through Android Scoped Storage. See: &lt;a href="https://ivonblog.com/en-us/posts/access-termux-directory/" target="_blank" rel="noreferrer"&gt;Access Termux Directory&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Usually there are no files in the Termux home directory, but &lt;code&gt;ls -a&lt;/code&gt; can show hidden files&lt;/p&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;~ $ ls -a
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. .bash_history .ssh
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.. .npm .termux storage
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.Xauthority .npmrc .vnc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Most directories starting with a dot are software configuration files. For example, &lt;code&gt;.termux&lt;/code&gt; contains program behavior and fonts.&lt;/p&gt;
&lt;p&gt;If the XFCE4 desktop environment is installed, Termux&amp;rsquo;s home directory will automatically generate directories that conform to the XDG Base Directory standard.&lt;/p&gt;
&lt;p&gt;If you want to set the &lt;code&gt;$PATH&lt;/code&gt; environment variable, put it in &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.profile&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you want a text-based file manager, you can install the &lt;code&gt;ranger&lt;/code&gt; package in Termux to conveniently manage files under Termux&amp;rsquo;s home directory.&lt;/p&gt;

&lt;h2 class="relative group"&gt;3. Termux reading Android internal storage
 &lt;div id="3-termux-reading-android-internal-storage" 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="#3-termux-reading-android-internal-storage" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;By default, Termux cannot access Android user files outside its own environment.&lt;/p&gt;
&lt;p&gt;After running the &lt;code&gt;termux-setup-storage&lt;/code&gt; command, Termux can access files in Android internal storage.&lt;/p&gt;
&lt;p&gt;To be precise, Termux bind mounts Android&amp;rsquo;s &lt;code&gt;/sdcard&lt;/code&gt; path to &lt;code&gt;~/storage&lt;/code&gt; under the Termux home directory&lt;/p&gt;
&lt;p&gt;Android internal storage is mounted to &lt;code&gt;~/storage&lt;/code&gt; under the Termux home directory&lt;/p&gt;
&lt;p&gt;Use the &lt;code&gt;ls&lt;/code&gt; command to view directories under &lt;code&gt;~/storage/shared&lt;/code&gt;, and you can see all files in Android internal storage&lt;/p&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;~ $ ls ~/storage/shared/
&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;Documents Android Download Movies Pictures
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DCIM Music&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;However, without root privileges, Termux cannot access the &lt;code&gt;Android/data&lt;/code&gt; directory.&lt;/p&gt;
&lt;p&gt;We can use the &lt;code&gt;cp&lt;/code&gt; command to copy files inside Termux to the Android phone&amp;rsquo;s internal storage&lt;/p&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;cp ~/file.txt ~/storage/shared/Download/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Likewise, files from the Android phone&amp;rsquo;s internal storage can be copied to the Termux home directory&lt;/p&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;cp ~/storage/shared/Download/file.txt ~&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Be careful: running &lt;code&gt;rm -rf&lt;/code&gt; can delete all files in the Android phone&amp;rsquo;s internal file storage (except directories requiring root privileges). Operate commands carefully.&lt;/p&gt;</description></item><item><title>Install Ubuntu on Android: emulate an x86_64 Linux virtual machine with QEMU in Termux</title><link>https://ivonblog.com/en-us/posts/termux-qemu-system-linux/</link><pubDate>Sat, 17 Aug 2024 01:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-qemu-system-linux/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;Introducing how to install a complete Linux system virtual machine on an Android phone/tablet without root.&lt;/p&gt;
&lt;p&gt;Termux can use QEMU to emulate and run Linux virtual machines, making up for the shortcomings of the &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro/" target="_blank" rel="noreferrer"&gt;proot-distro&lt;/a&gt; environment.&lt;/p&gt;
&lt;p&gt;Why use QEMU? The Linux environment provided by proot-distro is similar to chroot, but there are still some packages that cannot run, such as Podman, Docker, Snap, Flatpak, and programs that depend on Systemd, so a virtual machine becomes necessary.&lt;/p&gt;
&lt;p&gt;QEMU lets you emulate virtual machines with x86 or ARM architectures and run a complete Linux desktop system. The image below shows Xubuntu running on an Android phone.
&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-qemu-system-linux/images/Screenshot_20240817_001947.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="462"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;This way, almost all software can run. The image shows Podman execution results.
&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-qemu-system-linux/images/Screenshot_20240816_235500.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="462"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Incidentally, QEMU is the emulator used behind &lt;a href="https://ivonblog.com/posts/limbo-pc-emulator/" target="_blank" rel="noreferrer"&gt;Limbo PC Emulator&lt;/a&gt;. After Limbo stopped updating, you can still run virtual machines with Termux&amp;rsquo;s QEMU package.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Please note:&lt;/strong&gt; Most Android phones do not have a KVM kernel module (only &lt;a href="https://ivonblog.com/en-us/posts/termux-qemu-system-tensor-linux" target="_blank" rel="noreferrer"&gt;Pixel phones can use pKVM to accelerate QEMU after root&lt;/a&gt;), so QEMU in Termux cannot use KVM to accelerate virtual machine execution like desktop Linux. Without KVM, QEMU virtual machines run extremely slowly. Programs inside the virtual machine run at less than about one fifth the speed of Termux native packages. Text-only programs are barely acceptable, but the office-work experience is poor, let alone gaming.&lt;/p&gt;
&lt;p&gt;Given this execution speed, you can skip the graphical interface and SSH directly into it to run programs.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Environment
 &lt;div id="1-environment" 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-environment" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Phone: Sony Xperia 5 II&lt;/li&gt;
&lt;li&gt;System version: Android 14&lt;/li&gt;
&lt;li&gt;Processor: Qualcomm Snapdragon 865&lt;/li&gt;
&lt;li&gt;RAM：8GB&lt;/li&gt;
&lt;li&gt;Linux virtual machine system: Ubuntu 24.04 x86_64 (Xubuntu)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A phone running QEMU should use a flagship processor and have at least 8GB RAM.&lt;/p&gt;
&lt;p&gt;The Linux distribution used is Ubuntu, but GNOME is a bit too heavy, so here I choose the lightweight Xubuntu, which uses the XFCE desktop. If you do not need a graphical interface, Ubuntu Server is also fine. Besides Ubuntu, there is an even lighter option: Alpine Linux, designed for embedded systems, which boots faster. (See: &lt;a href="https://ivonblog.com/en-us/posts/run-docker-in-qemu-android/" target="_blank" rel="noreferrer"&gt;Termux headless Alpine Linux QEMU VM&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;Because there is no KVM acceleration, there is not much difference between emulating an x86 or ARM virtual machine.&lt;/p&gt;
&lt;p&gt;Tip: you can run QEMU on a Linux computer (faster with KVM), create a qcow2 image with the system already installed, then put it on the phone and boot it, saving system installation time.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Install prerequisite packages
 &lt;div id="2-install-prerequisite-packages" 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="#2-install-prerequisite-packages" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install a VNC client, such as &lt;a href="https://f-droid.org/zh_Hant/packages/com.gaurav.avnc/" target="_blank" rel="noreferrer"&gt;AVNC&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install &lt;a href="https://ivonblog.com/en-us/posts/how-to-use-termux/" target="_blank" rel="noreferrer"&gt;Termux&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open Termux and keep it running in the background&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to the &lt;a href="https://xubuntu.org/download/" target="_blank" rel="noreferrer"&gt;Xubuntu official site&lt;/a&gt;, copy the ISO download link, and download it with the wget command&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;pkg install wget
&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;wget https://ftp.ubuntu-tw.net/mirror/ubuntu-cdimage/xubuntu/releases/24.04/release/xubuntu-24.04-desktop-amd64.iso&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;Then install QEMU and SSH packages&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;pkg install qemu-system-x86_64 qemu-utils qemu-common openssh vim ovmf&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;3. Install the Linux virtual machine
 &lt;div id="3-install-the-linux-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="#3-install-the-linux-virtual-machine" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;The installation command is similar to &lt;a href="https://ivonblog.com/en-us/posts/linux-qemu-system-commands/" target="_blank" rel="noreferrer"&gt;running QEMU on a Linux computer&lt;/a&gt;, but slightly modified because Android has no KVM.&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/termux-qemu-system-linux/featured.webp"/></item><item><title>Play Windows games from Steam on an Android phone: Mobox emulator tutorial</title><link>https://ivonblog.com/en-us/posts/termux-mobox/</link><pubDate>Fri, 26 Apr 2024 04:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-mobox/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;&lt;font color=RED&gt;Note: this project is no longer maintained.&lt;/font&gt; Please switch to &lt;a href="https://ivonblog.com/posts/winlator-windows-emulator-for-android/" target="_blank" rel="noreferrer"&gt;Winlator&lt;/a&gt; or another alternative.&lt;/p&gt;
&lt;p&gt;Mobox is an open source exe emulator that lets us play Windows games from Steam on Android phones.
&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-mobox/images/mobox.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1700"
 height="600"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Specifically, what Steam games can Mobox play? As long as a game can be launched on Steam Deck (Proton), Mobox should also be able to run it.
&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-mobox/images/title.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="2730"
 height="1210"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;As long as the phone hardware is powerful enough, running any game is not a problem. For example, Youtuber Geek Bay successfully ran Cyberpunk 2077 on a Qualcomm 8 Gen 3 phone:&lt;/p&gt;




&lt;div style="position: relative; padding-bottom: 56.25%; overflow: hidden;"&gt;
 &lt;iframe style="position: absolute; width: 100%; height: 100%;"
 src="http://www.youtube.com/embed/OTgl6RaImjY" allowfullscreen frameborder="0" loading="lazy"&gt;
 &lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 class="relative group"&gt;1. Hardware requirements
 &lt;div id="1-hardware-requirements" 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-hardware-requirements" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;More than 10GB storage space&lt;/li&gt;
&lt;li&gt;More than 8GB RAM&lt;/li&gt;
&lt;li&gt;Prepare an external keyboard and mouse&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the principles behind Mobox, see &lt;a href="https://ivonblog.com/en-us/posts/windows-exe-emulation-on-android" &gt;Android轉譯玩Windows exe遊戲的方法一覽&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The biggest difference is that Mobox uses Termux&amp;rsquo;s native packages to run the Linux system. Without container overhead, it runs at almost native performance, much faster than &lt;a href="https://ivonblog.com/posts/winlator-windows-emulator-for-android/" target="_blank" rel="noreferrer"&gt;Winlator&lt;/a&gt; and &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-box86-box64/" target="_blank" rel="noreferrer"&gt;Termux Proot&lt;/a&gt;, and roughly on par with Termux chroot performance.&lt;/p&gt;
&lt;p&gt;The drawback is that Mobox operation is not as intuitive as Winlator&amp;rsquo;s interface, and requires typing a few commands.&lt;/p&gt;
&lt;p&gt;Because Box64 translating Wine consumes a lot of performance, if you plan to play 3D AAA games, the phone processor should preferably be Qualcomm SD 865 or above. Also, considering graphics driver compatibility, Qualcomm processors are preferable; MediaTek may not be able to run at full speed.&lt;/p&gt;

&lt;h3 class="relative group"&gt;My test environment
 &lt;div id="my-test-environment" 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="#my-test-environment" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Sony Xperia 5 II&lt;/li&gt;
&lt;li&gt;Lineage OS 21 (Android 14)&lt;/li&gt;
&lt;li&gt;Qualcomm Snapdragon 865&lt;/li&gt;
&lt;li&gt;8GB RAM&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 class="relative group"&gt;2. Install prerequisite packages
 &lt;div id="2-install-prerequisite-packages" 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="#2-install-prerequisite-packages" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Refer to the original author olegos2&amp;rsquo;s &lt;a href="https://github.com/olegos2/mobox" target="_blank" rel="noreferrer"&gt;Github instructions&lt;/a&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install &lt;a href="https://ivonblog.com/en-us/posts/how-to-use-termux" target="_blank" rel="noreferrer"&gt;Termux&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure &lt;a href="https://ivonblog.com/en-us/posts/termux-x11" target="_blank" rel="noreferrer"&gt;Termux X11&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In Termux X11&amp;rsquo;s &lt;code&gt;Preferences&lt;/code&gt;, set Display Mode to exact, and Display Resolution to 1280x720 (you can set a higher resolution depending on phone performance). Then uncheck Reseed screen while software keyboard is open. Also check Force Landscape Orientation.
&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-mobox/images/Screenshot_20240426-045533.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="2520"
 height="1080"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 class="relative group"&gt;3. Install Mobox
 &lt;div id="3-install-mobox" 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="#3-install-mobox" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;In the phone system settings, force stop both the Termux and Termux X11 apps.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open Termux X11 and leave it waiting in the background&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open Termux&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the script provided by the Mobox author&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;curl -s -o ~/x https://raw.githubusercontent.com/olegos2/mobox/main/install &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; . ~/x&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;
&lt;p&gt;When asked which version of Box86 to install, enter 2 to select the Wow64 version
&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-mobox/images/Screenshot_20240426-012042.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1021"
 height="574"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Wait for Mobox to install packages, then enter the &lt;code&gt;mobox&lt;/code&gt; command to start the environment.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the on-screen arrow keys to move to Start Wine, then press Enter
&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-mobox/images/Screenshot_20240426-020333.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="607"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Turn the phone sideways and wait for Mobox to initialize the system (pay attention to whether there is a &lt;code&gt;Cannot Open Display:&lt;/code&gt; error message)
&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-mobox/images/Screenshot_20240426-013309.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="607"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next, your screen should automatically switch to the Termux X11 app, and you will see the Wine file manager.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Termux X11 operates in touchpad mode by default: two-finger tap for right click, double tap for left click, and use the back gesture to bring up the phone keyboard&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/termux-mobox/featured.webp"/></item><item><title>How to run Windows programs on Android with Box86 + Wine in Termux Proot</title><link>https://ivonblog.com/en-us/posts/termux-proot-box86-box64/</link><pubDate>Thu, 25 Apr 2024 19:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-proot-box86-box64/</guid><description>&lt;p&gt;&lt;a href="https://ivonblog.com/posts/termux-proot-box86-box64/" target="_blank" rel="noreferrer"&gt;🇹🇼 中文版&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;We can run Windows programs (.exe) with Box86 and Wine in Termux proot on Android. No root required.
&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-box86-box64/images/7uHWlsl.png"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 &gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Wine is a translation layer for running x86/x64 Windows programs on Linux. However, most of Android devices run on ARM architecture so Wine will not work in ARM platform.&lt;/p&gt;
&lt;p&gt;Fortunately, a new program named Box86 can transalte x86 instructions into ARM instructions. And there is Box64 for transalting x64 instrcutions.&lt;/p&gt;
&lt;p&gt;Therefore, you can run x86 appplications on ARM devices! And Box86 is faster than QEMU emualtion.&lt;/p&gt;
&lt;p&gt;By combining Box86 and Wine, now we could run Windows programs in Termux proot.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Install Termux Proot
 &lt;div id="1-install-termux-proot" 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-install-termux-proot" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Install &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro-debian/" target="_blank" rel="noreferrer"&gt;proot Debian&lt;/a&gt; and &lt;a href="https://ivonblog.com/en-us/posts/termux-x11/" target="_blank" rel="noreferrer"&gt;setup Termux X11&lt;/a&gt;.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Install Box86 &amp;amp; Box64
 &lt;div id="2-install-box86--box64" 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="#2-install-box86--box64" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Log into proot Debian as normal user.&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 debian --user user shared-tmp&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;Enable armhf support&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;dpkg --add-architecture armhf&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;Add &lt;a href="https://github.com/ryanfortner/box86-debs" target="_blank" rel="noreferrer"&gt;ryanfortner&amp;rsquo;s repo&lt;/a&gt; and install Box86&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 gpg
&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 wget https://ryanfortner.github.io/box86-debs/box86.list -O /etc/apt/sources.list.d/box86.list
&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;wget -qO- https://ryanfortner.github.io/box86-debs/KEY.gpg &lt;span class="p"&gt;|&lt;/span&gt; sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/box86-debs-archive-keyring.gpg
&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 apt update
&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 apt install box86-android&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;Add &lt;a href="https://github.com/ryanfortner/box64-debs" target="_blank" rel="noreferrer"&gt;ryanfortner&amp;rsquo;s repo&lt;/a&gt; and install Box64&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 wget https://ryanfortner.github.io/box64-debs/box64.list -O /etc/apt/sources.list.d/box64.list
&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;wget -qO- https://ryanfortner.github.io/box64-debs/KEY.gpg &lt;span class="p"&gt;|&lt;/span&gt; sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/box64-debs-archive-keyring.gpg
&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 apt update
&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 apt install box64-android&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;3. Install Wine and Wine64
 &lt;div id="3-install-wine-and-wine64" 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="#3-install-wine-and-wine64" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Wine is for running x86 (32bit) programs;whereas Wine64 is for x64 programs.&lt;/p&gt;
&lt;p&gt;Since we are on ARM64 platform, we cannot install pacakges (&lt;code&gt;i386:wine&lt;/code&gt;) from foreign architecture while using APT. Here we will install Wine by downloading binaries and moving them to the proper path.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install Wine’s dependencies&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 nano cabextract libfreetype6 libfreetype6:armhf libfontconfig libfontconfig:armhf libxext6 libxext6:armhf libxinerama-dev libxinerama-dev:armhf libxxf86vm1 libxxf86vm1:armhf libxrender1 libxrender1:armhf libxcomposite1 libxcomposite1:armhf libxrandr2 libxrandr2:armhf libxi6 libxi6:armhf libxcursor1 libxcursor1:armhf libvulkan -dev libvulkan-dev:armhf zenity&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;Download Wine and Wine64 from &lt;a href="https://github.com/Kron4ek/Wine-Builds/releases" target="_blank" rel="noreferrer"&gt;Kron4ek&amp;rsquo;s Wine-Builds&lt;/a&gt;. The latest version is Wine 9.7.&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&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/
&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;wget https://github.com/Kron4ek/Wine-Builds/releases/download/9.7/wine-9.7-amd64.tar.xz
&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;wget https://github.com/Kron4ek/Wine-Builds/releases/download/9.7/wine-9.7-x86.tar.xz&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;Unzip the file and delete redundant files&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;tar xvf wine-9.7-amd64.tar.xz
&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;tar xvf wine-9.7-x86.tar.xz
&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;rm wine-9.7-amd64.tar.xz wine-9.7-x86.tar.xz
&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;mv wine-9.7-amd64 wine64
&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;mv wine-9.7-x86 wine&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 a symbolic link and point &lt;code&gt;/usr/local/bin/wine&lt;/code&gt; to &lt;code&gt;$HOME/wine/bin/wine&lt;/code&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;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;export WINEPREFIX=~/.wine32
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;box86 &amp;#39;&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/wine/bin/wine &amp;#34;&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;#34;$@&amp;#34;&amp;#39;&lt;/span&gt; &amp;gt; /usr/local/bin/wine
&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;chmod +x /usr/local/bin/wine
&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;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;export WINEPREFIX=~/.wine64
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;box64 &amp;#39;&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/wine64/bin/wine64 &amp;#34;&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;#34;$@&amp;#34;&amp;#39;&lt;/span&gt; &amp;gt; /usr/local/bin/wine64
&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;chmod +x /usr/local/bin/wine64&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;Add the PATH of Box86 and Box64 to &lt;code&gt;~/.bashrc&lt;/code&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;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;export DISPLAY=:0
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;export BOX86_PATH=~/wine/bin/
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;export BOX86_LD_LIBRARY_PATH=~/wine/lib/wine/i386-unix/:/lib/i386-linux-gnu/:/lib/aarch64-linux-gnu/:/lib/arm-linux-gnueabihf/:/usr/lib /aarch64-linux-gnu/:/usr/lib/arm-linux-gnueabihf/:/usr/lib/i386-linux-gnu/
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;export BOX64_PATH=~/wine64/bin/
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;export BOX64_LD_LIBRARY_PATH=~/wine64/lib/i386-unix/:~/wine64/lib/wine/x86_64-unix/:/lib/i386-linux-gnu/:/lib/x86_64-linux-gnu:/lib/aarch64 -linux-gnu/:/lib/arm-linux-gnueabihf/:/usr/lib/aarch64-linux-gnu/:/usr/lib/arm-linux-gnueabihf/:/usr/lib/i386-linux-gnu /:/usr/lib/x86_64-linux-gnu&amp;#39;&lt;/span&gt; &amp;gt;&amp;gt; ~/.bashrc
&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;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc&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;Install Winetricks&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; ~/
&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;wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
&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;chmod +x winetricks
&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;mv winetricks /usr/local/bin/
&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;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;export BOX86_NOBANNER=1 WINE=wine WINEPREFIX=~/.wine32 WINESERVER=~/wine/bin/wineserver
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;wine &amp;#39;&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;/usr/local/bin/winetricks &amp;#34;&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;#34;$@&amp;#34;&amp;#39;&lt;/span&gt; &amp;gt; /usr/local/bin/winetricks32
&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;chmod +x /usr/local/bin/winetricks32
&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;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;export BOX64_NOBANNER=1 WINE=wine64 WINEPREFIX=~/.wine64 WINESERVER=~/wine64/bin/wineserver
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;wine64 &amp;#39;&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;/usr/local/bin/winetricks &amp;#34;&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;#34;$@&amp;#34;&amp;#39;&lt;/span&gt; &amp;gt; /usr/local/bin/winetricks64
&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;chmod +x /usr/local/bin/winetricks64&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;Create a shortcut to the Wine file manager on the Linux desktop, so that you can directly click the exe to 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;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/Desktop
&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;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;[Desktop Entry]
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;Name=Wine32 Explorer
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;Exec=bash -c &amp;#34;wine explorer&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;icon=wine
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;Type=Application&amp;#39;&lt;/span&gt; &amp;gt; ~/Desktop/Wine32_Explorer.desktop
&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;chmod +x ~/Desktop/Wine32_Explorer.desktop
&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;cp ~/Desktop/Wine32_Explorer.desktop /usr/share/applications/
&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;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/Desktop
&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;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;[Desktop Entry]
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;Name=Wine64 Explorer
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;Exec=bash -c &amp;#34;wine64 explorer&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;icon=wine
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;Type=Application&amp;#39;&lt;/span&gt; &amp;gt; ~/Desktop/Wine64_Explorer.desktop
&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;chmod +x ~/Desktop/Wine64_Explorer.desktop
&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;cp ~/Desktop/Wine64_Explorer.desktop /usr/share/applications/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;4. Install DXVK
 &lt;div id="4-install-dxvk" 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="#4-install-dxvk" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;DXVK is a Vulkan-based translation layer for Direct3D 9/10/11. This may improve performance of some Windows games.&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/termux-proot-box86-box64/featured.png"/></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>Use Termux qemu-user to emulate x86_64 Ubuntu on ARM64 Android</title><link>https://ivonblog.com/en-us/posts/termux-proot-distro-qemu-emulation/</link><pubDate>Thu, 16 Nov 2023 18:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-proot-distro-qemu-emulation/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;This explains how to emulate an x86_64 Ubuntu system on an ARM64 (Aarch64) Android phone through Termux proot-distro.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Explanation
 &lt;div id="1-explanation" 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-explanation" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;You may say: most Android devices are ARM64, right? Why not just install the ARM version of Ubuntu? Some programs are just obnoxious and are not compiled for ARM.&lt;/p&gt;
&lt;p&gt;So on the road of force-running x86 programs, we have three choices:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Run an ARM64 system and install the &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-box86-box64/" target="_blank" rel="noreferrer"&gt;Box64 translator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Use qemu-system to start a complete x86_64 emulator, such as &lt;a href="https://ivonblog.com/en-us/posts/termux-qemu-system-linux" target="_blank" rel="noreferrer"&gt;Ubuntu x86_64 + QEMU&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Use qemu-user to emulate an x86_64 system.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;qemu-system runs a virtual machine, emulating complete hardware devices so Linux can run as if it were on a real computer. Of course, it consumes a lot of resources.&lt;/p&gt;
&lt;p&gt;qemu-user, on the other hand, is a userspace emulator that can emulate x86 executables on ARM64 devices without needing the resources of an entire virtual machine.&lt;/p&gt;
&lt;p&gt;QEMU supports emulating many architectures. Besides x86_64, emulating 32-bit x86, RISC-V, and other architectures is also possible.&lt;/p&gt;
&lt;p&gt;In Termux, as long as we have a rootfs, we can get a Linux system running without using qemu-system virtual machine emulation.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro" &gt;proot-distro&lt;/a&gt; tool has built-in qemu support. This article discusses using the proot-distro tool together with qemu-user to run an x86_64 system.&lt;/p&gt;
&lt;p&gt;Because it is emulated, program execution is naturally slower than native. Add proot&amp;rsquo;s performance overhead and it becomes even slower. At the end of the article, we will compare the speed of Proot native vs Box64 vs qemu-user.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Test environment
 &lt;div id="2-test-environment" 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="#2-test-environment" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Phone: Sony Xperia 10 V, Android 13&lt;/li&gt;
&lt;li&gt;Linux kernel version: 5.4&lt;/li&gt;
&lt;li&gt;Termux version: 0.118.0&lt;/li&gt;
&lt;li&gt;qemu-user version: 8.1.0&lt;/li&gt;
&lt;li&gt;Ubuntu version: 20.04 (Ubuntu 22.04 runs into a problem where apt pub_key cannot be imported)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 class="relative group"&gt;3. Create an x86_64 proot Ubuntu
 &lt;div id="3-create-an-x86_64-proot-ubuntu" 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="#3-create-an-x86_64-proot-ubuntu" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Refer to &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro-add-custom-distro" &gt;proot-distro rootfs&lt;/a&gt; and add the &lt;code&gt;Ubuntu 20.04_x86_64.sh&lt;/code&gt; script. But here we need to change the content a little.&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;vim &lt;span class="nv"&gt;$PREFIX&lt;/span&gt;/etc/proot-distro/ubuntu20.04_x86_64.sh&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;Modify it as follows&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="c1"&gt;# Specify the architecture as x86_64&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;DISTRO_ARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;x86_64
&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;&lt;span class="nv"&gt;DISTRO_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Ubuntu20.04 x86_64&amp;#34;&lt;/span&gt;
&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;&lt;span class="nv"&gt;DISTRO_COMMENT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Ubuntu 20.04 Focal x86_64&amp;#34;&lt;/span&gt;
&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;&lt;span class="nv"&gt;TARBALL_STRIP_OPT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;
&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;&lt;span class="c1"&gt;# Download the x86_64 Ubuntu base&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;TARBALL_URL&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;x86_64&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;https://cdimage.ubuntu.com/ubuntu-base/focal/daily/current/focal-base-amd64.tar.gz&amp;#34;&lt;/span&gt;
&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;TARBALL_SHA256&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;x86_64&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;16c831cc71b8ab79e5156451558df4a025783ba335047f6343518e7225416929&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="3"&gt;
&lt;li&gt;Install &lt;code&gt;qemu-user-x86-64&lt;/code&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;pkg install qemu-user-x86-64&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;Install Ubuntu&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 ubuntu20.04_x86_64&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;Log in to Ubuntu. proot-distro will automatically execute it with QEMU.&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 ubuntu20.04_x86_64&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;
&lt;p&gt;Through the &lt;code&gt;uname -a&lt;/code&gt; command, you can see that the architecture is x86_64, and no &lt;code&gt;Exec format error&lt;/code&gt; appears.
&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-qemu-emulation/images/Screenshot_20231116-223629.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="1080"
 height="391"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If a &lt;code&gt;signal 11 Segmentfault&lt;/code&gt; error appears while installing packages, just run &lt;code&gt;dpkg --configure -a&lt;/code&gt; once.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 class="relative group"&gt;4. Compare native and emulated execution speed
 &lt;div id="4-compare-native-and-emulated-execution-speed" 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="#4-compare-native-and-emulated-execution-speed" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Note: qemu-user in the table below refers to the method in this article&lt;/p&gt;
&lt;p&gt;native represents the arm64 executables installed in proot Ubuntu&lt;/p&gt;
&lt;p&gt;Box64 means using the &lt;code&gt;box64&lt;/code&gt; command in proot Ubuntu to translate and run x86_64 executables&lt;/p&gt;
&lt;p&gt;Use 7z to extract a 133MB zip file, and use &lt;code&gt;time&lt;/code&gt; to measure how long it takes to complete.&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/termux-proot-distro-qemu-emulation/featured.webp"/></item><item><title>Use a custom rootfs in Termux proot-distro to create a Linux container</title><link>https://ivonblog.com/en-us/posts/termux-proot-distro-add-custom-distro/</link><pubDate>Thu, 16 Nov 2023 16:00:00 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/termux-proot-distro-add-custom-distro/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;This article demonstrates how to add your preferred Linux distribution to the proot-distro tool in Android Termux.&lt;/p&gt;
&lt;p&gt;Using Ubuntu as an example, we will install the older &lt;code&gt;Ubunut 22.04 LTS&lt;/code&gt; proot Ubuntu.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. proot vs proot-distro
 &lt;div id="1-proot-vs-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-proot-vs-proot-distro" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;proot is a userspace implementation of chroot, allowing chroot-like functionality without root privileges.&lt;/p&gt;
&lt;p&gt;Some developers distribute Termux proot distributions by brute-forcing it with the &lt;code&gt;proot&lt;/code&gt; command. For example, &lt;a href="https://github.com/Ilya114/Box64Droid/tree/main" target="_blank" rel="noreferrer"&gt;Box64Droid&lt;/a&gt; downloads a custom rootfs, then uses a long chain of commands to log in to the proot distribution.
&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-add-custom-distro/images/Screenshot_20231116_165037.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="915"
 height="292"&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;But since we have the useful proot-distro script, why not make good use of it? It is a wrapper script for proot, integrating the processes of downloading, logging in to, and logging out of proot distributions, while also making it convenient to execute commands.&lt;/p&gt;
&lt;p&gt;I explained its usage in &lt;a href="https://ivonblog.com/en-us/posts/termux-proot-distro" &gt;proot-distro usage&lt;/a&gt;, but what if the distributions provided by the proot-distro maintainers do not meet your needs? For example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You need a rootfs for a specific Linux version, such as an LTS version of Ubuntu, but proot-distro&amp;rsquo;s Ubuntu is always the latest version.&lt;/li&gt;
&lt;li&gt;You need a rootfs for a specific architecture, such as 32-bit x86 Manjaro&lt;/li&gt;
&lt;li&gt;You want to run an x86_64 system on an ARM64 device&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Fortunately, proot-distro allows us to &amp;ldquo;register&amp;rdquo; proot distributions. We can add our own rootfs and then operate it with the &lt;code&gt;proot-disro&lt;/code&gt; command.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. How to build a custom Linux rootfs
 &lt;div id="2-how-to-build-a-custom-linux-rootfs" 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="#2-how-to-build-a-custom-linux-rootfs" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Most distributions have their own rootfs building tools. Note that packages like &lt;code&gt;debootstrap&lt;/code&gt; included in Termux may have permission issues, so it is safer to create the rootfs on a Linux computer and then move it to the phone.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ubuntu: &lt;a href="https://ivonblog.com/en-us/posts/debootstrap-create-rootfs-for-android" &gt;debootstrap&lt;/a&gt; or download an &lt;a href="https://cdimage.ubuntu.com/ubuntu-base/releases/jammy/release/" target="_blank" rel="noreferrer"&gt;automatically built rootfs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Debian：&lt;a href="https://ivonblog.com/en-us/posts/debootstrap-create-rootfs-for-android" &gt;debootstrap&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Fedora：&lt;a href="https://github.com/libguestfs/supermin" target="_blank" rel="noreferrer"&gt;supermin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;openSUSE: download an &lt;a href="https://en.opensuse.org/HCL:Chroot" target="_blank" rel="noreferrer"&gt;automatically built rootfs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Alpine：&lt;a href="https://wiki.alpinelinux.org/wiki/Bootstrapping_Alpine_Linux" target="_blank" rel="noreferrer"&gt;Bootstrapping Alpine Linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Arch：&lt;a href="https://wiki.archlinux.org/title/Pacstrap" target="_blank" rel="noreferrer"&gt;pacstrap&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Manjaro：&lt;a href="https://wiki.archlinux.org/title/Pacstrap" target="_blank" rel="noreferrer"&gt;pacstrap&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Void：&lt;a href="https://docs.voidlinux.org/installation/guides/chroot.html" target="_blank" rel="noreferrer"&gt;Installation via chroot&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also refer to &lt;a href="https://github.com/termux/proot-distro/tree/master/distro-build" target="_blank" rel="noreferrer"&gt;the proot-distro author&amp;rsquo;s scripts&lt;/a&gt; to understand how to create a custom rootfs.&lt;/p&gt;

&lt;h2 class="relative group"&gt;3. Register a new Ubuntu proot-distro
 &lt;div id="3-register-a-new-ubuntu-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="#3-register-a-new-ubuntu-proot-distro" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Open Termux and install 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;pkg install proot-distro&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;
&lt;p&gt;Go to &lt;a href="https://cdimage.ubuntu.com/ubuntu-base/releases/22.04/release/?C=M;O=D" target="_blank" rel="noreferrer"&gt;Ubuntu daily builds&lt;/a&gt; and copy the Ubuntu base 22.04 URL. This is a minimal system.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Temporarily download it to the Termux home directory&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;pkg install wget
&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;wget https://cdimage.ubuntu.com/ubuntu-base/releases/22.04/release/ubuntu-base-22.04.3-base-arm64.tar.gz&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;Calculate the SHA256 checksum, then remove it&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;pkg install coreutils
&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;sha256sum ubuntu-base-22.04.3-base-arm64.tar.gz
&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;rm ubuntu-base-22.04.3-base-arm64.tar.gz&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;Switch to &lt;code&gt;$PREFIX/etc/proot-distro&lt;/code&gt;, where proot scripts are stored, copy the sample script, and name it &lt;code&gt;ubuntu22.04.sh&lt;/code&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;&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="nv"&gt;$PREFIX&lt;/span&gt;/etc/proot-distro
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cp distro.sh.sample ubuntu22.04.sh&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;Edit it&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;vim ubuntu22.04.sh&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;Add the following content. I omitted the original comments.&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="c1"&gt;# The architecture should match the phone processor architecture&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;DISTRO_ARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;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;&lt;span class="c1"&gt;# Display name of the distribution&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;DISTRO_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Ubuntu 22.04 LTS&amp;#34;&lt;/span&gt;
&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;&lt;span class="c1"&gt;# Comment&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;DISTRO_COMMENT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Ubuntu 22.04 LTS Jammy Jellyfish&amp;#34;&lt;/span&gt;
&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;&lt;span class="c1"&gt;# Directory depth of the archive, default is 1, which ignores the root directory. But Ubuntu base extracts directly as the filesystem, so set 0 here&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;TARBALL_STRIP_OPT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;
&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;&lt;span class="c1"&gt;# Each architecture in the array corresponds to a rootfs URL. You can also upload the rootfs to your own Github instead&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;TARBALL_URL&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;aarch64&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;https://cdimage.ubuntu.com/ubuntu-base/releases/22.04/release/ubuntu-base-22.04.3-base-arm64.tar.gz&amp;#34;&lt;/span&gt;
&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;&lt;span class="c1"&gt;# Fill in the archive&amp;#39;s SHA256 checksum&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;TARBALL_SHA256&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;aarch64&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;bdae94b05d0fca7decbe164010af2ac1b772a9dda21ed9fb5552b5674ad634a3&amp;#34;&lt;/span&gt;
&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;&lt;span class="c1"&gt;# Commands to run after installation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;distro_setup&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; run_proot_cmd touch /etc/hello-world
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;}&lt;/span&gt;&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;Try running &lt;code&gt;proot-distro list&lt;/code&gt;; you can see that the Ubuntu 22.04 LTS we just added has appeared in the list
&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-add-custom-distro/images/Screenshot_20231116-163707.webp"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/cannotloadimage.avif'"
 width="512"
 height="527"&gt;&lt;/figure&gt;&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://ivonblog.com/en-us/posts/termux-proot-distro-add-custom-distro/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>