Best Practice with ZFS
This article will introduce some practicality usage of ZFS file system.
Basic Usage
Pool related
Create a pool
1
2
3
4
5
6
7
8create 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/sdcSet 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
5scan existing pool
sudo zpool import
import specific pool
sudo zpool import new-pool
Filesystem related
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
2sudo 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
Shutdown system, replace the disk, then boot up
Check the ID of disk with UNAVAIL status by executing
1
sudo zpool status
Replace with new disk
/dev/sdb
1
sudo zpool replace new-pool 4932927217405226991 /dev/sdb
Check status and wait for resilvering
1
sudo zpool status