Credit to https://github.com/ELWAER-M/Chroot-on-termux for the original script
- Good to Mention
- Choosing a rootfs
- Extracting the rootfs
- Making a script to launch the chroot environment
- Troubleshooting
- You need a rooted phone for that
- I've used here a Samsung S10+ phone running Lineage OS 19.1
- If any damage happens to your phone, you are all responsible for it!
the rootfs architecture have to match with your device architecture too, to know what architecture your phone have run: Ubuntu RootFS
$ uname -m
aarch64(e.g. aarch64, armv7l).
Any location under /data should be good (because it formatted as ext4)
e.g.
$ mkdir chroot #or anything else
$ sudo tar xfp /sdcard/Download/rootfs.tar.xz -C /data/ubuntu #to keep the files permissionsUse nano or any text editor you like for that:
$ nano run-chroot.sh
simple example:
#!/bin/sh
# fix /dev mount options
mount -o remount,dev,suid /data
mount --bind /dev /data/ubuntu/dev
mount --bind /sys /data/ubuntu/sys
mount --bind /proc /data/ubuntu/proc
mount --bind /dev/pts /data/ubuntu/dev/pts
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export TERM=$TERM
export TMPDIR=/tmp
chroot /data/ubuntu/ /bin/su - rootthen change the file permissions to executable:
$ chmod +x run-chroot.shyou have to run it as root:
$ sudo ./run-chroot.shusermod -g 3003 _aptyou have to add a DNS to resolv.conf:
echo "nameserver 8.8.8.8" > /etc/resolv.confthen you need to add android root groups:
groupadd -g 3001 aid_bt
groupadd -g 3002 aid_bt_net
groupadd -g 3003 aid_inet
groupadd -g 3004 aid_net_raw
groupadd -g 3005 aid_adminthen add those groups to the user you using:
usermod -a -G aid_bt,aid_bt_net,aid_inet,aid_net_raw,aid_admin root