Zfs Dataset Best Option For Media

Zfs dataset best option for media

ZFS has three main structures exposed to the user - ZFS storage pools, ZFS datasets and ZFS volumes.

Zfs dataset best option for media

Though ZFS now has Solaris ZFS and Open ZFS two branches, but most of concepts and main structures are still same, so far.

In below examples, I used OpenZFS version 0.6.3 on RHEL

ZFS pool

A ZFS storage pool consists of one or more block devices ("vdevs", e.g. hard drives or partitions) that operate in various modes (JBOD, mirror, RAID-Z).

Zfs dataset best option for media

ZFS storage pools are operated with the "zpool" command. Each ZFS storage pool can contain ZFS volumes and ZFS datasets.

For exampoe, here is an zfs pool status output, shows list of disk drives in ZFS pool zpool12_4.

# zpool status zpool12_4
  pool: zpool12_4
 state: ONLINE
  scan: none requested

    zpool12_4   ONLINE       0     0     0
      raidz2-0  ONLINE       0     0     0
        c0t6    ONLINE       0     0     0
        c0t7    ONLINE       0     0     0
        c1t6    ONLINE       0     0     0
        c1t7    ONLINE       0     0     0
        c2t6    ONLINE       0     0     0
        c2t7    ONLINE       0     0     0
        c3t6    ONLINE       0     0     0
        c3t7    ONLINE       0     0     0
        c4t6    ONLINE       0     0     0
        c4t7    ONLINE       0     0     0
        c5t6    ONLINE       0     0     0
        c5t7    ONLINE       0     0     0

errors: No known data errors

Another example shows zpool properities.

# zpool get all zpool12_4
NAME       PROPERTY               VALUE                  SOURCE
zpool12_4  size                   10.9T                  -
zpool12_4  capacity               1%                     -
zpool12_4  altroot                -                      default
zpool12_4  health                 ONLINE                 -
zpool12_4  guid                   8662571455768505881    default
zpool12_4  version                -                      default
zpool12_4  bootfs                 -                      default
zpool12_4  delegation             on                     default
zpool12_4  autoreplace            off                    default
zpool12_4  cachefile              -                      default
zpool12_4  failmode               wait                   default
zpool12_4  listsnapshots          off                    default
zpool12_4  autoexpand             off                    default
zpool12_4  dedupditto             0                      default
zpool12_4  dedupratio             1.00x                  -
zpool12_4  free                   10.8T                  -
zpool12_4  allocated              116G                   -
zpool12_4  readonly               off                    -
zpool12_4  ashift                 0                      default
zpool12_4  comment                -                      default
zpool12_4  expandsize             0                      -
zpool12_4  freeing                0                      default
zpool12_4  [email protected]_destroy  enabled                local
zpool12_4  [email protected]_bpobj    enabled                local
zpool12_4  [email protected]_compress   enabled                local

ZFS datasets

ZFS datasets are the user visible ZFS filesystems that contain files and directories and are operated with the "zfs" command.

Here are some examples of zfs commands.

Quick check zfs version

# zfs upgrade
This system is currently running ZFS filesystem version 5.

All filesystems are formatted with the current version.# zfs upgrade -v
The following filesystem versions are supported:

---  --------------------------------------------------------
 1   Initial ZFS filesystem version
 2   Enhanced directory entries
 3   Case insensitive and filesystem user identifier (FUID)
 4   userquota, groupquota properties
 5   System attributes

For more information on a particular version, including supported releases,
see the ZFS Administration Guide.

ZFS dataset properities

# zfs get all zpool12_4
NAME       PROPERTY              VALUE                  SOURCE
zpool12_4  type                  filesystem             -
zpool12_4  creation              Fri Oct 10 12:35 2014  -
zpool12_4  used                  96.0G                  -
zpool12_4  available             8.77T                  -
zpool12_4  referenced            96.0G                  -
zpool12_4  compressratio         1.00x                  -
zpool12_4  mounted               yes                    -
zpool12_4  quota                 none                   default
zpool12_4  reservation           none                   default
zpool12_4  recordsize            128K                   default
zpool12_4  mountpoint            /zpool12_4             local
zpool12_4  sharenfs              off                    default
zpool12_4  checksum              on                     default
zpool12_4  compression           off                    default
zpool12_4  atime                 on                     default
zpool12_4  devices               on                     default
zpool12_4  exec                  on                     default
zpool12_4  setuid                on                     default
zpool12_4  readonly              off                    default
zpool12_4  zoned                 off                    default
zpool12_4  snapdir               hidden                 default
zpool12_4  aclinherit            restricted             default
zpool12_4  canmount              on                     default
zpool12_4  xattr                 on                     default
zpool12_4  copies                1                      default
zpool12_4  version               5                      -
zpool12_4  utf8only              off                    -
zpool12_4  normalization         none                   -
zpool12_4  casesensitivity       sensitive              -
zpool12_4  vscan                 off                    default
zpool12_4  nbmand                off                    default
zpool12_4  sharesmb              off                    default
zpool12_4  refquota              none                   default
zpool12_4  refreservation        none                   default
zpool12_4  primarycache          all                    default
zpool12_4  secondarycache        all                    default
zpool12_4  usedbysnapshots       0                      -
zpool12_4  usedbydataset         96.0G                  -
zpool12_4  usedbychildren        753K                   -
zpool12_4  usedbyrefreservation  0                      -
zpool12_4  logbias               latency                default
zpool12_4  dedup                 off                    default
zpool12_4  mlslabel              none                   default
zpool12_4  sync                  standard               default
zpool12_4  refcompressratio      1.00x                  -
zpool12_4  written               96.0G                  -
zpool12_4  logicalused           96.0G                  -
zpool12_4  logicalreferenced     96.0G                  -
zpool12_4  snapdev               hidden                 default
zpool12_4  acltype               off                    default
zpool12_4  context               none                   default
zpool12_4  fscontext             none                   default
zpool12_4  defcontext            none                   default
zpool12_4  rootcontext           none                   default
zpool12_4  relatime              off                    default

You can also create more datasets on one ZFS pool

# zfs create zpool12_3/lun1

# zfs create zpool12_3/lun1/sub1

Interesting thing is that they have equal size.

# zfs list
zpool12_1            2.84M  7.50T   329K  /zpool12_1
zpool12_2             931K  8.00T  68.2K  /zpool12_2
zpool12_3            19.7G  8.14T   384K  /zpool12_3
zpool12_3/lun1        640K  8.14T   329K  /zpool12_3/lun1
zpool12_3/lun1/sub1   311K  8.14T   311K  /zpool12_3/lun1/sub1
zpool12_3/lun2       9.40G  8.14T  9.40G  /zpool12_3/lun2
zpool12_3/lun3        311K  8.14T   311K  /zpool12_3/lun3
zpool12_4            96.0G  8.77T  96.0G  /zpool12_4

To manage them, use quota property.

# zfs set quota=2G zpool12_3/lun1
# zfs list
zpool12_1            2.84M  7.50T   329K  /zpool12_1
zpool12_2             931K  8.00T  68.2K  /zpool12_2
zpool12_3            20.7G  8.13T   384K  /zpool12_3
zpool12_3/lun1        640K  2.00G   329K  /zpool12_3/lun1
zpool12_3/lun1/sub1   311K  2.00G   311K  /zpool12_3/lun1/sub1
zpool12_3/lun2       10.4G  8.13T  10.4G  /zpool12_3/lun2
zpool12_3/lun3        311K  8.13T   311K  /zpool12_3/lun3
zpool12_4            96.0G  8.77T  96.0G  /zpool12_4

Note: zfs colone feature is also based on datasets.

ZFS volumes

ZFS volumes are virtual block devices that can be used in the operating system like any other block device.

FreeNAS Corral: VDEVs, Pools, Datasets, Shares

# zfs create -V 10g zpool12_3/lun4

Here is zfs list looks like(zool12_3 only)

zpool12_3            21.4G  8.13T   384K  /zpool12_3
zpool12_3/lun1        640K  2.00G   329K  /zpool12_3/lun1
zpool12_3/lun1/sub1   311K  2.00G   311K  /zpool12_3/lun1/sub1
zpool12_3/lun2       11.1G  8.13T  11.1G  /zpool12_3/lun2
zpool12_3/lun3        311K  8.13T   311K  /zpool12_3/lun3
zpool12_3/lun4       10.3G  8.14T   379M  -

Now, you can use the device /dev/zvol/zpool12_3/lun4 as a regular virtual block device

#mkfs -t ext3 -L lun4 /dev/zvol/zpool12_3/lun4
#mount /dev/zvol/zpool12_3/lun4 /lun4
# df -k /lun4
Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/zd0        10321208 23028   9773892   1% /lun4

ZFS volume properities, very similar with datasets(no version).

# zfs get all zpool12_3/lun4
NAME            PROPERTY              VALUE                  SOURCE
zpool12_3/lun4  type                  volume                 -
zpool12_3/lun4  creation              Wed Oct 15  0:18 2014  -
zpool12_3/lun4  used                  10.3G                  -
zpool12_3/lun4  available             8.14T                  -
zpool12_3/lun4  referenced            379M                   -
zpool12_3/lun4  compressratio         1.00x                  -
zpool12_3/lun4  reservation           none                   default
zpool12_3/lun4  volsize               10G                    local
zpool12_3/lun4  volblocksize          8K                     -
zpool12_3/lun4  checksum              on                     default
zpool12_3/lun4  compression           off                    default
zpool12_3/lun4  readonly              off                    default
zpool12_3/lun4  copies                1                      default
zpool12_3/lun4  refreservation        10.3G                  local
zpool12_3/lun4  primarycache          all                    default
zpool12_3/lun4  secondarycache        all                    default
zpool12_3/lun4  usedbysnapshots       0                      -
zpool12_3/lun4  usedbydataset         379M                   -
zpool12_3/lun4  usedbychildren        0                      -
zpool12_3/lun4  usedbyrefreservation  9.94G                  -
zpool12_3/lun4  logbias               latency                default
zpool12_3/lun4  dedup                 off                    default
zpool12_3/lun4  mlslabel              none                   default
zpool12_3/lun4  sync                  standard               default
zpool12_3/lun4  refcompressratio      1.00x                  -
zpool12_3/lun4  written               379M                   -
zpool12_3/lun4  logicalused           164M                   -
zpool12_3/lun4  logicalreferenced     164M                   -
zpool12_3/lun4  snapdev               hidden                 default
zpool12_3/lun4  context               none                   default
zpool12_3/lun4  fscontext             none                   default
zpool12_3/lun4  defcontext            none                   default
zpool12_3/lun4  rootcontext           none                   default

Category: Storage
Hits: 13046