前言

在闲置的Android旧手机(无需root)安装ubuntu

准备

下载termux app,对应链接https://github.com/termux/termux-app/releases

换成国内镜像源

1
termux-change-repo

下载软件

1
pkg install vim

创建目录,设置存储权限

在手机的根目录创建目录a,再进入a目录创建file目录

1
2
3
termux-setup-storage
#设置软链接
ln -s storage/shared/a/file file

安装ubuntu

下载 proot-distro

1
pkg install proot-distro

下载ubuntu

有两种方式可下载ubuntu

方式一:直接下载

1
2
3
4
#查看要安装的系统
proot-distro list
#下载安装ubuntu
proot-distro install ubuntu

方式二:压缩包安装

直接下载太慢的话,可以在github上先把镜像压缩包下载下来,具体链接:https://github.com/termux/proot-distro/releases/download/v4.18.0/ubuntu-noble-aarch64-pd-v4.18.0.tar.xz

将下载的压缩包文件放到手机的a/file目录,再移动到$PREFIX/var/lib/proot-distro/dlcache目录下,再执行proot-distro install ubuntu。具体命令:

1
2
3
4
#移动压缩包
mv ~/file/ubuntu-noble-aarch64-pd-v4.18.0.tar.xz $PREFIX/var/lib/proot-distro/dlcache
#执行下载命令
proot-distro install ubuntu

安装完成后,登录ubuntu

1
proot-distro login ubuntu

换国内镜像源

更新现有源

1
apt update -y

下载ca-certificates

1
apt install ca-certificates -y

从 Ubuntu 24.04 开始,Ubuntu 的软件源配置文件变更为 DEB822 格式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#将One-Line-Style配置文件注释
mv /etc/apt/sources.list /etc/apt/sources.list.bak
#创建配置文件,使用DEB822格式
vim /etc/apt/sources.list.d/ubuntu.sources

Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
# Types: deb-src
# URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports
# Suites: noble noble-updates noble-backports
# Components: main restricted universe multiverse
# Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
Types: deb
URIs: http://ports.ubuntu.com/ubuntu-ports/
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# Types: deb-src
# URIs: http://ports.ubuntu.com/ubuntu-ports/
# Suites: noble-security
# Components: main restricted universe multiverse
# Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# 预发布软件源,不建议启用

# Types: deb
# URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports
# Suites: noble-proposed
# Components: main restricted universe multiverse
# Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# # Types: deb-src
# # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports
# # Suites: noble-proposed
# # Components: main restricted universe multiverse
# # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

# 更新
apt update -y && apt upgrade -y

远程连接

1
2
3
4
5
6
7
8
9
10
apt install openssh-server -y
#修改/etc/ssh/sshd_config,取消以下内容的注释并修改
Port 8253 #使用数字较小的端口不会生效
PermitRootLogin yes
PasswordAuthentication yes

service ssh start
service ssh status
#设置开机自启
update-rc.d ssh enable

若ssh开机自启不生效在~/.bashrc文件中追加service ssh start

1
echo "service ssh start" >> ~/.bashrc