在有道词典笔3上运行Ubuntu
2025/12/21大约 4 分钟
注意
修改词典笔软件可能会导致您失去保修或者导致系统损坏,若您的利益因此受到损失,作者不承担任何责任。请谨慎操作,确保您了解每一步的含义。
开启ADB连接
在词典笔上打开设置->关于->法律监管->连续点击3C图标(或底部)直到弹出“adb调试已经启用”
ADB授权并开启SSH
C:\Users\Administrator>adb shell auth
YoudaoDictionaryPen-929's password: CherryYoudao
CherryYoudao
success.
C:\Users\Administrator>adb shell
[root@YoudaoDictionaryPen-929:/]# /usr/bin/sshd_sevice start
Starting sshd: OK
[root@YoudaoDictionaryPen-929:~]# cd /userdisk/Music/
[root@YoudaoDictionaryPen-929:/userdisk/Music]# mkdir ubuntu-rootfs
[root@YoudaoDictionaryPen-929:/userdisk/Music]# cd ubuntu-rootfs/
[root@YoudaoDictionaryPen-929:/userdisk/Music]# wget https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cdimage/ubuntu-base/releases/jammy/release/ubuntu-base-22.04.5-base-arm64.tar.gz
[root@YoudaoDictionaryPen-929:/userdisk/Music/ubuntu-rootfs]# tar -zxvf ubuntu-base-22.04.5-base-arm64.tar.gz
[root@YoudaoDictionaryPen-929:/userdisk/Music/ubuntu-rootfs]# cd(可选)设置SSH开机自启
[root@YoudaoDictionaryPen-929:/]# echo "/usr/bin/sshd_sevice start" >> /etc/init.d/rcS提示
如果出现报错,请翻至文章末尾“排障”。
保存启动脚本
/usr/bin/sshd_sevice start
cd /userdisk/Music/ubuntu-rootfs/
mount -o rw,remount /
mount --bind /dev ./dev
mount --bind /dev/pts ./dev/pts
mount --bind /proc ./proc
mount --bind /sys ./sys
#mount --bind /tmp ./tmp
#mount --bind /run ./run
#mount --bind /var ./var
#mount --bind /usr/lib ./usr/lib
chroot . /bin/bash --loginChroot下启动Ubuntu-jammy
[root@YoudaoDictionaryPen-929:/]# bash startubuntu.sh
bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.utf8)
Starting sshd: OK
bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.utf8)保存DNS修改脚本
ls -la /etc/resolv.conf
rm -f /etc/resolv.conf
cat > /etc/resolv.conf << EOF
nameserver 223.5.5.5
nameserver 119.29.29.29
nameserver 114.114.114.114
options timeout:2 attempts:3
EOF修改DNS
root@YoudaoDictionaryPen-929:/# bash editDNS.sh
root@YoudaoDictionaryPen-929:/# apt update
root@YoudaoDictionaryPen-929:/# apt install -y ca-certificates
root@YoudaoDictionaryPen-929:/# update-ca-certificates换清华源
替换原sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse更新软件包列表
root@YoudaoDictionaryPen-929:/# apt update排障(本排障针对chroot外对原系统的修改)
提示
Q: 提示“can't create xxx: Read-only file system”?
A: 执行mount -o rw,remount /
提示
Q: 提示“cat: write error: No space left on device(或类似根目录无额外存储空间)”?
A: 需要将swapfile更改为较小文件,方法如下↓
排障:修改swapfile
首先执行
# 检查当前Swap状态(单位:KB)
# total: 总内存,used: 已用,free: 空闲,Swap: 交换空间
[root@YoudaoDictionaryPen-929:~]# free -h
total used free shared buffers cached
Mem: 984312 938612 45700 32388 18904 314548
-/+ buffers/cache: 605160 379152
Swap: 832512 0 832512 # 当前Swap约813MB(需根据根分区空间调整)可以看到:Swap占用有1047884KB(可能不同),我们需要将其缩小到512KB(或相对较小)。
# 1. 关闭所有Swap(必须先关闭才能删除文件)
[root@YoudaoDictionaryPen-929:~]# cd
[root@YoudaoDictionaryPen-929:/]# swapoff -a
# 2. 删除原/swapfile
[root@YoudaoDictionaryPen-929:/]# rm swapfile
# 3. 检查根分区空间
[root@YoudaoDictionaryPen-929:/]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 2.5G 1.7G 696M 71% / # 根分区原2.5G,已用1.7G,释放后剩696M可用
devtmpfs 481M 0 481M 0% /dev
tmpfs 481M 32K 481M 1% /dev/shm
tmpfs 481M 8.0K 481M 1% /tmp
tmpfs 481M 48K 481M 1% /var
tmpfs 481M 216K 481M 1% /run
/dev/mmcblk1p11 504M 425M 80M 85% /userdata
/dev/mmcblk1p12 8.6G 6.2G 2.1G 75% /userdisk可以看到:/dev/root已经被腾出696M空间(可能不同)了,接下来我们需要创建一个小一点的swapfile,对我来说我选择512MB。
# 1. 用dd创建512MB空文件
[root@YoudaoDictionaryPen-929:/]# dd if=/dev/zero of=/swapfile bs=1M count=512 status=progress
535822336 bytes (536 MB, 511 MiB) copied, 8.00463 s, 66.9 MB/s
512+0 records in
512+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 8.03261 s, 66.8 MB/s
# 2. 设置权限(仅root可读写,Swap安全要求)
[root@YoudaoDictionaryPen-929:/]# chmod 600 /swapfile
# 3. 启用新Swap
[root@YoudaoDictionaryPen-929:/]# swapon -a最后再查看一下内存情况:
# 验证Swap是否缩小成功(Swap total应接近512MB,示例中409276KB≈400MB,因计算误差)
[root@YoudaoDictionaryPen-929:~]# free -h
total used free shared buffers cached
Mem: 984312 938612 45700 32388 18904 314548
-/+ buffers/cache: 605160 379152
Swap: 409276 0 409276 # 约400MB,符合预期Swap空间已经成功缩小。
提示
Q: 提示有关内存不足?
A: 需要将swapfile扩大,方法如下↓
# 1. 进入有空间的分区(/userdisk,避免根分区满)
[root@YoudaoDictionaryPen-929:~]# cd /userdisk
# 2. 创建1GB Swapfile(bs=1M count=1024 → 1MB×1024=1GB,放在/userdisk更安全)
[root@YoudaoDictionaryPen-929:/userdisk]# dd if=/dev/zero of=./swapfile bs=1M count=1024
# 3. 设置权限(同前,600安全权限)
[root@YoudaoDictionaryPen-929:/userdisk]# chmod 600 ./swapfile
# 4. 格式化并启用Swap(mkswap初始化,swapon启用)
[root@YoudaoDictionaryPen-929:/userdisk]# mkswap ./swapfile
[root@YoudaoDictionaryPen-929:/userdisk]# swapon ./swapfile