前言#
在閒置的 Android 舊手機(無需 root)安裝 ubuntu
準備#
下載 termux app,對應鏈接https://github.com/termux/termux-app/releases
換成國內鏡像源
termux-change-repo
下載軟體
pkg install vim
創建目錄,設置存儲權限
在手機的根目錄創建目錄 a,再進入 a 目錄創建 file 目錄
termux-setup-storage
#設置軟鏈接
ln -s storage/shared/a/file file
安裝 ubuntu#
下載 proot-distro#
pkg install proot-distro
下載 ubuntu#
有兩種方式可下載 ubuntu
方式一:直接下載
#查看要安裝的系統
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
。具體命令:
#移動壓縮包
mv ~/file/ubuntu-noble-aarch64-pd-v4.18.0.tar.xz $PREFIX/var/lib/proot-distro/dlcache
#執行下載命令
proot-distro install ubuntu
安裝完成後,登錄 ubuntu
proot-distro login ubuntu
換國內鏡像源#
更新現有源
apt update -y
下載 ca-certificates
apt install ca-certificates -y
從 Ubuntu 24.04 開始,Ubuntu 的軟體源配置文件變更為 DEB822 格式
#將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
遠程連接#
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
。
echo "service ssh start" >> ~/.bashrc