NanoPC-T4
一、简介
本文主要记录笔者使用NanoPC-T4进行系统安装、Debian12系统换源与系统更新、安装Doocker、安装1panel面板、设置中文语言与输入法、安装gnome桌面、安装星火商店、磁盘挂载等操作步骤。
二、系统安装
具体步骤可根据官方维基教程进行操作,官方维基地址:https://wiki.friendlyelec.com/wiki/index.php/NanoPC-T4/zh
三、换源与系统更新
# 备份原文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# sources.list文件内添加国内源
sudo vim /etc/apt/sources.list
阿里云源
deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
中科大源
deb https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb-src https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
网易源
deb https://mirrors.163.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.163.com/debian-security/ bookworm-security main
deb-src https://mirrors.163.com/debian-security/ bookworm-security main
deb https://mirrors.163.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.163.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm-backports main non-free non-free-firmware contrib
腾讯云源
deb https://mirrors.cloud.tencent.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.cloud.tencent.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.cloud.tencent.com/debian-security/ bookworm-security main
deb-src https://mirrors.cloud.tencent.com/debian-security/ bookworm-security main
deb https://mirrors.cloud.tencent.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.cloud.tencent.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.cloud.tencent.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.cloud.tencent.com/debian/ bookworm-backports main non-free non-free-firmware contrib
系统更新
# 更新软件列表
sudo apt update
# 更新已经安装的软件包
sudo apt upgrade
注意:需要注意在更新过程中,某些安装包可能会提示是否保留配置文件,根据自己的需求来选择
四、设置中文语言与输入法
4.1 设置中文语言
输入以下命令,用空格选中 ‘zh_CN.UTF-8’
sudo dpkg-reconfigure locales
添加环境变量到 .bashrc:
echo "export LC_ALL=zh_CN.UTF-8" >> ~/.bashrc
echo "export LANG=zh_CN.UTF-8" >> ~/.bashrc
echo "export LANGUAGE=zh_CN.UTF-8" >> ~/.bashrc
重启确认一下设置是否生效:
sudo reboot
4.2 安装中文输入法
输入如下命令安装fcitx和拼音输入法:
sudo apt update
sudo apt-get install fcitx fcitx-pinyin
sudo apt-get install im-config
sudo apt-get install fcitx-table*
sudo apt-get install fcitx-ui-classic fcitx-ui-light
sudo apt-get install fcitx-frontend-gtk2 fcitx-frontend-gtk3
sudo apt-get remove --purge scim* ibus*
sudo reboot
注意:桌面环境安装好后,找到fcitx图标,点击进行输入法设置
五、安装Docker
5.1 本节适应范围
- 支持的平台: RK3399
- 支持的目标板操作系统: debian-bookworm-core
5.2 安装前的检查和准备
Docker现在推荐使用的存储驱动是Overlay2, 而由于根文件系统已经使用了OverlayFS, 所以可能无法直接安装,需要对分区作些调整,有如下几种方法, 下面将分别介绍。本文仅使用第一种方式,其它方式自行查看官方维基:https://wiki.friendlyelec.com/wiki/index.php/NanoPC-T4/zh#.E5.9C.A8Debian.E7.B3.BB.E7.BB.9F.E4.B8.8A.E5.AE.89.E8.A3.85Docker
-
方法1
让根文件系统不再使用OverlayFS, 最省事,但由于"恢复出厂设置"这个功能需要依赖OverlayFS,所以此功能将无法工作;
# 为root用户创建密码,如果之前没有做 sudo passwd root # 让根文件系统不使用OverlayFS,写特定内容到 /.init_wipedata 后重启 su - root -c 'echo "overlayfs=disable" > /.init_wipedata' sudo reboot
-
方法2
创建一个额外的分区用来挂载/var/lib/docker目录, 需要预先规划好分区大小;
-
方法3
将/var/lib/docker目录挂载到例如U盘和M.2 SSD这样的外置存储设备上,存储设备需要格式化为ext4格式;
5.3 安装docker
因Docker安装程序需要使用iptables, 而Debian默认使用的是nftables, 因此安装前先设置Debian使用传统的iptables:
# 下载iptables
sudo apt install iptables
# 配置网络,每行执行后都有输出
[ -f /usr/sbin/iptables-legacy ] && sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
[ -f /usr/sbin/ip6tables-legacy ] && sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
开始安装Docker:
# 安装必要工具
sudo apt install lsb-release wget
# 获取系统版本信息
codename=$(lsb_release -c | awk '{print $2}')
version=$(lsb_release -sr | cut -d'.' -f1)
# 下载安装包
wget https://download.docker.com/linux/debian/dists/${codename}/pool/stable/arm64/containerd.io_1.6.24-1_arm64.deb
wget https://download.docker.com/linux/debian/dists/${codename}/pool/stable/arm64/docker-ce-cli_24.0.6-1~debian.${version}~${codename}_arm64.deb
wget https://download.docker.com/linux/debian/dists/${codename}/pool/stable/arm64/docker-buildx-plugin_0.11.2-1~debian.${version}~${codename}_arm64.deb
wget https://download.docker.com/linux/debian/dists/${codename}/pool/stable/arm64/docker-ce_24.0.6-1~debian.${version}~${codename}_arm64.deb
wget https://download.docker.com/linux/debian/dists/${codename}/pool/stable/arm64/docker-compose-plugin_2.21.0-1~debian.12~${codename}_arm64.deb
# 安装
sudo apt install ./containerd.io_1.6.24-1_arm64.deb \
./docker-ce_24.0.6-1~debian.${version}~${codename}_arm64.deb \
./docker-ce-cli_24.0.6-1~debian.${version}~${codename}_arm64.deb \
./docker-buildx-plugin_0.11.2-1~debian.${version}~${codename}_arm64.deb \
./docker-compose-plugin_2.21.0-1~debian.12~${codename}_arm64.deb
验证是否安装成功:
sudo docker info
看看Docker是否使用了overlay2存储驱动:
#执行以下命令,输出: Storage Driver: overlay2,证明安装成功
sudo docker info | grep storage -i
5.4 配置非root用户使用docker
sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo systemctl restart docker
sudo chmod a+rw /var/run/docker.sock
验证是否成功:
docker images
六、安装1panel面板
1Panel 是一个现代化、开源的 Linux 服务器运维管理面板。
- 建议先安装Docker再安装1panel面板
# Debian系统在线安装1panel面板
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && bash quick_start.sh
七、安装gnome桌面
安装桌面环境
# 安装 gnome
sudo apt install task-gnome-desktop
# 安装显示管理器
sudo apt install lightdm
# 配置登录管理器为lightdm
sudo dpkg-reconfigure lightdm
设置开机启动进入图形界面
# 使开机启动进入图形界面
systemctl set-default graphical.target
# 使开机启动进入命令行界面
systemctl set-default multi-user.target
卸载gnome
# 卸载 gnome
apt purge -y --auto-remove task-gnome-desktop
dpkg -l | awk '/^ii/{print $2}' | grep -E '.gnome.|^sddm|^lightdm|^gdm3' | xargs apt-get purge -V --auto-remove -yy
八、安装星火应用商店
下载安装包 https://gitee.com/spark-store-project/spark-store/releases/tag/4.3.3.2
上传安装包后,再对应目录下执行安装命令
# xxxx 可使用Tab补全
sudo apt install ./spark-store_xxxx.deb
九、磁盘挂载
9.1 磁盘挂载脚本
- 查看设备名称
lsblk
注意:设备名称可能只有/sda,后面的设备路径就只写/dev/sda
- 自行创建mount.sh文件,放在/etc目录下
#!/bin/bash
# 设备路径,更据 lsblk 命令查看设备名称,并修改
DEVICE="/dev/sda1"
# 挂载点
MOUNT_POINT="/mnt/data"
# 文件系统类型(对于exFAT,使用exfat-fuse)
FS_TYPE="ntfs" # 对于exFAT,更改为"exfat"并在系统中安装相应的支持
# 检查挂载点是否存在,如果不存在则创建它
if [ ! -d "$MOUNT_POINT" ]; then
mkdir -p "$MOUNT_POINT"
fi
# 尝试挂载设备
mount -t "$FS_TYPE" "$DEVICE" "$MOUNT_POINT"
# 检查挂载是否成功
if [ $? -eq 0 ]; then
echo "磁盘已成功挂载到 $MOUNT_POINT"
else
echo "挂载磁盘时出错"
fi
- 检查脚本权限
# 给脚本赋予执行权限
chmod +x /etc/mount.sh
9.2 创建挂载服务
- 创建mount.service文件,放到/etc/systemd/system目录下
[Unit]
Description=Mount
After=network.target
[Service]
ExecStart=/etc/mount.sh
Type=oneshot
RemainAfterExit=true
[Install]
WantedBy=multi-user.target
- 启用挂载服务
# 重新加载 systemd 的配置
systemctl daemon-reload
# 启用开机挂载服务
systemctl enable mount.service
# 检查服务是否已设置为在系统启动时启用
systemctl is-enabled mount.service
# 启动服务
systemctl start mount.service
参考文献
- NanoPC-T4官方维基 https://wiki.friendlyelec.com/wiki/index.php/NanoPC-T4/zh
- 官方固件介绍 https://wiki.friendlyelec.com/wiki/index.php/NanoPC-T4/zh#.E5.AE.98.E6.96.B9.E5.9B.BA.E4.BB.B6
- 官方固件下载地址 https://download.friendlyelec.com/NanoPC-T4
- 官方Docker安装教程 https://wiki.friendlyelec.com/wiki/index.php/NanoPC-T4/zh#.E5.9C.A8Debian.E7.B3.BB.E7.BB.9F.E4.B8.8A.E5.AE.89.E8.A3.85Docker
- B站参考视频《友善之臂 NanoPC-T4 docker部署思路》, 视频创作者:YU-MOU 视频链接:https://www.bilibili.com/video/BV12j4veAEA1/?vd_source=f7a960484fb079b0987af83b5317778e
- Debian12换国内源 原文作者: Linux大魔王 原文链接:https://www.cnblogs.com/smlile-you-me/p/17727308.html
- Debian安装图形界面 原文作者:荸荠鸭 原文链接:https://duckgle.in/posts/Debian%E5%AE%89%E8%A3%85%E5%90%84%E7%B1%BB%E5%9B%BE%E5%BD%A2%E7%95%8C%E9%9D%A2/
- 1panel面板 https://1panel.cn/docs/installation/online_installation/
- 星火应用商店 https://www.spark-app.store/