1. 前提
目前据我所知的安装Linux方法有两种,这边笔者介绍安装Alpine Linux。
- 通过
proot-distro
安装Alpine Linux
https://wiki.termux.com/wiki/PRoot - 安装大佬打包的
Alpine Linux
https://github.com/Hax4us/TermuxAlpine
2. 通过 proot-distro 安装 Alipine Linux
- 安装
proot
$ pkg install proot
- 安装
proot-distro
Android 5.0下的 Termux 源里没有proot-distro
,所以需要手动安装proot-distro
,可能是因为0.118版本的Termux没有做太多适配,导致后面系统兼容性有些问题,不过能正常使用。
proot-distro 开源地址: https://github.com/termux/proot-distro
通过下面的命令安装:
$ pkg install git
$ git clone https://github.com/termux/proot-distro
$ cd proot-distro
$ ./install.sh
- 安装
Alpine Linux
- 通过
proot-distro list
查看当前支持并且可以安装的Linux
$ proot-distro list
Supported distributions:
* Alpine Linux
Alias: alpine
Status: NOT installed
Comment: Rolling release branch (edge).
* Arch Linux
Alias: archlinux
Status: NOT installed
Comment: Currently available only AArch64 and ARM ports.
* Debian
Alias: debian
Status: NOT installed
Comment: A stable release (bullseye).
.....
- 通过
proot-distro install <Alias>
命令安装对应的Linux版本
下载这一步拿梯子会下的快一点,不然比较慢,但是还能接受,因为Alpine系统出了名的小。
$ proot-distro install alpine
- 下载完成后
proot-distro login alpine
进入Alpine Linux
系统
$ proot-distro login alpine
localhost:~#
问题:Android 5.0 下的0.118版本会出现下面的错误```shell
proot error: unknown option ‘–sysvipc’.
fatal error: see proot --help
.
解决方法:
启动时加上`--no-sysvipc`参数
```shell
$ proot-distro login alpine --no-sysvipc
localhost:~#
3. 安装大佬打包的 Alpine Linux
项目地址:https://github.com/Hax4us/TermuxAlpine
- 首先安装git
$ pkg install git
- 安装方法很简单,只要通过整合的代码一键运行就能安装了。
$ cd $HOME
$ git clone https://github.com/Hax4us/TermuxAlpine.git
$ cd TermuxAlpine
$ chmod 777 TermuxAlpine.sh
$ ./TermuxAlpine.sh
等待片刻,出现下面的界面说明安装完成
#------------------------------------------#
Now you can enjoy a very small (just 1 MB!) Linux environment in your Termux :)
Don't forget to star my work
#------------------------------------------#
#------------------------------------------#
[*] Email : lkpandey950@gmail.com
[*] Website : https://hax4us.com
[*] YouTube : https://youtube.com/hax4us
#------------------------------------------#
NOTE : use --uninstall option for uninstall
#------------------------------------------#
上面介绍到了通过startalpine --uninstall
可以卸载alpine
- 安装完成后运行
startalpine
就能进入系统
$ startalpine
$ exit # 退出系统
- 进入系统后更新源,这时候在alpine环境里。
$ apk update
- 配置Alpine源
alpine 源文件存在 /etc/apk/repositories
目录下,直接修改这里面的文件地址
$ vi /etc/apk/repositories
替换文件里的源为
http://mirrors.aliyun.com/alpine/v3.12/main
http://mirrors.aliyun.com/alpine/v3.12/community
换过源以后需要更新源
$ apk update && apk upgrade
4. 安装Ubuntu
1. termux-ubuntu(Android 7.0 无法启动)
https://github.com/Neo-Oli/termux-ubuntu
安装步骤:
- 安装必备依赖
$ pkg install wget proot git
- 克隆代码安装ubuntu
$ git clone https://github.com/Neo-Oli/termux-ubuntu.git
$ cd termux-ubuntu
$ bash ubuntu.sh
$ ./start-ubuntu.sh
运行./start-ubuntu.sh
的时候出现下面的问题
$./start-ubuntu.sh
proot warning: can't chdir("/root/.") in the guest rootfs: No such file or directory
proot info: default working directory is now "/"
proot error: '/usr/bin/env' not found (root = /data/data/com.termux/files/home/termux-ubuntu/ubuntu-fs, cwd = /, $PATH=(null))
fatal error: see `proot --help`.
解决方案就是安装下面的项目:https://github.com/Neo-Oli/termux-ubuntu/issues/127#issuecomment-630208350
2. ubuntu-in-termux(Android7.0 19.10版本apt 有各种问题,20.04.3分支没问题)
https://github.com/MFDGaming/ubuntu-in-termux
安装步骤:
- 更新Termux
$ pkg update && pkg upgrade -y
- 安装依赖
$ pkg install wget proot git
- 安装ubuntu
$ git clone https://github.com/MFDGaming/ubuntu-in-termux.git
$ cd ubuntu-in-termux
$ chmod +x ubuntu.sh
$ ./ubuntu.sh -y
$ ./startubuntu.sh
成功安装Ubuntu