ruri 启动 chroot 容器

ruri 启动 chroot 容器

这一过程在 Android 上运行,需要有 root 权限

获取 Rootfs

~/Downloads/mubuntu_tar # eza -T
.
├── ca-certificates.crt
└── ubuntu-base-24.04.4-base-arm64.tar

获取 Rootfs,其中 ca-certificates.crt 是 ssl 所需使用的证书,其需要复制到解压后的 etc/ssl/certs 下。

设定 /etc/resolv.conf 其默认为空,可设置例如

nameserver 223.5.5.5
nameserver 223.6.6.6

分配 /dev/tty 终端设备,在宿主机上执行:

mknod ./dev/tty c 5 0
chmod 666 ./dev/tty

ruri 运行容器

使用 script 包裹,使其分配一个伪终端,否则 tty 返回是 not a tty

ruri -E root -W /root /data/ssh/root/Documents/mubuntu /usr/bin/env SHELL=/bin/bash TERM="$TERM" LANG=C.UTF-8 script -q -c /bin/bash /dev/null

容器内部可以创建用户,-E-W 可以指定用户和用户目录;创建用户时需要注意其默认 shell 为 sh ,需要设定为 bash,例如

chsh -s /bin/bash zsig

此时即可使用这一容器

设定系统代理

环境变量配置

bash -c 'grep -q "^http_proxy" /etc/environment 2>/dev/null || cat >> /etc/environment << '\''EOF'\''
http_proxy=http://172.31.96.1:4568
https_proxy=http://172.31.96.1:4568
HTTP_PROXY=http://172.31.96.1:4568
HTTPS_PROXY=http://172.31.96.1:4568
no_proxy=localhost,127.0.0.1,172.31.96.1
NO_PROXY=localhost,127.0.0.1,172.31.96.1
EOF
echo "environment proxy set"'