Skip to content

Instantly share code, notes, and snippets.

@onlurking
Last active July 18, 2024 10:56
Show Gist options
  • Save onlurking/6f76b9c6b34930215e6583d80c5af250 to your computer and use it in GitHub Desktop.
Save onlurking/6f76b9c6b34930215e6583d80c5af250 to your computer and use it in GitHub Desktop.
Arch Linux chroot on Termux

Arch Linux

chroot on Termux

Let's download the Arch ARM image with the text-browser w3m and install proot:

apt install w3m proot
w3m http://archlinuxarm.org/os/ArchLinuxARM-utilite-latest.tar.gz
cd ~ && mkdir .arch && cd .arch && mv ../ArchLinuxARM-utilite-latest.tar.gz .

We extract the image,

tar xvf ArchLinuxARM-utilite-latest.tar.gz || chmod -R 777 . && tar xvf ArchLinuxARM-utilite-latest.tar.gz 

Add to .bashrc or .zshrc:

alias arch="proot --link2symlink -0 -r ~/.arch -b /dev/ -b /sys/ -b /proc/ -b $HOME /bin/env -i HOME=/root

run arch, inside the Arch chroot for striping it down:

pacman -Rns lvm2 linux-firmware linux-utilite systemd systemd-sysvcompat libusb netctl dhcpcd device-mapper usbutils libpcap iptables cryptsetup iproute2 xfsprogs s-nail reiserfsprogs pciutils licenses gettext man-db jfsutils procps-ng mdadm haveged inetutils psmisc logrotate sysfsutils iputils texinfo diffutils net-tools 

Uncomment the locale:

vi /etc/locale.gen

And then generate:

locale-gen

Network doesn't work out of box, to fix it:

rm /etc/resolv.conf && vi /etc/resolv.conf

And put inside the file:

nameserver 8.8.8.8
nameserver 4.4.4.4

Let's fix the encoding also:

vi /etc/locale.conf
LC_ALL=en_US.UTF-8 
LANG=en_US.UTF-8 
LANGUAGE=en_US.UTF-8

Also, let's fix some permissions:

chmod 755 -R /etc /usr /var /boot /home /mnt /opt /run /srv
Copy link

ghost commented Oct 6, 2017

I still got error when extracting image :
"./var/cache/ldconfig/aux-cache tar: Exiting with failure status due to previous errors"
Any clue?

@luoling8192
Copy link

I still got error when extracting image : "./var/cache/ldconfig/aux-cache tar: Exiting with failure status due to previous errors" Any clue?

I have the same problem. What should I do?

@ann-dvlpr
Copy link

ann-dvlpr commented Mar 7, 2024

I still got error when extracting image : "./var/cache/ldconfig/aux-cache tar: Exiting with failure status due to previous errors" Any clue?

I have the same problem. What should I do?

Just enter http://archlinuxarm.org/os/ site from PC and search for your CPU arch and then edit the downloaded file name to ArchLinuxARM-utilite-latest.tar.gz by holding backspace after the w3m command in order to run the tutorial further without editing any commands. aarch64 worked for me

i recommend using proot-distro, use this cmd: pkg update && pkg upgrade -Y && pkg install proot-distro -Y && proot-distro install archlinux

@ann-dvlpr
Copy link

or at least run with sudo lolz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment