Best Practice with ZFS

This article will introduce some practicality usage of ZFS file system.

Basic Usage

  • Create a pool

    1
    2
    3
    4
    5
    6
    7
    8
    # create a striped pool
    sudo zpool create new-pool /dev/sdb /dev/sdc

    # create a mirrored pool
    sudo zpool create new-pool mirror /dev/sdb /dev/sdc

    # create a pool with specific mount point
    sudo zpool create -m /mnt/storage new-pool mirror /dev/sdb /dev/sdc
  • Set the mount point

    1
    sudo zfs set mountpoint=/mnt/storage new-pool
  • Check status

    1
    sudo zpool status
  • Destroy a pool

    1
    sudo zpool destroy new-pool
  • Import a pool

    1
    2
    3
    4
    5
    # scan existing pool
    sudo zpool import

    # import specific pool
    sudo zpool import new-pool
  • Create a filesysytem in a pool

    1
    sudo zfs create new-pool/new-fs
  • Destroy a filesystem in a pool

    1
    sudo zfs destroy new-pool/new-fs
  • List all filesystems in a pool

    1
    sudo zfs list
  • Set mount point for a filesystem

    1
    2
    sudo zfs set mountpoint=/mnt/storage new-pool
    sudo zfs set mountpoint=/mnt/new new-pool/new-fs

Conditions

  • How to replace disk in a mirrored pool

    1. Shutdown system, replace the disk, then boot up

    2. Check the ID of disk with UNAVAIL status by executing

      1
      sudo zpool status
    3. Replace with new disk /dev/sdb

      1
      sudo zpool replace new-pool 4932927217405226991 /dev/sdb
    4. Check status and wait for resilvering

      1
      sudo zpool status

References

Setup a ZFS storage pool

How to replace a failed disk in a ZFS mirror