Cyberithub

Top 31 ZFS File System Commands Every Unix Admin Should Know

Advertisements

In this article, I will take you through Top 31 ZFS File System Commands Every Unix Admin Should Know. As per Oracle Guide, ZFS file system is a revolutionary new file system that fundamentally changes the way file systems are administered, with features and benefits not found in any other file system available today. ZFS is robust, scalable, and easy to administer.

Top 31 ZFS File System Commands Every Unix Admin Should Know 1

ZFS File System Commands

Also Read: How to use tar command in Solaris 11

Advertisements

1. Create ZFS File system

To create zfs file system, you need to use zfs create rpool/zone1 command. Verify the filesystem created by grepping the filesystem name from zfs list command.

root@localhost:~# zfs create rpool/zone1
root@localhost:~# zfs list | grep zone1
rpool/zone1 918M 22.2G 32K /rpool/zone1
rpool/zone1/rpool 918M 22.2G 31K /rpool/zone1/root/rpool
rpool/zone1/rpool/ROOT 916M 22.2G 31K none
rpool/zone1/rpool/ROOT/solaris 916M 22.2G 816M /rpool/zone1/root
rpool/zone1/rpool/ROOT/solaris/var 89.1M 22.2G 87.8M /rpool/zone1/root/var
rpool/zone1/rpool/VARSHARE 2.44M 22.2G 1.23M /rpool/zone1/root/var/share
rpool/zone1/rpool/VARSHARE/pkg 63K 22.2G 32K /rpool/zone1/root/var/share/pkg
rpool/zone1/rpool/VARSHARE/pkg/repositories 31K 22.2G 31K /rpool/zone1/root/var/share/pkg/repositories
rpool/zone1/rpool/VARSHARE/sstore 1.12M 22.2G 1.12M /rpool/zone1/root/var/share/sstore/repo
rpool/zone1/rpool/VARSHARE/tmp 31K 22.2G 31K /rpool/zone1/root/var/tmp
rpool/zone1/rpool/export 63K 22.2G 32K /rpool/zone1/root/export
rpool/zone1/rpool/export/home 31K 22.2G 31K /rpool/zone1/root/export/home

2. Destroy zfs File system

If you want to delete already existed zfs file system, you need to use zfs destroy rpool/zone1 command.

Advertisements
root@localhost:~# zfs destroy rpool/zone1

3. List All ZFS File system

To check all the currently existed zfs file system in your node, you need to use zfs list command.

root@localhost:~# zfs list
NAME USED AVAIL REFER MOUNTPOINT
rpool 5.32G 23.7G 4.33M /rpool
rpool/ROOT 3.04G 23.7G 31K none
rpool/ROOT/solaris 3.04G 23.7G 2.66G /
rpool/ROOT/solaris/var 316M 23.7G 315M /var
rpool/VARSHARE 35.1M 23.7G 2.77M /var/share
rpool/VARSHARE/kvol 27.7M 23.7G 31K /var/share/kvol
rpool/VARSHARE/kvol/dump_summary 1.22M 23.7G 1.02M -
rpool/VARSHARE/kvol/ereports 10.2M 23.7G 10.0M -
rpool/VARSHARE/kvol/kernel_log 16.2M 23.7G 16.0M -
rpool/VARSHARE/pkg 63K 23.7G 32K /var/share/pkg
rpool/VARSHARE/pkg/repositories 31K 23.7G 31K /var/share/pkg/repositories
rpool/VARSHARE/sstore 4.50M 23.7G 4.50M /var/share/sstore/repo
rpool/VARSHARE/tmp 31K 23.7G 31K /var/tmp
rpool/VARSHARE/zones 31K 23.7G 31K /system/zones
rpool/dump 1.24G 23.7G 1.24G -
rpool/export 64K 23.7G 32K /export
rpool/export/home 32K 23.7G 32K /export/home
rpool/swap 1.00G 23.7G 1.00G -
rpool/zone1 31K 23.7G 31K /rpool/zone1

4. Create zpool

If you want to create zpool on c1d1s2 device, you need to use zpool create tpool c1d1s2 command. You can also verify the zpool created for zfs file system using zpool list command.

Advertisements
root@localhost:~# zpool create tpool c1d1s2
root@localhost:~# zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
rpool 29.5G 6.81G 22.7G 23% 1.00x ONLINE -
tpool 15.9G 164K 15.9G 0% 1.00x ONLINE -

5. Create ZFS Dataset

To create a zfs dataset, you need to use zfs create tpool/vol01 command. After creation, you can check the dataset by grepping from zfs list command.

root@localhost:~# zfs create tpool/vol01
root@localhost:~# zfs list | grep vol01
tpool/vol01 31K 15.6G 31K /tpool/vol01

6. Create ZFS Dataset under a dataset

Suppose you need to create a dataset under a dataset, then you need to use the same command as above but under root dataset path. Here we are creating vol02 dataset under vol01 dataset, so you need to use zfs create tpool/vol01/vol02 command. It can also be verified by querying the dataset name zfs list command.

Advertisements
root@localhost:~# zfs create tpool/vol01/vol02
root@localhost:~# zfs list | grep vol02
tpool/vol01/vol02

7. Enable ZFS dataset Sharing through sharenfs

If you want to enable zfs dataset sharing through sharenfs, you need to use zfs set sharefs=on tpool/vol01 command. You can check the sharenfs status by running zfs get sharenfs tpool/vol01 command.

root@localhost:~# zfs set sharenfs=on tpool/vol01
root@localhost:~# zfs get sharenfs tpool/vol01
NAME PROPERTY VALUE SOURCE
tpool/vol01 share.nfs on local

NOTE:

To find out the correct disk name that you attached to your node, run format command and select the disk. Then write p and enter. After that write print and enter. It will show you all the partition.Check the part number which shows maximum disk space. For eg:- If your disk name is c1d1 and your maximum space lies on part number 2, so your disk name will become c1d1s2.

8. Disable NFS Share of ZFS Dataset

To disable nfs share of ZFS dataset, you need to use zfs set sharenfs=off tpool/vol01 command.

root@localhost:~# zfs set sharenfs=off tpool/vol01
root@localhost:~# zfs get sharenfs tpool/vol01
NAME        PROPERTY  VALUE  SOURCE
tpool/vol01 share.nfs  off   local

9. Enable ZFS File System Compression

If you want to enable ZFS Compression, you need to use zfs set compression=on tpool/vol01 command. Once enabled, you can check the compression status by running zfs get compression tpool/vol01 command.

root@localhost:~# zfs set compression=on tpool/vol01
root@localhost:~# zfs get compression tpool/vol01
NAME        PROPERTY    VALUE SOURCE
tpool/vol01 compression  on   local

10. Enable gzip-9 compression

If you want to use gzip-9 compression, you can set it by using zfs set compression=gzip-9 tpool/vol01 command. Once enabled, you can check the compression value by using zfs get compression tpool/vol01 command.

root@localhost:~# zfs set compression=gzip-9 tpool/vol01
root@localhost:~# zfs get compression tpool/vol01
NAME         PROPERTY   VALUE  SOURCE
tpool/vol01 compression gzip-9 local

11. Disable Compression on ZFS Dataset

If you want to disable compression on ZFS Dataset, you need to use zfs set compression=off tpool/vol01 command.

root@localhost:~# zfs set compression=off tpool/vol01
root@localhost:~# zfs get compression tpool/vol01
NAME        PROPERTY    VALUE SOURCE
tpool/vol01 compression  off  local

12. Check Quota of ZFS Dataset

If you want to check the Quota of ZFS dataset, you need to use zfs get quota tpool/vol01 command.

root@localhost:~# zfs get quota tpool/vol01
NAME        PROPERTY VALUE SOURCE
tpool/vol01 quota    none  default

13. Enable Quota on ZFS Dataset

If you want to enable quota usage on tpool/vol01 dataset, you need to use zfs set quota=100M tpool/vol01 command.

root@localhost:~# zfs set quota=100M tpool/vol01
root@localhost:~# zfs get quota tpool/vol01
NAME        PROPERTY VALUE SOURCE
tpool/vol01 quota    100M  local

14. Disable Quota on ZFS Dataset

If you want to disable quota on tpool/vol01 dataset, then you to need to run zfs set quota=none tpool/vol01 command. You can verify the quota status by running zfs get quota tpool/vol01 command.

root@localhost:~# zfs set quota=none tpool/vol01
root@localhost:~# zfs get quota tpool/vol01
NAME        PROPERTY VALUE SOURCE
tpool/vol01 quota    none  local

15. Check tpool property value

To check autoreplace property of zpool tpool, you can use zpool get autoreplace tpool command.

root@localhost:~# zpool get autoreplace tpool
NAME  PROPERTY   VALUE SOURCE
tpool autoreplace off  default

16. Enable tpool property value

If you want to enable autoreplace property of tpool, you can use zpool set autoreplace=on tpool command.

root@localhost:~# zpool set autoreplace=on tpool
root@localhost:~# zpool get autoreplace tpool
NAME  PROPERTY   VALUE SOURCE
tpool autoreplace on   local

17. Disable tpool property value

If you want to disable tpool autoreplace property, you need to use zpool set autoreplace=off tpool command.

root@localhost:~# zpool set autoreplace=off tpool
root@localhost:~# zpool get autoreplace tpool
NAME  PROPERTY    VALUE SOURCE
tpool autoreplace  off  local

18. Check all zpool health status

If you want to check all available zpool health status, you need to use zpool status -x command.

root@localhost:~# zpool status -x
all pools are healthy

19. Create Snapshots for tpool/vol01

If you want to create snapshots for tpool, you need to use zfs snapshot tpool/vol01@bkp_vol01 command. It can be verified using zfs list -t snapshot tpool/vol01@bkp_vol01 command.

root@localhost:~# zfs snapshot tpool/vol01@bkp_vol01
root@localhost:~# zfs list -t snapshot tpool/vol01@bkp_vol01
NAME                 USED AVAIL REFER MOUNTPOINT
tpool/vol01@bkp_vol01 0     -    32K      -

20. ZFS List Snapshots

If you want to list all available zfs snapshots, you need to use zfs list -t snapshot command.

root@localhost:~# zfs list -t snapshot
NAME USED AVAIL REFER MOUNTPOINT
rpool/ROOT/solaris@install 71.6M - 2.55G -
rpool/ROOT/solaris/var@install 970K - 314M -
rpool/zone1/rpool/ROOT/solaris@install 10.1M - 776M -
rpool/zone1/rpool/ROOT/solaris/var@install 1.33M - 87.1M -
tpool/vol01@bkp_vol01 0 - 32K -

21. ZFS Delete Snapshot

If you want to delete zfs snapshot, you need to use zfs destroy tpool/vol01@bkp_vol01 command.

root@localhost:~# zfs destroy tpool/vol01@bkp_vol01
root@localhost:~# zfs list -t snapshot
NAME USED AVAIL REFER MOUNTPOINT
rpool/ROOT/solaris@install 71.6M - 2.55G -
rpool/ROOT/solaris/var@install 970K - 314M -
rpool/zone1/rpool/ROOT/solaris@install 10.1M - 776M -
rpool/zone1/rpool/ROOT/solaris/var@install 1.33M - 87.1M -

22. Check all ZFS Options

To check all the zfs options available, you need to use zfs help command.

root@localhost:~# zfs help
The following commands are supported:
allow clone create destroy diff get
groupspace help hold holds inherit key
list mount promote receive release rename
rollback send set share snapshot unallow
unmount unshare upgrade userspace
For more info, run: zfs help <command>

23. Share all ZFS File system

If you want to share all ZFS File system, then you need to use zfs share -a command.

root@localhost:~# zfs share -a

24. Unshare all ZFS Files ystem

To unmount all zfs filesystem, you need to use zfs unshare -a command.

root@localhost:~# zfs unshare -a

25. Mount all ZFS File system

To mount all zfs filesystems, you need to use zfs mount -a command.

root@localhost:~# zfs mount -a

26. Check reservation of ZFS dataset

If want to check reservation status on tpool/vol01 dataset, you need to run zfs get reservation tpool/vol01 command as shown below.

root@localhost:~# zfs get reservation tpool/vol01
NAME        PROPERTY    VALUE SOURCE
tpool/vol01 reservation none  default

NOTE:

A ZFS reservation is an allocation of disk space from the pool that is guaranteed to be available to a dataset. As such, you cannot reserve disk space for a dataset if that space is not currently available in the pool

27. Enable reservation of ZFS dataset

If you want to enable reservation on tpool/vol01, you need to use zfs set reservation=500M tpool/vol01 command. To check the reservation applied status, run zfs get reservation tpool/vol01 command.

root@localhost:~# zfs set reservation=500M tpool/vol01
root@localhost:~# zfs get reservation tpool/vol01
NAME PROPERTY VALUE SOURCE
tpool/vol01 reservation 500M local

28. Disable reservation on ZFS dataset

If you want to disable reservation of ZFS Dataset, you need to use zfs set reservation=none tpool/vol01 command.

root@localhost:~# zfs set reservation=none tpool/vol01
root@localhost:~# zfs get reservation tpool/vol01
NAME PROPERTY VALUE SOURCE
tpool/vol01 reservation none local

29. Check Data Integrity through zpool scrub

If you want to check the data integrity of tpool dataset, you need to use zpool scrub tpool command.

root@localhost:~# zpool scrub tpool

30. Check zpool scrub status 

If you want to check the status of data integrity checks, you need to use zpool status -v tpool command. This command will show you if any error occurred on data.

root@localhost:~# zpool status -v tpool
pool: tpool
state: ONLINE
scan: scrub repaired 0 in 1s with 0 errors on Thu Jan 9 18:56:21 2020

config:

NAME STATE READ WRITE CKSUM
tpool ONLINE 0 0 0
c1d1s2 ONLINE 0 0 0

errors: No known data errors

31. Stop ZFS Scrub

If you want to stop data integrity checks,then you need to use zpool scrub -s tpool command. Here there is no data integrity check running hence it is showing no active scrub.

root@localhost:~# zpool scrub -s tpool
cannot cancel scrubbing tpool: there is no active scrub

 

Popular Searches

  • zfs stop scrub
  • zfs options
  • zpool clear
  • zfs scrub
  • zpool scrub
  • zfs create dataset
  • zfs sharenfs
  • zfs share
  • zfs delete snapshot

Reference: Oracle ZFS Administration Guide

Also Read: Easy Methods to extend/shrink primary partition in Linux

Leave a Comment