ZFS 文件系统 - create, destroy, share

好风 发表于 2016-11-18T08:24:40.294817Z
引用地址:https://plus.ooclab.com/note/article/1302

基本操作

语法:

zfs create pool-name/[filesystem-name/]filesystem-name

创建实验环境

[root@localhost ~]# zpool create stor1 mirror vdb vdc
[root@localhost ~]# zpool status
  pool: stor1
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        stor1       ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            vdb     ONLINE       0     0     0
            vdc     ONLINE       0     0     0

errors: No known data errors

创建(create)文件系统

创建 stor1/datastor1/data/docs:

[root@localhost ~]# zfs create stor1/data
[root@localhost ~]# zfs create stor1/data/docs
[root@localhost ~]# zfs list
NAME              USED  AVAIL  REFER  MOUNTPOINT
stor1             102K   464M    19K  /stor1
stor1/data         38K   464M    19K  /stor1/data
stor1/data/docs    19K   464M    19K  /stor1/data/docs
[root@localhost ~]# df -h
文件系统         容量  已用  可用 已用% 挂载点
...
stor1            464M     0  464M    0% /stor1
stor1/data       464M     0  464M    0% /stor1/data
stor1/data/docs  464M     0  464M    0% /stor1/data/docs

创建时指定挂载目录(而不是使用文件系统名称作为默认挂载目录):

[root@localhost ~]# mkdir -p /mnt/{a,b,c,d}
[root@localhost ~]# zfs create -o mountpoint=/mnt/a stor1/data/a
[root@localhost ~]# zfs list
NAME              USED  AVAIL  REFER  MOUNTPOINT
stor1             134K   464M    19K  /stor1
stor1/data         57K   464M    19K  /stor1/data
stor1/data/a       19K   464M    19K  /mnt/a
stor1/data/docs    19K   464M    19K  /stor1/data/docs

删除/销毁(destroy)文件系统

[root@localhost ~]# zfs destroy stor1/data/a
[root@localhost ~]# zfs list
NAME              USED  AVAIL  REFER  MOUNTPOINT
stor1             105K   464M    19K  /stor1
stor1/data         38K   464M    19K  /stor1/data
stor1/data/docs    19K   464M    19K  /stor1/data/docs

重命名(rename)文件系统

[root@localhost ~]# zfs rename stor1/data/docs stor1/data/documents
[root@localhost ~]# zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
stor1                  117K   464M    19K  /stor1
stor1/data              38K   464M    19K  /stor1/data
stor1/data/documents    19K   464M    19K  /stor1/data/documents

修改属性

修改挂载点:

zfs set mountpoint=/stor/archive stor/archive