ZFS syntax (updated)
Introduction
ZFS is an alternative filesystem. It allows RAID, deduplication and compression.
You create a collection of drives as a 'pool'. That's useful if you want many drives as one big drive. Suppose you have two spare drives, sdc1 and sdd1. To make them into one big drive with deduplication and no compression, do this. Deduplication = where it doesn't make multiple copies of identical files, just marks them as copies.
Creating a ZFS pool (drive collection)
zpool create -f zfspool /dev/sdc1 /dev/sdd1
zfs set compression=off zfspool
zfs set dedup=on zfspool
zpool list
df -h
you'll see it is mounted as /zfspool
A zfs snapshot is a read-only copy of zfs file system or volume. They consume no extra space in the zfs pool and can be created instantly. They can be used to save a state of file system at particular point of time and can later be rolled back to exactly same state. LVM is similar to ZFS but doesn't offer all these other features. (In my experience, LVM is a bit more prone to complaining and giving weird failures BUT it performs better. Perhaps next time I should run it as a RAID rather than just a volume group. This experience of LVM performing better COULD be because I turned on compression and deduplication on my ZFS drive, which obviously is done on-the-fly and slows copying down).
How to mount a zfs pool on a different machine
Suppose you have another separate machine with linux on it and want to attach a zfs drive you made on another machine. Suppose on this new machine your primary drive is sda and therefore the attached zfs drive is going to be sdb. First check which drive it is using fdisk. Then run zpool import to get the name of the zfs pool. Then make its mountpoint. Then run zpool import with the -f flag. If that fails try -m as well.
# fdisk -l /dev/sdb
/dev/sdb1 63 3907029167 3907029105 1.8T 83 Linux
# zpool import
pool: zfspool
id: 12898311241760105065
state: ONLINE
status: Some supported features are not enabled on the pool.
(Note that they may be intentionally disabled if the
'compatibility' property is set.)
action: The pool can be imported using its name or numeric identifier, though
some features will not be available without an explicit 'zpool upgrade'.
config:
zfspool ONLINE
sdb1 ONLINE
# mkdir /zfspool
# zpool import zfspool
cannot import 'zfspool': pool was previously in use from another system.
Last accessed by <unknown> (hostid=0) at Mon Jul 24 09:17:48 2023
The pool can be imported, use 'zpool import -f' to import the pool.
# zpool import -f zfspool