Difference between revisions of "Template:OfficialDebianCore/zh"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
 
(3 intermediate revisions by the same user not shown)
Line 45: Line 45:
 
  | NanoPi-R2S
 
  | NanoPi-R2S
 
  | NanoPi-R2C-Plus
 
  | NanoPi-R2C-Plus
 +
| NanoPi-R2S-Plus
 
  | NanoPi-R2C =
 
  | NanoPi-R2C =
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 53: Line 54:
 
  | NanoPi-R5S =
 
  | NanoPi-R5S =
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
git clone https://github.com/friendlyarm/sd-fuse_rk3568.git -b master --single-branch
+
git clone https://github.com/friendlyarm/sd-fuse_rk3568.git -b kernel-6.1.y --single-branch
 
cd sd-fuse_rk3568
 
cd sd-fuse_rk3568
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 59: Line 60:
 
  | NanoPi-R6S =
 
  | NanoPi-R6S =
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
git clone https://github.com/friendlyarm/sd-fuse_rk3588.git -b master --single-branch
+
git clone https://github.com/friendlyarm/sd-fuse_rk3588.git -b kernel-6.1.y --single-branch
 
cd sd-fuse_rk3588
 
cd sd-fuse_rk3588
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 72: Line 73:
 
convert files/logo.jpg -type truecolor /tmp/logo.bmp
 
convert files/logo.jpg -type truecolor /tmp/logo.bmp
 
convert files/logo.jpg -type truecolor /tmp/logo_kernel.bmp
 
convert files/logo.jpg -type truecolor /tmp/logo_kernel.bmp
sudo LOGO=/tmp/logo.bmp KERNEL_LOGO=/tmp/logo_kernel.bmp ./build-kernel.sh debian-bullseye-core-arm64
+
sudo LOGO=/tmp/logo.bmp KERNEL_LOGO=/tmp/logo_kernel.bmp ./build-kernel.sh debian-bookworm-core-arm64
sudo ./mk-sd-image.sh debian-bullseye-core-arm64
+
sudo ./mk-sd-image.sh debian-bookworm-core-arm64
sudo ./mk-emmc-image.sh debian-bullseye-core-arm64
+
sudo ./mk-emmc-image.sh debian-bookworm-core-arm64
 
</syntaxhighlight>
 
</syntaxhighlight>
 
====恢复出厂设置====
 
====恢复出厂设置====
Line 81: Line 82:
 
sudo firstboot && sudo reboot
 
sudo firstboot && sudo reboot
 
</syntaxhighlight>
 
</syntaxhighlight>
===安装Docker===
+
===在Debian系统上安装Docker===
====前言====
+
请参考此链接: [[How to Install Docker on Debian/zh]]
Docker现在推荐使用的存储驱动是Overlay2, 而由于根文件系统已经使用了OverlayFS, 所以可能无法直接安装,需要对分区作些调整,有如下两种调整方法:<br />
+
方法1)让根文件系统不再使用OverlayFS (缺点: 恢复出厂设置的功能将无法工作); <br />
+
方法2) 根文件系统继续使用OverlayFS, 创建一个额外的分区存放docker数据; <br />
+
下面将分别说明这两种方法,请根据需要选择其中一种。<br />
+
<br/>
+
'''注意事项: '''<br/>
+
注1:此操作会擦除用户数据,需要预先备份好数据<br>
+
注2:需要将固件更新至2023/03/14或之后的版本,或者单独更新boot.img<br>
+
注3:命令中出现的/dev/mmcblkX设备节点是虚构的节点,需要改成真实的设备,eMMC的设备节点是/dev/mmcblk2,TF卡的设备节点是/dev/mmcblk0<br>
+
<br/>
+
====方法1: 让根文件系统不使用OverlayFS====
+
* 写特定内容到 /.init_wipedata 后重启
+
<syntaxhighlight lang="bash">
+
sudo passwd root  # 为root用户创建密码,如果之前没有做
+
su - root -c 'echo "overlayfs=disable" > /.init_wipedata'
+
sudo reboot
+
</syntaxhighlight>
+
* 重启后,使用parted命令查看当前的分区布局,正常情况下,可以看到根系统是以ext4格式挂载的,而不是之前的overlay:
+
<syntaxhighlight lang="bash">
+
sudo apt update
+
sudo apt install parted
+
export DEV=/dev/mmcblkX
+
sudo parted -s ${DEV} unit MiB print
+
</syntaxhighlight>
+
====方法2: 创建一个额外的分区用于docker====
+
* 查看当前的分区布局
+
<syntaxhighlight lang="bash">
+
sudo apt update
+
sudo apt install parted fdisk
+
export DEV=/dev/mmcblkX
+
sudo parted -s ${DEV} unit MiB print
+
</syntaxhighlight>
+
* 调整userdata分区的大小
+
这里以调整为8G大小为例:
+
<syntaxhighlight lang="bash">
+
sudo passwd root  # 为root用户创建密码,如果之前没有做
+
su - root -c 'echo "overlayfs=enable userdata=8096" > /.init_wipedata'
+
sudo reboot
+
</syntaxhighlight>
+
重启后, 正常情况下,可以看到userdata分区已调整为8GB:
+
<syntaxhighlight lang="bash">
+
sudo parted -s ${DEV} unit MiB print
+
</syntaxhighlight>
+
* 创建新分区并格式化
+
<syntaxhighlight lang="bash">
+
(echo n; echo ""; echo ""; echo ""; echo w) | sudo fdisk ${DEV}
+
NUM=$(sudo parted ${DEV} print | awk 'NF > 1 {p = $1} END {print p}')  # 获取最后一个分区的序号
+
sudo mkfs.ext4 ${DEV}p${NUM}
+
</syntaxhighlight>
+
* 挂载新分区到docker数据目录
+
<syntaxhighlight lang="bash">
+
sudo mkdir /var/lib/docker
+
sudo blkid ${DEV}p${NUM}
+
# 配置开机自动挂载新创建的分区
+
sudo vi /etc/fstab
+
# 在文件末尾加入如下内容(其中UUID需替换为真实的)
+
UUID=2efab5a5-8b74-41d2-8747-4c00fff8514a /var/lib/docker ext4 suid,dev,exec,auto,nouser,async,noatime,nofail 0 0
+
sudo mount /var/lib/docker
+
</syntaxhighlight>
+
====安装docker====
+
<syntaxhighlight lang="bash">
+
sudo apt install curl ca-certificates uidmap
+
curl -fsSL https://get.docker.com | bash
+
</syntaxhighlight>
+
验证是否安装成功:
+
<syntaxhighlight lang="bash">
+
sudo docker info
+
</syntaxhighlight>
+
验证Docker使用了overlay2存储驱动:
+
<syntaxhighlight lang="bash">
+
$ docker info | grep storage -i
+
Storage Driver: overlay2
+
</syntaxhighlight>
+
====配置非root用户使用docker====
+
<syntaxhighlight lang="bash">
+
sudo groupadd docker
+
sudo gpasswd -a ${USER} docker
+
sudo systemctl restart docker
+
sudo chmod a+rw /var/run/docker.sock
+
</syntaxhighlight>
+
验证是否成功:
+
<syntaxhighlight lang="bash">
+
docker images
+
</syntaxhighlight>
+
====测试运行docker映像: 安装nextcloud网盘====
+
<syntaxhighlight lang="bash">
+
mkdir ~/nextcloud -p
+
docker run -d -p 8888:80  --name nextcloud  -v ~/nextcloud/:/var/www/html/ --restart=always --privileged=true  arm64v8/nextcloud
+
</syntaxhighlight>
+
安装完成后, 在电脑浏览器上访问: http://设备IP地址:8888, 即可查看nextcloud网盘页面。
+

Latest revision as of 08:18, 1 July 2024

1 Debian Core的使用

1.1 帐户与密码

普通用户:
    用户名: pi
    密码: pi

Root用户:
    默认没有设置root密码,可通过sudo passwd root命令配置root密码

1.2 查看IP地址

由于Debian Bullseye主机名默认为硬件型号, 所以可以使用ping命令来获得IP地址: ping {{{1}}}
Debian Bullseye使用network-manager管理网络, 网口默认配置成DHCP自动获取IP地址 (包括有多网口的设备)。

1.3 通过ssh登录Debian

使用以下命令:ssh pi@{{{1}}}
默认密码为pi

1.4 更新软件包

1.4.1 更换软件源为国内镜像源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.org
sudo sed -i -e 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
sudo sed -i -e 's/security.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
sudo apt update

1.5 更改时区

1.5.1 检查当前时区

timedatectl

1.5.2 列出所有时区

timedatectl list-timezones

1.5.3 设置时区 (比如上海)

sudo timedatectl set-timezone Asia/Shanghai

替换内核下面的两个文件,重新编译内核:
kernel/logo.bmp
kernel/logo_kernel.bmp
或者使用脚本来操作,如下所示:

  • 下载脚本
git clone https://github.com/friendlyarm/sd-fuse_rk3399.git -b kernel-4.19 --single-branch
cd sd-fuse_rk3399
  • 编译内核并重新打包固件
convert files/logo.jpg -type truecolor /tmp/logo.bmp
convert files/logo.jpg -type truecolor /tmp/logo_kernel.bmp
sudo LOGO=/tmp/logo.bmp KERNEL_LOGO=/tmp/logo_kernel.bmp ./build-kernel.sh debian-bookworm-core-arm64
sudo ./mk-sd-image.sh debian-bookworm-core-arm64
sudo ./mk-emmc-image.sh debian-bookworm-core-arm64

1.6.1 恢复出厂设置

在终端上执行如下命令:

sudo firstboot && sudo reboot

1.7 在Debian系统上安装Docker

请参考此链接: How to Install Docker on Debian/zh