8,367
edits
Changes
→关机和重启开发板的方法
<span id="the-method-of-shutting-down-and-restarting-the-development-board"></span>
== 关机和重启开发板的方法 How to use the ZFS file system ==
{| class="wikitable" style="background-color:#ffffdc;width:800px;"
|-
|
<big>'''最新版本的Ubuntu20The latest version of Ubuntu20.04、Ubuntu2204, Ubuntu22.04, Debian11 and Debian12 desktop version systems have pre-installed zfs, you can use it directly.04、Debian11和Debian12桌面版系统中已经预装了zfs,直接使用即可。'''
'''在Ubuntu20The pre-installed zfs version in Ubuntu20.04、Ubuntu2204 and Ubuntu22.04桌面版系统中预装的zfs版本是204 desktop systems is 2.1.6。6.'''
'''在Debian11和Debian12桌面版系统中预装的zfs版本是2The pre-installed zfs version in Debian11 and Debian12 desktop systems is 2.1.11。11.'''
'''系统启动后,首先请确认下zfs的内核模块有没有被加载,如果使用lsmod命令可以看到zfs相关的内容,就说明系统已经预装了zfs。After the system starts, please first confirm whether the zfs kernel module has been loaded. If you can see zfs-related content using the lsmod command, it means that the system has pre-installed zfs.'''
orangepi@orangepi:~$ '''lsmod | grep "zfs"'''</big>
|}
=== 安装ZFS的方法 How to install ZFS ===
{| class="wikitable" style="background-color:#ffffdc;width:800px;"
|-
|
<big>'''安装zfs前,请先确保使用的linux镜像为最新版本。另外,如果系统中已经安装了zfs,就无需重复安装了。Before installing zfs, please ensure that the Linux image used is the latest version. In addition, if zfs is already installed in the system, there is no need to install it again.'''</big>
|}
<p>[[File:5plus-3.png]]</p>
{| class="wikitable" style="width:800px;"
|-
|}
{| class="wikitable" style="width:800px;"
|}
{| class="wikitable" style="background-color:#ffffdc;width:800px;"
|}
{| class="wikitable" style="width:800px;"
|}
=== 创建ZFS池的方法 Methods of creating ZFS pools ===
{| class="wikitable" style="background-color:#ffffdc;width:800px;"
|-
|
<big>'''ZFS是基于存储池的,我们可以将多个物理存储设备添加到池中,然后从这个池中分配存储空间。ZFS is based on storage pools, we can add multiple physical storage devices to the pool, and then allocate storage space from this pool.'''
'''下面的内容是基于开发板接了一个NVMe SSD和一个U盘来演示的。The following content is demonstrated based on the development board connected to an NVMe SSD and a USB flash drive.'''</big>
|}
1) 首先我们可以通过First, we can use the '''lsblk'''命令查看下开发板所有的存储设备,当前开发板接了一个NVMe SSD以及一个U盘,输出如下所示:command to view all storage devices on the development board. The current development board is connected to an NVMe SSD and a U disk. The output is as follows:
<p>[[File:5plus-4.png]]</p>
2) 然后输入下面的命令可以创建一个ZFS池,包含NVMe SSD和U盘两个存储设备Then enter the following command to create a ZFS pool, including two storage devices, NVMe SSD and U disk
{| class="wikitable" style="width:800px;"
|}
3) 然后使用Then use the '''zpool list'''命令可以看到系统已经创建了一个名为pool1的ZFS池,并且ZFS池pool1的大小是NVME SSD的大小加上U盘的大小command to see that the system has created a ZFS pool named '''pool1''', and the size of the ZFS pool pool1 is the size of the NVME SSD plus the size of the U disk
<p>[[File:5plus-5.png]]</p>
4) 然后执行Then execute '''df -h'''可以看到to see that '''pool1'''被挂载到了is mounted to the '''/pool1'''目录directory
{| class="wikitable" style="width:800px;"
'''pool1 489G 9.3M 489G 1% /pool1''' <br>
|}
5) 使用下面的命令可以看到pool1的文件系统类型为zfsUse the following command to see that the file system type of pool1 is zfs
{| class="wikitable" style="width:800px;"
pool1 on /pool1 type '''zfs''' (rw,xattr,noacl)
|}
6) 然后我们可以测试下拷贝一个文件到ZFS池中Then we can test copying a file to the ZFS pool
{| class="wikitable" style="width:800px;"
|}
=== 测试ZFS的数据去重功能 Test the data deduplication function of ZFS ===1) ZFS的数据去重功能默认是关闭的,我们需要执行下面的命令打开The data deduplication function of ZFS is disabled by default, we need to execute the following command to enable it
{| class="wikitable" style="width:800px;"
orangepi@orangepi:~$ '''sudo zfs set dedup=on pool1'''
|}
2) 然后做一个简单的测试,首先进入pool1中,再执行下面的命令生成1个1G大小的随机文件Then do a simple test, first enter pool1, and then execute the following command to generate a random file with a size of 1G
{| class="wikitable" style="width:800px;"
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 5.04367 s, 213 MB/s <br>
|}
3) 然后使用下面的命令将1G大小的随机文件拷贝1000份Then use the following command to copy 1000 random files of size 1G
{| class="wikitable" style="width:800px;"
root@orangepi:/pool1$ '''for ((i=0; i<1000; i++)); do sudo cp test.1g $i.test.1g; done'''
|}
4) 然后用Then use '''du -lh'''可以看到目前池中总共有1002G的数据,但实际上ZFS池的大小只有to see that there are currently 1002G of data in the pool, but in fact the size of the ZFS pool is only '''504GB'''(SSD(the total capacity of SSD+U盘的总容量),是装不下那么大的数据的U disk), which cannot hold such a large amount of data
{| class="wikitable" style="width:800px;"
1002G
|}
5) 然后用Then use the '''zpool list'''命令可以看到实际只占用了1command to see that only 1.01G is actually occupied, because these 1001 files are all duplicates, indicating that the data deduplication function is effective.01G,因为这1001个文件都是重复的,说明数据去重功能有效。
<p>[[File:5plus-6.png]]</p>
=== 测试ZFS的数据压缩功能 Test the data compression function of ZFS ===
1) 因为存储的数据不同,压缩节省的磁盘空间也会有所不同,所以我们选择压缩比较大的纯文本文件来进行压缩测试,执行下面的命令将Because the stored data is different, the disk space saved by compression will also be different, so we choose to compress relatively large plain text files for compression testing, and execute the following commands to pack the '''/var/log/'''和and '''/etc/'''目录打包成tar包directories into a tarball
{| class="wikitable" style="width:800px;"
root@orangepi:/pool1$ '''sudo tar -cf text.tar /var/log/ /etc/'''
|}
2) 然后通过Then the file size that can be seen through the '''ls -lh'''命令可以看到的文件大小以及在ZFS池中占用的空间都是command and the space occupied in the ZFS pool are both '''27M'''
<p>[[File:5plus-7.png]]</p>
3) 然后我们在ZFS池pool1中启用压缩功能Then we enable compression in the ZFS pool pool1
{| class="wikitable" style="width:800px;"
root@orangepi:/pool1$ '''sudo zfs set compression=lz4 pool1'''
|}
4) 然后再次执行下面的命令将Then execute the following command again to package the '''/var/log/'''和and '''/etc/'''目录打包成tar包directories into a tar package
{| class="wikitable" style="width:800px;"
root@orangepi:/pool1$ '''sudo tar -cf text.tar /var/log/ /etc/'''
|}
5) 这时可以看到At this time, you can see that the size of the '''text.tar'''文件大小还是27M,但是在ZFS池中只占用9file is still 27M, but it only occupies 9.47M的空间,说明文件被压缩了47M in the ZFS pool, indicating that the file is compressed
<p>[[File:5plus-8.png]]</p>
== The method of shutting down and restarting the development board ==