Show File System Info#
- List all ZFS file systems
zfs list
- List all properties of a ZFS file system
zfs get all [pool-name]
Show Pool Info#
zpool status -x
- Show individual pool status with verbose output
zpool status -v [pool-name]
zpool list
- Show particular properties of all the pools (name & size)
zpool list -o name,size
- Show all pools without headers & columns
zpool list -Ho name
- Create a basic pool named datapool
zpool create datapool c0t0d0
- Force the creation of a pool
zpool create -f datapool c0t0d0
- Create a pool with a different mount point than the default.
zpool create -m /data datapool c0t0d0
zpool create datapool raidz c3t0d0 c3t1d0 c3t2d0
- Add RAID-Z vdev to pool datapool
zpool add datapool raidz c4t0d0 c4t1d0 c4t2d0
zpool create datapool raidz1 c0t0d0 c0t1d0 c0t2d0 c0t3d0 c0t4d0 c0t5d0
zpool create datapool raidz2 c0t0d0 c0t1d0 c0t2d0 c0t3d0 c0t4d0 c0t5d0
zpool create datapool mirror c0t0d0 c0t5d0
- Disk c0t0d0 is mirrored with c0t5d0 and disk c0t2d0 is mirrored withc0t4d0
zpool create datapool mirror c0t0d0 c0t5d0 mirror c0t2d0 c0t4d0
- Add new mirrored vdev to datapool
zpool add datapool mirror c3t0d0 c3t1d0
- Add spare device c1t3d0 to the datapool
zpool add datapool spare c1t3d0
- Do a dry run on pool creation
zpool create -n geekpool c1t3d0
File-system/Volume Commands#
- Create file-system fs1 under datapool
zfs create datapool/fs1
- Create 1 GB volume (Block device) in datapool
zfs create -V 1gb datapool/vol01
- destroy datapool and all datasets under it
zfs destroy -r datapool
- destroy file-system or volume (data) and all related snapshots
zfs destroy -fr datapool/data
Maintenance Commands#
- Run scrub on all file systems under data pool
zpool scrub [pool-name]
- Offline a disk untill reboot
zpool offline -t [pool-name] [disk-name]
- Online a disk to clear error count
zpool online
File System Properties#
- Set quota of 1 GB on filesystem fs1
zfs set quota=1G datapool/fs1
- Set Reservation of 1 GB on filesystem fs1
zfs set reservation=1G datapool/fs1
- Disable ZFS auto mounting and enable mounting through /etc/vfstab.
zfs set mountpoint=legacy datapool/fs1
zfs set sharenfs=on datapool/fs1
- Enable compression on fs1
zfs set compression=on datapool/fs1
- Set Dataset Record Size (Size should be a value like 16k, 128k, or 1M etc.)
zfs set recordsize=[size] pool/dataset/name
zfs get recordsize pool/dataset/name
- Display ZFS I/O Statistics every 2 seconds
zpool iostat 2
- Display detailed ZFS I/O statistics every 2 seconds
zpool iostat -v 2
Mount/Unmount Commands#
- Set the mount-point of file system fs1 to /data
zfs set mountpoint=/data datapool/fs1
zfs mount datapool/fs1
- Umount ZFS file system fs1
zfs umount datapool/fs1
- Mount all ZFS file systems
zfs mount -a
- Umount all ZFS file systems
zfs umount -a
Import/Export Commands#
- List pools available for import
zpool import
- Imports all pools found in the search directories
zpool import -a
- To search for pools with block devices not located in /dev/dsk
zpool import -d
- Search for a pool with block devices created in /zfs
zpool import -d /zfs datapool
- Import a pool originally named oldpool under new name newpool
zpool import oldpool newpool
- Import pool using pool ID
zpool import 3987837483
- Deport a ZFS pool named datapool
zpool export datapool
- Force the unmount and deport of a ZFS pool
zpool export -f datapool
Snapshot Commands#
- Create a snapshot named 12jan2014 of the fs1 filesystem
zfs snapshot datapool/fs1@12jan2014
zfs list -t snapshot
- Roll back to 10jan2014 (recursively destroy intermediate snapshots)
zfs rollback -r datapool/fs1@10jan2014
- Roll back must and force unmount and remount
zfs rollback -rf datapool/fs1@10jan2014
- Destroy snapshot created earlier
zfs destroy datapool/fs1@10jan2014
- Take a backup of ZFS snapshot locally
zfs send datapool/fs1@oct2013 > /geekpool/fs1/oct2013.bak
- Restore from the snapshot backup backup taken
zfs receive anotherpool/fs1 < /geekpool/fs1/oct2013.bak
- Combine the send and receive operation
zfs send datapool/fs1@oct2013 | zfs receive anotherpool/fs1
- Send the snapshot to a remote system node02
zfs send datapool/fs1@oct2013 | ssh node02 "zfs receive testpool/testfs "