Difference between revisions of "Template:OfficialDebianCore"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
Line 79: Line 79:
 
sudo firstboot && sudo reboot
 
sudo firstboot && sudo reboot
 
</syntaxhighlight>
 
</syntaxhighlight>
===Install Docker Engine on Debian===
+
===Install Docker===
====创建一个额外的分区用于docker====
+
====Create an additional partition for Docker====
注1:此操作会擦除系统中的用户数据,需要做好备份<br>
+
Note 1: This operation will erase user data in the system, so please make a backup beforehand.<br>
注2:需要将固件(或boot.img) 更新至2023/03/14或之后的版本<br>
+
Note 2: The firmware (or boot.img) needs to be updated to version on or after March 14th, 2023<br>
 +
Note 3: The device node /dev/mmcblkX needs to be changed to the actual device. For eMMC, the device node is /dev/mmcblk2, and for TF card, the device node is /dev/mmcblk0.
 
<br>
 
<br>
下面是以TF卡启动的情况下的操作作为例子,如果是eMMC启动,需要将存储设备名由/dev/mmcblk0改为/dev/mmcblk2:
+
* Check the current partition layout
* 查看当前的分区布局
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sudo apt update
 
sudo apt update
 
sudo apt install parted fdisk
 
sudo apt install parted fdisk
sudo parted -s /dev/mmcblk0 unit MiB print
+
export DEV=/dev/mmcblkX
 +
sudo parted -s ${DEV} unit MiB print
 
</syntaxhighlight>
 
</syntaxhighlight>
* 调整userdata分区至8G
+
* Adjust the userdata partition to 8GB
这里是以8G作为例子,具体的分区大小可根据需要自行调整:
+
Here, 8GB is used as an example. The partition size can be adjusted according to your needs:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo passwd root  # 为root用户创建密码
+
sudo passwd root  # Create a password for the root user
 
su - root -c 'echo "overlayfs=enable userdata=8096" > /.init_wipedata'
 
su - root -c 'echo "overlayfs=enable userdata=8096" > /.init_wipedata'
 
sudo reboot
 
sudo reboot
 
</syntaxhighlight>
 
</syntaxhighlight>
重启后确认分区已经调整完成,正常可以看到userdata分区已调整为8GB:
+
After reboot, confirm that the partition has been adjusted and you can see that the userdata partition is now 8GB:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo parted -s /dev/mmcblk0 unit MiB print
+
sudo parted -s ${DEV} unit MiB print
 
</syntaxhighlight>
 
</syntaxhighlight>
* 创建新分区并格式化
+
* Create a new partition and format it:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
(echo n; echo ""; echo ""; echo ""; echo w) | sudo fdisk /dev/mmcblk0
+
(echo n; echo ""; echo ""; echo ""; echo w) | sudo fdisk ${DEV}
sudo mkfs.ext4 /dev/mmcblk0p10
+
NUM=$(sudo parted ${DEV} print | awk 'NF > 1 {p = $1} END {print p}')  # Get the index of the last partition
 +
sudo mkfs.ext4 ${DEV}p${NUM}
 
</syntaxhighlight>
 
</syntaxhighlight>
* 挂载分区到docker数据目录
+
* Mount the partition to the Docker data directory:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sudo mkdir /var/lib/docker
 
sudo mkdir /var/lib/docker
sudo blkid /dev/mmcblk0p10
+
sudo blkid ${DEV}p${NUM}
# 配置自动挂载
+
# Configure automatic mounting
 
sudo vi /etc/fstab
 
sudo vi /etc/fstab
# 在文件末尾加入如下内容(其中UUID需替换为真实的)
+
# Add the following content to the end of the file (where UUID needs to be replaced with the actual one).
 
UUID=2efab5a5-8b74-41d2-8747-4c00fff8514a /var/lib/docker ext4 suid,dev,exec,auto,nouser,async,noatime,nofail 0 0
 
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
 
sudo mount /var/lib/docker
Line 126: Line 128:
 
sudo docker info
 
sudo docker info
 
</syntaxhighlight>
 
</syntaxhighlight>
可以发现Docker使用了overlay2存储驱动:
+
You can see that Docker is using the overlay2 storage driver:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ docker info | grep storage -i
 
$ docker info | grep storage -i

Revision as of 05:51, 16 March 2023

1 Work with Debian Core

1.1 Account & Password

Regular Account:
    User Name: pi
    Password: pi

Root:
    the root user account is disabled by default, you may configure the root password through the 'sudo passwd root' command.

1.2 View IP address

Since the Debian Bullseye hostname is the hardware model by default, you can use the ping command to get the IP address:ping {{{1}}}
Debian Bullseye uses network-manager to manage the network, and the network ports are configured to automatically obtain IP addresses by DHCP (including devices with multiple network ports).

1.3 Connect to Debian via SSH

Run the following commandssh pi@{{{1}}}
The default password is: pi

1.4 Update Software Packages

$ sudo apt-get update

1.5 Change time zone

1.5.1 Check the current time zone

timedatectl

1.5.2 List all available time zones

timedatectl list-timezones

1.5.3 Set the time zone (e.g. Shanghai)

sudo timedatectl set-timezone Asia/Shanghai

Replace the following two files in the kernel source code directory and recompile the kernel:
kernel/logo.bmp
kernel/logo_kernel.bmp
Or use the script to operate, as shown below:

  • Download scripts:
git clone https://github.com/friendlyarm/sd-fuse_rk3399.git -b kernel-4.19 --single-branch
cd sd-fuse_rk3399
  • Compile kernel and repackage firmware
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-bullseye-core-arm64
sudo ./mk-sd-image.sh debian-bullseye-core-arm64
sudo ./mk-emmc-image.sh debian-bullseye-core-arm64


1.7 Soft Factory Reset

Execute the following command in a terminal:

sudo firstboot && sudo reboot

1.8 Install Docker

1.8.1 Create an additional partition for Docker

Note 1: This operation will erase user data in the system, so please make a backup beforehand.
Note 2: The firmware (or boot.img) needs to be updated to version on or after March 14th, 2023
Note 3: The device node /dev/mmcblkX needs to be changed to the actual device. For eMMC, the device node is /dev/mmcblk2, and for TF card, the device node is /dev/mmcblk0.

  • Check the current partition layout
sudo apt update
sudo apt install parted fdisk
export DEV=/dev/mmcblkX
sudo parted -s ${DEV} unit MiB print
  • Adjust the userdata partition to 8GB

Here, 8GB is used as an example. The partition size can be adjusted according to your needs:

sudo passwd root  # Create a password for the root user
su - root -c 'echo "overlayfs=enable userdata=8096" > /.init_wipedata'
sudo reboot

After reboot, confirm that the partition has been adjusted and you can see that the userdata partition is now 8GB:

sudo parted -s ${DEV} unit MiB print
  • Create a new partition and format it:
(echo n; echo ""; echo ""; echo ""; echo w) | sudo fdisk ${DEV}
NUM=$(sudo parted ${DEV} print | awk 'NF > 1 {p = $1} END {print p}')  # Get the index of the last partition
sudo mkfs.ext4 ${DEV}p${NUM}
  • Mount the partition to the Docker data directory:
sudo mkdir /var/lib/docker
sudo blkid ${DEV}p${NUM}
# Configure automatic mounting
sudo vi /etc/fstab
# Add the following content to the end of the file (where UUID needs to be replaced with the actual one).
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

1.8.2 Install Docker Engine

sudo apt install curl ca-certificates uidmap
curl -fsSL https://get.docker.com | bash

Let’s verify:

sudo docker info

You can see that Docker is using the overlay2 storage driver:

$ docker info | grep storage -i
 Storage Driver: overlay2

1.8.3 Run Docker as a non-root user

sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo systemctl restart docker
sudo chmod a+rw /var/run/docker.sock

Let’s verify:

docker images

1.8.4 Testing Docker: Installing Nextcloud with docker

mkdir ~/nextcloud -p
docker run -d -p 8888:80  --name nextcloud  -v ~/nextcloud/:/var/www/html/ --restart=always --privileged=true  arm64v8/nextcloud

After installation, visit: http://Device-IP-Address:8888 on your computer browser to view the nextcloud web page.