注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "ZFS/zh-cn"

From Funtoo
Jump to navigation Jump to search
(Created page with "ZFS")
 
(Updating to match new version of source page)
 
(14 intermediate revisions by one other user not shown)
Line 1: Line 1:
<div class="mw-translate-fuzzy">
<languages/>
<languages/>
ZFS is an advanced filesystem that is available for use in Funtoo Linux, thanks to the ZFS on Linux project.
{{Warning|Funtoo Linux 项目目前还不能推荐 Linux 上的 ZFS 用于生产中。事实上,我们建议你不要在生产中使用 ZFS。我们已经在这个文件系统上遇到了一些问题,即使在做了一些非常重要的努力使它工作得更可靠。请使用 [[Btrfs/zh-cn|BTRFS]] 代替。它比传闻中的要好。}}


ZFS 是一个先进的文件系统,由于 ZFS on Linux 项目,它可以在 Funtoo Linux 中使用。
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
ZFS is an advanced filesystem that is available for use in Funtoo Linux, thanks to the ZFS on Linux project.
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
It is easy to set up and use ZFS. In this simple introduction, we're going to set up ZFS under Funtoo Linux using an existing {{c|debian-sources}} or {{c|debian-sources-lts}} kernel like the one that comes pre-built for you with Funtoo Linux, and we will also be using our ZFS storage pool for storing data that isn't part of the Funtoo Linux installation itself. This means that we don't need to worry about enabling ZFS support in GRUB, or mounting ZFS to actually boot Funtoo Linux. Funtoo Linux will boot from a non-ZFS filesystem, and as part of the initialization process will initialize our ZFS storage pool and mount it at the location of our choice.
It is easy to set up and use ZFS. In this simple introduction, we're going to set up ZFS under Funtoo Linux using an existing {{c|debian-sources}} or {{c|debian-sources-lts}} kernel like the one that comes pre-built for you with Funtoo Linux, and we will also be using our ZFS storage pool for storing data that isn't part of the Funtoo Linux installation itself. This means that we don't need to worry about enabling ZFS support in GRUB, or mounting ZFS to actually boot Funtoo Linux. Funtoo Linux will boot from a non-ZFS filesystem, and as part of the initialization process will initialize our ZFS storage pool and mount it at the location of our choice.
</div>


== Installation ==
== 安装 ==


To install ZFS, perform the following steps:
要安装 ZFS,执行以下步骤:


{{console|body=
{{console|body=
Line 12: Line 22:
}}
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
This will emerge the ZFS userspace tools ({{c|zfs}}) as well as ZFS kernel modules ({{c|zfs-kmod}} and {{c|spl}}). Once complete, enable ZFS in your default runlevel as follows:
This will emerge the ZFS userspace tools ({{c|zfs}}) as well as ZFS kernel modules ({{c|zfs-kmod}} and {{c|spl}}). Once complete, enable ZFS in your default runlevel as follows:
</div>


{{console|body=
{{console|body=
Line 19: Line 31:
}}
}}


ZFS is now initialized and ready for use.
ZFS 现在已经初始化,可以使用了。


== ZFS Concepts ==
== ZFS 概念 ==


<div lang="en" dir="ltr" class="mw-content-ltr">
Unlike traditional filesystems like ext4 and xfs, ZFS is an all-inclusive storage technology that manages its own filesystems without using {{f|/etc/fstab}}. The ZFS concept of ''importing'' volumes and their associated filesystems makes them available for use by the operating system. This will be performed when the system boots via the {{c|zfs-import}} startup script.
Unlike traditional filesystems like ext4 and xfs, ZFS is an all-inclusive storage technology that manages its own filesystems without using {{f|/etc/fstab}}. The ZFS concept of ''importing'' volumes and their associated filesystems makes them available for use by the operating system. This will be performed when the system boots via the {{c|zfs-import}} startup script.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
ZFS also generally manages the physical disks that it uses, and physical disks are added to a ZFS storage pool. Then, ZFS can create volumes from the storage pool on which
ZFS also generally manages the physical disks that it uses, and physical disks are added to a ZFS storage pool. Then, ZFS can create volumes from the storage pool on which
files can be stored.  
files can be stored.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Unlike traditional Linux filesystems, ZFS filesystems will allocate storage on-demand from the underlying storage pool. Thus, we can set the "size" of a ZFS volume, but this space only actually allocated when files are stored on the filesystem. In contrast, traditional Linux filesystems like ext4 and xfs must be assigned underlying block storage in advance.
Unlike traditional Linux filesystems, ZFS filesystems will allocate storage on-demand from the underlying storage pool. Thus, we can set the "size" of a ZFS volume, but this space only actually allocated when files are stored on the filesystem. In contrast, traditional Linux filesystems like ext4 and xfs must be assigned underlying block storage in advance.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
In ZFS terminology, a ZFS ''storage pool'' can hold the following things, all of which are considered to be ''datasets'':
In ZFS terminology, a ZFS ''storage pool'' can hold the following things, all of which are considered to be ''datasets'':
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
* ''filesystems'' - these are what get mounted and you store files in. Generally, this is the main thing people use ZFS for.
* ''filesystems'' - these are what get mounted and you store files in. Generally, this is the main thing people use ZFS for.
* ''clones'' - a filesystem that is created as a copy of an existing ''snapshot''.
* ''clones'' - a filesystem that is created as a copy of an existing ''snapshot''.
* ''snapshots'' - a read-only copy of a filesystem at a given point in time.
* ''snapshots'' - a read-only copy of a filesystem at a given point in time.
* ''volume'' - a dataset that acts as a block device, such as a swap device.
* ''volume'' - a dataset that acts as a block device, such as a swap device.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
When you inspect the contents of a ZFS storage pool, you will see potentially all these different types of things listed as the contents of the pool, and their names will appear in a {{c|pool/path[@snapshot]}} format. ''Pool'' is the name of the storage pool. ''Path'' is a slash-delimited path name for the component, and the slashes don't represent directories but a logical organizational hierarchy for the dataset in the pool.
When you inspect the contents of a ZFS storage pool, you will see potentially all these different types of things listed as the contents of the pool, and their names will appear in a {{c|pool/path[@snapshot]}} format. ''Pool'' is the name of the storage pool. ''Path'' is a slash-delimited path name for the component, and the slashes don't represent directories but a logical organizational hierarchy for the dataset in the pool.
</div>


== Creating a Storage Pool ==
== 创建存储池 ==


To create a basic ZFS storage pool, you will need an extra empty disk. Perform the following steps:
要创建一个基本的 ZFS 存储池,将需要一个额外的空磁盘。执行以下步骤:


{{console|body=
{{console|body=
Line 47: Line 71:
}}
}}


{{c|/dev/sdxy}} should be an unused disk. You may need to use the following command if this disk contains any pre-existing data on it:
{{c|/dev/sdxy}} 应该是一个未使用的磁盘。如果这个磁盘上有任何已存在的数据,可能需要使用以下命令:


{{console|body=
{{console|body=
Line 53: Line 77:
}}
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
Once your storage pool is created, you can verify its existence with the {{c|zpool status}} command:
Once your storage pool is created, you can verify its existence with the {{c|zpool status}} command:
</div>


{{console|body=
{{console|body=
Line 70: Line 96:
}}
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
And if you type {{c|zfs list}}, you will likely see something like this:
And if you type {{c|zfs list}}, you will likely see something like this:
</div>


{{console|body=
{{console|body=
Line 78: Line 106:
}}
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
Notice the ''mountpoint'' entry of {{c|None}}. While it is possible to mount your storage pool directly and use it as a filesystem, it is best to create a filesystem as a sub-path within your pool's namespace, as follows:
Notice the ''mountpoint'' entry of {{c|None}}. While it is possible to mount your storage pool directly and use it as a filesystem, it is best to create a filesystem as a sub-path within your pool's namespace, as follows:
</div>


{{console|body=
{{console|body=
Line 88: Line 118:
}}
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
As you can see above, although we have created a ZFS filesystem, it is only using 96K of storage on our pool, although there are 459GB available. You can also see that the filesystem is currently not mounted. Rather than use the {{c|mount}} command, let's change that the ZFS way:
As you can see above, although we have created a ZFS filesystem, it is only using 96K of storage on our pool, although there are 459GB available. You can also see that the filesystem is currently not mounted. Rather than use the {{c|mount}} command, let's change that the ZFS way:
</div>


{{console|body=
{{console|body=
Line 98: Line 130:
}}
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
We have now set the {{c|mountpoint}} property on our filesystem, and can see that it is now mounted where we want it. ZFS will remember that our {{c|mypool/home}} filesystem gets mounted at {{f|/data/home}}. Most people will want their filesystems to be automatically mounted at boot and will perform the following steps to make this happen:
We have now set the {{c|mountpoint}} property on our filesystem, and can see that it is now mounted where we want it. ZFS will remember that our {{c|mypool/home}} filesystem gets mounted at {{f|/data/home}}. Most people will want their filesystems to be automatically mounted at boot and will perform the following steps to make this happen:
</div>


{{console|body=
{{console|body=
Line 104: Line 138:
}}
}}


You should now be at the point where you can begin to use ZFS for a variety of tasks. While there is a lot more to ZFS than what is covered in this short introduction, you should now have a good understanding of the fundamental concepts on which ZFS is based.
你现在应该已经到了可以开始使用 ZFS 来完成各种任务的阶段。虽然 ZFS 的内容比这篇简短的介绍要多得多,但你现在应该对 ZFS 的基本概念有了很好的理解。


[[Category:ZFS]]
[[Category:ZFS]]

Latest revision as of 23:37, December 10, 2021

Other languages:
English • ‎español • ‎português do Brasil • ‎中文(中国大陆)‎
   Warning

Funtoo Linux 项目目前还不能推荐 Linux 上的 ZFS 用于生产中。事实上,我们建议你不要在生产中使用 ZFS。我们已经在这个文件系统上遇到了一些问题,即使在做了一些非常重要的努力使它工作得更可靠。请使用 BTRFS 代替。它比传闻中的要好。

ZFS 是一个先进的文件系统,由于 ZFS on Linux 项目,它可以在 Funtoo Linux 中使用。

ZFS is an advanced filesystem that is available for use in Funtoo Linux, thanks to the ZFS on Linux project.

It is easy to set up and use ZFS. In this simple introduction, we're going to set up ZFS under Funtoo Linux using an existing debian-sources or debian-sources-lts kernel like the one that comes pre-built for you with Funtoo Linux, and we will also be using our ZFS storage pool for storing data that isn't part of the Funtoo Linux installation itself. This means that we don't need to worry about enabling ZFS support in GRUB, or mounting ZFS to actually boot Funtoo Linux. Funtoo Linux will boot from a non-ZFS filesystem, and as part of the initialization process will initialize our ZFS storage pool and mount it at the location of our choice.

安装

要安装 ZFS,执行以下步骤:

root # emerge zfs

This will emerge the ZFS userspace tools (zfs) as well as ZFS kernel modules (zfs-kmod and spl). Once complete, enable ZFS in your default runlevel as follows:

root # rc-update add zfs-import default
root # rc

ZFS 现在已经初始化,可以使用了。

ZFS 概念

Unlike traditional filesystems like ext4 and xfs, ZFS is an all-inclusive storage technology that manages its own filesystems without using /etc/fstab. The ZFS concept of importing volumes and their associated filesystems makes them available for use by the operating system. This will be performed when the system boots via the zfs-import startup script.

ZFS also generally manages the physical disks that it uses, and physical disks are added to a ZFS storage pool. Then, ZFS can create volumes from the storage pool on which files can be stored.

Unlike traditional Linux filesystems, ZFS filesystems will allocate storage on-demand from the underlying storage pool. Thus, we can set the "size" of a ZFS volume, but this space only actually allocated when files are stored on the filesystem. In contrast, traditional Linux filesystems like ext4 and xfs must be assigned underlying block storage in advance.

In ZFS terminology, a ZFS storage pool can hold the following things, all of which are considered to be datasets:

  • filesystems - these are what get mounted and you store files in. Generally, this is the main thing people use ZFS for.
  • clones - a filesystem that is created as a copy of an existing snapshot.
  • snapshots - a read-only copy of a filesystem at a given point in time.
  • volume - a dataset that acts as a block device, such as a swap device.

When you inspect the contents of a ZFS storage pool, you will see potentially all these different types of things listed as the contents of the pool, and their names will appear in a pool/path[@snapshot] format. Pool is the name of the storage pool. Path is a slash-delimited path name for the component, and the slashes don't represent directories but a logical organizational hierarchy for the dataset in the pool.

创建存储池

要创建一个基本的 ZFS 存储池,将需要一个额外的空磁盘。执行以下步骤:

root # zpool create mypool /dev/sdxy

/dev/sdxy 应该是一个未使用的磁盘。如果这个磁盘上有任何已存在的数据,可能需要使用以下命令:

root # zpool create -f mypool /dev/sdxy

Once your storage pool is created, you can verify its existence with the zpool status command:

root # zpool status
  pool: mypool
 state: ONLINE
  scan: none requested
config:

	NAME        STATE     READ WRITE CKSUM
	mypool      ONLINE       0     0     0
	  sdb       ONLINE       0     0     0

errors: No known data errors
root #

And if you type zfs list, you will likely see something like this:

root # # zfs list
NAME                                                                          USED  AVAIL  REFER  MOUNTPOINT
mypool                                                                       2.19G   459G    96K  none

Notice the mountpoint entry of None. While it is possible to mount your storage pool directly and use it as a filesystem, it is best to create a filesystem as a sub-path within your pool's namespace, as follows:

root # zfs create mypool/home
root # zfs list
NAME                                                                          USED  AVAIL  REFER  MOUNTPOINT
mypool                                                                       2.19G   459G    96K  none
mypool/home                                                                    96K   459G    96K  none

As you can see above, although we have created a ZFS filesystem, it is only using 96K of storage on our pool, although there are 459GB available. You can also see that the filesystem is currently not mounted. Rather than use the mount command, let's change that the ZFS way:

root # mkdir /data/home
root # zfs set mountpoint=/data/home mypool/home
root # mount
...
mypool/home on /data/home type zfs (rw,xattr,posixacl)

We have now set the mountpoint property on our filesystem, and can see that it is now mounted where we want it. ZFS will remember that our mypool/home filesystem gets mounted at /data/home. Most people will want their filesystems to be automatically mounted at boot and will perform the following steps to make this happen:

root # rc-update add zfs-mount default

你现在应该已经到了可以开始使用 ZFS 来完成各种任务的阶段。虽然 ZFS 的内容比这篇简短的介绍要多得多,但你现在应该对 ZFS 的基本概念有了很好的理解。