8 zfs
bucde edited this page 2022-11-10 12:43:59 +00:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

ZFS

Create ZPOOL

  • -m <MOUNTPOINT> set the mountpoint (default is /<POOLNAME>)
  • -o ashift=12 set blocksize to 4k
  • <POOLNAME> name of the pool to be created
  • <RAIDLEVEL> can be
    • LEAVE_EMPTY for striped group
    • mirror for mirrored group
    • raid10 for stripped mirror
    • raidz for single parity (like RAID5)
    • raidz2 for dual parity (like RAID5 with dual parity)
  • <DISK_x> list of all disks to be used for the new pool
    • for unique identification you should use the disk ids /dev/disk/by-id/<DISK_ID>
    • e.g. /dev/disk/by-id/ata-HGST_HTS725050A7E630_TF0500WJ09RMZL
zpool create -m <MOUNTPOINT> -o ashift=12 <POOLNAME> <RAIDLEVEL> <DISK_1> <DISK_2> ... <DISK_n>

ZPOOL compression

Enable compression for ZPOOL with:

zfs set compression=lz4 <POOLNAME>

Create ZVOL

  • -s thin zfs volume
  • -v verbose
  • -V <BYTES> size of the new zfs volume
  • <POOLNAME> name of existing pool
  • <ZVOLNAME> name of the new zfs volume
zfs create -s -v -V <BYTES> <POOLNAME>/<ZVOLNAME>

Create datastore

  • -o mountpoint=<MOUNTPOINT> set the mountpoint (default is /<POOLNAME>/<DATASTORENAME>)
  • <POOLNAME> name of existing pool
  • <DATASTORENAME> name of the new datastore
zfs create o mountpoint=<MOUNTPOINT>  <POOLNAME>/<DATASTORENAME>

Set quota for datastore

  • <SIZE> quota size (you can use M or G)
  • <POOLNAME> name of existing pool
  • <DATASTORE> name of existing datastore
zfs set quota=<SIZE> <POOLNAME>/<DATASTORE>

Adjust ZFS cache

In this example we set the ZFS cache to 4G (4294967296 bytes). Create or extend the file /etc/modprobe.d/zfs.conf with the following:

options zfs zfs_arc_min=4294967295
options zfs zfs_arc_max=4294967296

Save the file and update-initramfs -u -k all

Reboot the system.

You can show statistics with arc_summary.