Install zfs on Ubuntu
sudo add-apt-repository ppa:zfs-native/stable
sudo apt-get update
sudo apt-get install ubuntu-zfs
sudo zfs list
Check your drive info
sudo smartctl -i /dev/sda
sudo hdparm -I /dev/sda
sudo hdparm -I /dev/sda | grep 'Serial Number'
Label your drives!
sudo fdisk -l
sudo lsblk --nodeps -o name,serial
sudo lsblk --nodeps -o name,model,serial,size
sudo lsblk --nodeps -o name,model,serial,size,tran
sudo lsblk --nodeps -no serial /dev/sda
sudo lshw -class disk -short
sudo lshw -class disk | less
sudo lshw -short
For freebsd
gpart show
gpart show adax
camcontrol identify adax
glabel status
egrep 'ad[0-9]|cd[0-9]' /var/run/dmesg.boot
atacontrol list
camcontrol devlist
Create a zfs pool (striped)
RAID 0 (-f overrides any errors due to existing file system)
sudo zpool create -f myPoolZFS /dev/sdx /dev/sdxx /dev/sdxxx
Create a zfs pool (raidz = RAID 5)
RAID 5 (raidz)
sudo zpool create -f myPoolZFS raidz /dev/x /dev/xx /dev/xxx
Confirm your zfs pool
sudo zpool status
df -h
Create a dataset in the pool
sudo zfs create pool_name/directory_name
Setting Quotas
sudo zfs set quota=100G myPoolKim/iSCSI
sudo zfs get quota myPoolKim/iSCSI
Take snapshots
sudo zfs snapshot myPoolKim/iSCSI@xxxx-xx-xx
View snapshots
sudo zfs list -t snapshot
sudo zfs list -t snapshot -r -o name,creation
You can access them physcially
ls /myPoolKim/iSCSI/.zfs/snapshot/
View space used for snapshots
zfs list -o space
Rollback snapshots
To roll back to an earlier snapshot, all intermediate snapshots must be destroyed.
sudo zfs rollback myPoolKim/iSCSI@xxxx-xx-xx
Maintenance
Start scrubbing and see the status or stop scrub
sudo zpool scrub PoolName
sudo zpool status PoolName
sudo zpool scrub -s PoolName
You need to destroy existing pool if you do not have enough drives to play
sudo zpool destroy myPoolZFS
Adding more drives to your pool for more storage
sudo zpool add -f myPoolZFS raidz /dev/y /dev/yy /dev/yyy
Check increased storage space & iostat
sudo zpool status && df -h
zpool iostat -v 5 5
#Getting all parameters
sudo zfs set quota=50M PoolName
sudo zfs set quota=none PoolName/Apache
sudo zfs set compression=lzjb PoolName/apache
sudo zfs get compressratio PoolName/apache
sudo zfs get compress PoolName
sudo zfs get all PoolName
How to replace a dead drive
Offline the dead drive and insert a new drive
sudo zpool offline Poolname DeadDeviceName
sudo zpool online PoolName DeadDeviceName
Replace a dead drive with new one (on the same slot)
zpool replace PoolName DeadDeviceName
zpool replace PoolName 16201382842022959672X adaX
Replace a dead drive with new one (if you have inserted extra new drive on another port or HBA)
zpool replace PoolName DeadDeviceName NewDeviceName
Replace a dead drive with larger one
#You must replace all drives in the RAID to enjoy larger drives
sudo zpool set autoexpand=on PoolName
sudo zpool replace PoolName DeadDrive NewBiggerDrive
If you wish to improve performance of your zfs pool
sudo zpool add PoolName cache /dev/ssd1 /dev/ssd2
sudo zpool add PoolName log mirror /dev/ssd1 /dev/ssd2