ZFS Cheatsheet

Pools

List Pools

sudo zpool list  

Create a ZFS volume/pool on a single disk:

zpool create vol0 /dev/sd[x]  

Your pool will automatically be mounted at /[pool name].

Refer here for details of creating other pool types across multiple disks, such as RAID 1, 10, 5 etc.

Delete a Pool

zfs destroy [pool name]  

Check Disk Statuses

If you're running a redundant raid, you may want to check if any drives have failed once in a while. This is done by just checking the pools.

sudo zpool status  

Scrubbing

Scrub a pool

sudo zpool scrub [pool name]

To see the progress of a scrub use sudo zpool status

Datasets

Create a Dataset

sudo zfs create [pool name]/[dataset name]  

ZFS will automatically mount the dataset at /path/to/pool/[dataset name].

You can create a "descendent" dataset/filesystem like so:

sudo zfs create \  
[pool name]/[dataset name]/[descendent filesystem]

List Datasets and Pools

sudo zfs list  

Delete Dataset

sudo zfs destroy [pool name]/[dataset name]  

A dataset cannot be destroyed if snapshots or clones of the dataset exist.

Snapshots

Snapshot Datasets

zfs snapshot [pool]/[dataset name]@[snapshot name]  

List Snapshots

sudo zfs list -t snapshot  

Rename Snapshots

zfs rename [pool]/[dataset]@[old name] [new name]  

Restore Snapshot

zfs rollback -r [pool]/[dataset]@[snapshot name]  

This will delete all snapshots that were taken after [snapshot name] was taken!

The file system that you want to roll back is unmounted and remounted, if it is currently mounted. If the file system cannot be unmounted, the rollback fails. The -f option forces the file system to be unmounted, if necessary.

Delete a Snapshot

zfs destroy tank/home/cindys@snap1  

Clones

@TODO

Creating RAID Arrays

Refer to my post on creating ZFS Pools.

References

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus