lsblk -S # General Linux command
geom disk list # FreeNAS specific
zpool list
zpool clear
zpool create -f files /dev/sdb /dev/sdc /dev/sdd
Optional Parameters
- -m mountpoint
Sets the mount point for the root dataset. The default is/pool
oraltroot/pool
if altroot is specified. The mount point must be an absolute path, legacy, or none.
For more information, see thezfs(8)
man page.
zpool create files mirror /dev/sda /dev/sdb
Note: Use
raidz
instead ofmirror
for RAID 5 setups.
zfs set mountpoint=$NEWPATH $POOL
zpool destroy $POOL
ZFS file systems live 'inside' pools. By default, they are mounted under the parent pool.
For example:
zfs get mountpoint big
NAME PROPERTY VALUE SOURCE
big mountpoint /var/lib/snapd/hostfs/big local
To create a filesystem:
zfs create big/docker # docker is a filesystem inside the pool named big
zfs get mountpoint big/docker
NAME PROPERTY VALUE SOURCE
big/docker mountpoint /var/lib/snapd/hostfs/big/docker inherited from big
As you can see, big
is mounted in /var/lib/snapd/hostfs/big
, and big/docker
is mounted in /var/lib/snapd/hostfs/big/docker
.
zfs set mountpoint=/var/lib/docker big/docker
zfs get mountpoint big/docker
zfs list
shows all file systemszfs list -r small
shows all file systems undersmall
zfs list -t snapshot
shows all snapshots
Snapshots capture a point in time of a file system. Snapshots can't be accessed directly, but you can clone them, back them up, and roll back to them.
zfs snapshot big/test@demo
List snapshots:
zfs list -t snapshot
Example output:
NAME USED AVAIL REFER MOUNTPOINT
big/test@demo 0B - 96K -
After making changes (e.g., creating a file):
touch /home/user/test/afile.txt
ls /home/user/test/
afile.txt
Rollback to the snapshot:
zfs rollback big/test@demo
ls /home/user/test/
<nothing is shown>
You can make a copy of a snapshot into a new filesystem.
Here we take the snapshot big/test@demo
and create a new ZFS filesystem big/demobackup
from it:
zfs clone big/test@demo big/demobackup
Note: Snapshots used to create cloned file systems can't be deleted until the cloned file system is destroyed.
You can also send your snapshot to another machine.
Here we're sending the big/test@demo
snapshot to othermachine
into the backup/test
filesystem:
zfs send big/test@demo | ssh othermachine zfs recv backup/test
The receiving machine (othermachine
) must have ZFS installed.