Build for android platform. Currently (2021-08-11), only 32-bit arm
proot-rs is supported
CARGO_BUILD_TARGET=arm-unknown-linux-musleabi cargo make build
Push the binary to your android device. Although proot-rs is built for arm
, we can still test on arch64
android phone.
adb push target/arm-unknown-linux-musleabi/debug/proot-rs /data/local/tmp/proot-rs
Download rootfs and push it to your device
wget <https://dl-cdn.alpinelinux.org/alpine/v3.14/releases/armv7/alpine-minirootfs-3.14.0-armv7.tar.gz>
adb push alpine-minirootfs-3.14.0-armv7.tar.gz /data/local/tmp/
Enter adb shell with adb shell
, and perform the following:
cd /data/local/tmp
mkdir rootfs
# unpack alpine rootfs to "./rootfs/"
tar -C ./rootfs/ -xvf alpine-minirootfs-3.14.0-armv7.tar.gz
Before starting proot-rs
, we need to set up the dns server address so that we can access the network in the rootfs:
echo "nameserver 8.8.8.8" > rootfs/etc/resolv.conf
Now run proot-rs
with
./proot-rs --rootfs=./rootfs --bind /dev:/dev --bind /proc:/proc
You should now have a shell in our new rootfs:
# set necessary environment variable
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ls -la /etc/os-release
Install neofetch
with apk
apk update
apk add neofetch
Install nginx
with apk
apk update
apk add nginx
Some necessary preparations
Edit /etc/nginx/http.d/default.conf
apk add vim
vim /etc/nginx/http.d/default.conf
Change the content to:
server {
listen 8080 default_server;
listen [::]:8080 default_server;
location / {
root /;
autoindex on;
}
}
Create dir /run/nginx
mdkir /run/nginx
Test nginx configs
nginx -t
Launch a static file server
nginx
nginx will be run in the background
Visit with curl
apk add curl
curl <http://192.168.123.245:8080>
echo "It works!" > /tmp/file
curl <http://192.168.123.245:8080/tmp/file>
Visit from another PC
add alpine to mkrootfs.sh