Update and rename sources/tech/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md to translated/tech/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md

翻译完成,请审核
This commit is contained in:
guevaraya 2019-11-19 23:25:45 +08:00 committed by GitHub
parent d886b7bb0a
commit 0728b0c98b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 169 additions and 144 deletions

View File

@ -1,144 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (guevaraya )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Getting Started With ZFS Filesystem on Ubuntu 19.10)
[#]: via: (https://itsfoss.com/zfs-ubuntu/)
[#]: author: (John Paul https://itsfoss.com/author/john/)
Getting Started With ZFS Filesystem on Ubuntu 19.10
======
One of the main [features of Ubuntu 19.10][1] is support for [ZFS][2]. Now you can easily install Ubuntu with on ZFS without any extra effort.
Normally, you install Linux with Ext4 filesystem. But if you do a fresh install of Ubuntu 19.10, youll see the option to use ZFS on the root. You must not use it on a dual boot system though because it will erase the entire disk.
![You can choose ZFS while installing Ubuntu 19.10][3]
Lets see why ZFS matters and how to take advantage of it on ZFS install of Ubuntu.
### How ZFS is different than other filesystems?
ZFS is designed with two major goals in mind: to handle large amounts of storage and prevent data corruption. ZFS can handle up to 256 quadrillion Zettabytes of storage. (Hence the Z in ZFS.) It can also handle files up to 16 exabytes in size.
If you are limited to a single drive laptop, you can still take advantage of the data protection features in ZFS. The copy-on-write feature ensures that data that is in use is not overwritten. Instead, the new information is written to a new block and the filesystems metadata is updated to point to the new block. ZFS can easily create snapshots of the filesystem. These snapshots track changes made to the filesystem and share with the filesystem the data that is the same to save space.
ZFS assigned a checksum to each file on the drive. It is constantly checking the state of the file against that checksum. If it detects that the file has become corrupt, it will attempt to automatically repair that file.
I have written a detailed article about [what is ZFS and what its features are][2]. Please read it if you are interested in knowing more on this topic.
Note
Keep in mind that the data protection features of ZFS can lead to a reduction in performance.
### Using ZFS on Ubuntu [For intermediate to advanced users]
![][4]
Once you have a clean install of Ubuntu with ZFS on the main disk you can start [taking advantage][5] of the features that this filesystem has.
Please note that all setup of ZFS requires the command line. I am not aware of any GUI tools for it.
#### Creating a ZFS pool
_**The section only applies if you have a system with more than one drive. If you only have one drive, Ubuntu will automatically create the pool during installation.**_
Before you create your pool, you need to find out the id of the drives for the pool. You can use the command _**lsblk**_ to show this information.
To create a basic pool with three drives, use the following command:
```
sudo zpool create pool-test /dev/sdb /dev/sdc /dev/sdd.
```
Remember to replace _**pool-test**_ with the pool name of your choice.
This command will set up “a zero redundancy RAID-0 pool”. This means that if one of the drives becomes damaged or corrupt, you will lose data. If you do use this setup, it is recommended that you do regular backups.
You can alos add another disk to the pool by using this command:
```
sudo zpool add pool-name /dev/sdx
```
#### Check the status of your ZFS pool
You can check the status of your new pool using this command:
```
sudo zpool status pool-test
```
![Zpool Status][6]
#### Mirror a ZFS pool
To ensure that your data is safe, you can instead set up mirroring. Mirroring means that each drive contains the same data. With mirroring setup, you could lose two out of three drives and still have all of your information.
To create a mirror, you can use something like this:
```
sudo zpool create pool-test mirror /dev/sdb /dev/sdc /dev/sdd
```
#### Create ZFS Snapshots for backup and restore
Snapshots allow you to create a fall-back position in case a file gets deleted or overwritten. For example, lets create a snapshot, delete some folder in my home directory and restore them.
First, you need to find the dataset you want to snapshot. You can do that with the
```
zfs list
```
![Zfs List][7]
You can see that my home folder is located in **rpool/USERDATA/johnblood_uwcjk7**.
Lets create a snapshot named **1910** using this command:
```
sudo zfs snapshot rpool/USERDATA/[email protected]
```
The snapshot will be created very quickly. Now, I am going to delete the _Downloads_ and _Documents_ directories.
Now to restore the snapshot, all you have to do is run this command:
```
sudo zfs rollback rpool/USERDATA/[email protected]
```
The length of the rollback depends on how much the information changed. Now, you can check the home folder and the deleted folders (and their content) will be returned to their correct place.
### To ZFS or not?
This is just a quick glimpse at what you can do with ZFS on Ubuntu. For more information, check out [Ubuntus wiki page on ZFS.][5] I also recommend reading this [excellent article on ArsTechnica][8].
This is an experimental feature and if you are not aware of ZFS and you want to have a simple stable system, please go with the standard install on Ext4. If you have a spare machine that you want to experiment with, then only try something like this to learn a thing or two about ZFS. If you are an expert and you know what you are doing, you are free to experiment ZFS wherever you like.
Have you ever used ZFS? Please let us know in the comments below. If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][9].
--------------------------------------------------------------------------------
via: https://itsfoss.com/zfs-ubuntu/
作者:[John Paul][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/john/
[b]: https://github.com/lujun9972
[1]: https://itsfoss.com/ubuntu-19-04-release-features/
[2]: https://itsfoss.com/what-is-zfs/
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/zfs-ubuntu-19-10.jpg?ssl=1
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Using_ZFS_Ubuntu.jpg?resize=800%2C450&ssl=1
[5]: https://wiki.ubuntu.com/Kernel/Reference/ZFS
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/zpool-status.png?ssl=1
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/zfs-list.png?ssl=1
[8]: https://arstechnica.com/information-technology/2019/10/a-detailed-look-at-ubuntus-new-experimental-zfs-installer/
[9]: https://reddit.com/r/linuxusersgroup

View File

@ -0,0 +1,169 @@
[#]: collector: (lujun9972)
[#]: translator: (guevaraya )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Getting Started With ZFS Filesystem on Ubuntu 19.10)
[#]: via: (https://itsfoss.com/zfs-ubuntu/)
[#]: author: (John Paul https://itsfoss.com/author/john/)
在 Ubuntu 19.10 上入门 ZFS 文件系统
======
[Ubuntu 19.01][1] 的一个主要新特性就是 [ZFS][2]。现在你可以很容易的不要太多操作就可以在 Ubuntu 系统上安装 ZFS了。
一般情况下,安装 Linux 都会选择 Ext4 文件系统。但是如果是安装 Ubuntu 19.10,在启动阶段可以看到 ZFS 选项。但你绝对不能在双系统上用它,因为它会擦除这个磁盘。
![你可以在安装 Ubuntu 19.10 的时候选择 ZFS][3]
让我们看看 ZFS 有多重要以及如何在已经安装 ZFS 的 Ubuntu 上使用它。
### ZFS 与其他文件系统有哪些区别?
ZFS 的设计初衷是处理海量存储和避免数据损坏。ZFS 可以处理 256 千万亿的泽它字节(ZB)数据。这就是ZFS的Z且它可以处理最大16艾字节EB的文件。
如果你仅有一个单磁盘的笔记本电脑,你可以体验 ZFS 的数据保护特性。即写及时拷贝特性确保正在使用的数据不会被覆盖相反新的数据会被写到一个新的块中同时文件系统的元数据会被更新到新块中。ZFS 可容易的创建文件系统的快照。这个快照可追踪文件系统的更改,并共享数据块确保节省数据空间。
ZFS 为磁盘上的每个文件分配一个校验和。它会不断的校验文件的状态和校验和。如果发现文件被损坏了,它就会尝试修复文件。
我写过一个文章详细介绍 [什么是 ZFS以及它有哪些特性][2].如果你感兴趣可以去阅读下。
注:
请谨记 ZFS 的数据保护特性会导致性能下降。
### Ubuntu下使用 ZFS [适用于中高级用户]
![][4]
一旦你在你的主磁盘上干净安装了 Ubuntu 的 ZFS你就可以开始体验它的特性。
请注意安装 ZFS 这个过程需要命令行。我还没用过它的 GUI 工具。
#### 创建一个 ZFS 池
_**这段仅针对拥有多个磁盘的系统。如果你只有一个磁盘Ubuntu会在安装的时候自动的创建池。**_
在创建池之前你需要为池找到磁盘的id。你可以用命令 _**lsblk**_ 查询出这个信息。
为三个磁盘创建一个基础池,用以下命令:
```
sudo zpool create pool-test /dev/sdb /dev/sdc /dev/sdd.
```
请记得替换 _**pool-test**_ 为你自己的命名
这个命令将会设置“无冗余RAID-0池”。这意味着如果一个磁盘被破坏或有故障你将会丢失数据。如果你执行以上命令还是建议做一个常规备份。
你也可以增加一个磁盘到池,用下面命令:
```
sudo zpool add pool-name /dev/sdx
```
#### 查看 ZFS 池的状态
你可以用这个命令查询新建池的状态:
```
sudo zpool status pool-test
```
![Zpool 状态][6]
#### 镜像一个 ZFS 池
确保数据的安全性,你可以创建镜像。镜像意味着每个磁盘包含同样的数据。在创建镜像的磁盘上三个磁盘坏掉两个仍然可以不丢数据。
创建镜像你可以用下面命令:
```
sudo zpool create pool-test mirror /dev/sdb /dev/sdc /dev/sdd
```
#### 创建 ZFS 用于备份恢复的快照
快照可以是一个需要备份的时间点以防某个文件被删除或被覆盖。比如,我们创建一个快照,当在用户主目录下删除一些目录后,然后把他恢复。
首先,你需要找到你想要的快照数据集。你可以这样做:
```
zfs list
```
![Zfs List][7]
你可以看到我的目录位于 **rpool/USERDATA/johnblood_uwcjk7**
我们用下面命令创建一个名叫 **1910** 的快照:
```
sudo zfs snapshot rpool/USERDATA/[email protected]
```
快照很快创建完成。现在你可以删除 _Downloads__Documents_ 目录。
现在你用以下命令恢复快照:
```
sudo zfs rollback rpool/USERDATA/[email protected]
```
回滚的数据大小取决于有多少信息改变。现在你可以查看用户目录和被删目录(和它的内容)将会被恢复过来。
### 要不要试试 ZFS
这篇文章仅简单介绍的 Ubuntu下 ZFS 的用法。更多的信息请参考 [ Ubuntu 的ZFS Wiki页面][5] 我也推荐阅读 [ArsTechnica的精彩文章][8]。
这个是试验性的功能。如果你还不了解 ZFS你想用一个简单稳定的系统请安装标准文件系统 EXT4。如果你想用闲置的机器体验可以参照上面了解 ZFS。如果你是一个专家你知道你在做什么那就可以随便咋搞。
你之前用过 ZFS 吗?请在下面留言。如果你觉得这个文章还可以,请分享到社交媒体,黑客新闻或 [Reddit][9]。
--------------------------------------------------------------------------------
via: https://itsfoss.com/zfs-ubuntu/
作者:[John Paul][a]
选题:[lujun9972][b]
译者:[guevaraya](https://github.com/guevaraya)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/john/
[b]: https://github.com/lujun9972
[1]: https://itsfoss.com/ubuntu-19-04-release-features/
[2]: https://itsfoss.com/what-is-zfs/
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/zfs-ubuntu-19-10.jpg?ssl=1
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Using_ZFS_Ubuntu.jpg?resize=800%2C450&ssl=1
[5]: https://wiki.ubuntu.com/Kernel/Reference/ZFS
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/zpool-status.png?ssl=1
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/zfs-list.png?ssl=1
[8]: https://arstechnica.com/information-technology/2019/10/a-detailed-look-at-ubuntus-new-experimental-zfs-installer/
[9]: https://reddit.com/r/linuxusersgroup
know in the comments below. If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][9].
--------------------------------------------------------------------------------
via: https://itsfoss.com/zfs-ubuntu/
作者:[John Paul][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/john/
[b]: https://github.com/lujun9972
[1]: https://itsfoss.com/ubuntu-19-04-release-features/
[2]: https://itsfoss.com/what-is-zfs/
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/zfs-ubuntu-19-10.jpg?ssl=1
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Using_ZFS_Ubuntu.jpg?resize=800%2C450&ssl=1
[5]: https://wiki.ubuntu.com/Kernel/Reference/ZFS
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/zpool-status.png?ssl=1
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/zfs-list.png?ssl=1
[8]: https://arstechnica.com/information-technology/2019/10/a-detailed-look-at-ubuntus-new-experimental-zfs-installer/
[9]: https://reddit.com/r/linuxusersgroup