Alpine chroot jail on Android

But why?

You might ask what’s the point of this because Termux exists? Right?
Well the answer is simple…

Step #1 Root your device

Blah blah blah.
Seriously this ain’t a guide for this.
But if you’re really this green you can find some information in these great forums:

Step #2 Clone the Git repository

git clone 'https://gitlab.com/stnby/alpinedroid.git'
cd alpinedroid

Step #3 Connect your phone over ADB

$ adb connect 10.0.1.2
connected to 10.0.1.2:5555

Click Allow button.

"Allow USB debugging" prompt

Step #4 Move over and execute the setup script

Transfer the setup.sh script.

$ adb push setup.sh /sdcard
setup.sh: 1 file pushed, 0 skipped. 0.1 MB/s (1310 bytes in 0.019s)

Execute the transferred script as root.

$ adb shell su -c 'sh /sdcard/setup.sh'
> prepare
< download rootfs
Connecting to dl-cdn.alpinelinux.org (151.101.194.133:80)
saving to 'rootfs.tar.gz'
rootfs.tar.gz    100% |********************************| 2554k  0:00:00 ETA
'rootfs.tar.gz' saved
> download rootfs
< extract rootfs
> extract rootfs
> configure
< configure

Setup is finished!!!

Usage guide

Spawn an adb shell

$ adb shell

Within an adb shell run these commands to start the chroot environment.

beryllium:/ $ su
beryllium:/ # /data/alpinedroid/up.sh
beryllium:/ # /data/alpinedroid/chroot.sh
localhost:/#

Done we are now inside the alpine chroot environment.

localhost:/# apk add figlet
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/aarch64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/aarch64/APKINDEX.tar.gz
(1/1) Installing figlet (2.2.5-r1)
Executing busybox-1.31.1-r16.trigger
OK: 6 MiB in 15 packages
localhost:/# figlet -f small Kernal.eu
 _  __                  _
| |/ /___ _ _ _ _  __ _| |  ___ _  _
| ' </ -_) '_| ' \/ _` | |_/ -_) || |
|_|\_\___|_| |_||_\__,_|_(_)___|\_,_|

localhost:/# exit

Unmount the virtual partitions afterward by running this script.

beryllium:/ # /data/alpinedroid/down.sh

Note: In case you want to remove the chroot environment make sure /data/alpinedroid/mnt/sdcard is unmounted!!! Otherwise rip your data :-D