termux proot安装debian

PRoot 是 chroot、mount --bind 和 binfmt_misc 的用户空间实现用户不需要任何权限或设置即可通过 QEMU 用户模式透明地执行为另一个 CPU 架构构建的程序等操作。这里用来安装debian。

安装 PRoot

pkg install proot proot-distro
目前支持alpine,arch,debian,fedora,ubuntu等

安装debian

~$ proot-distro install debian

[*] Installing Debian (bookworm)...
[*] Creating directory '/data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/debian'...
[*] Creating directory '/data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/debian/.l2s'...
[*] Creating directory '/data/data/com.termux/files/usr/var/lib/proot-distro/dlcache'...
[*] Downloading rootfs tarball...
[*] URL: https://github.com/termux/proot-distro/releases/download/v4.17.3/debian-bookworm-aarch64-pd-v4.17.3.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 40.9M  100 40.9M    0     0   306k      0  0:02:16  0:02:16 --:--:--  419k

[*] Checking integrity, please wait...
[*] Extracting rootfs, please wait...
[*] Writing file '/data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/debian/etc/environment'...
[*] Updating PATH in '/data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/debian/etc/bash.bashrc' if needed...
[*] Updating PATH in '/data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/debian/etc/profile' if needed...
[*] Updating PATH in '/data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/debian/etc/login.defs' if needed...
[*] Creating file '/data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/debian/etc/resolv.conf'...
[*] Creating file '/data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/debian/etc/hosts'...
[*] Registering Android-specific UIDs and GIDs...
[*] Running distribution-specific configuration steps...
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.
[*] Finished.

Log in with: proot-distro login debian

安装完成。

登录

~ $ proot-distro login debian

root@localhost:~# uname -a
Linux localhost 6.2.1-PRoot-Distro #0 SMP PREEMPT Mon Oct 30 11:30:48 UTC 2023 aarch64 GNU/Linux

安装docker

apt update
apt install docker.io

root@localhost:~# ifconfig
Warning: cannot open /proc/net/dev (Permission denied). Limited output.
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1  (UNSPEC)

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 3000  (UNSPEC)
查看docker信息
`root@localhost:~# docker info`
Client:
 Context:    default
 Debug Mode: false

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info

root@localhost:~# systemctl enable docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker

root@localhost:~# systemctl start docker
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

由于没有systemd,无法运行服务,也无法使用docker。