I’m a fan of ZFS filesystem. It’s so good that I also use ZFS on most my Linux machines, though it’s painful at time when the ZFS kernel modules fail to compile. Why I like it so much comparing to other file system such as XFS, EXT4, BTRFS? ZFS allows me to quickly do snapshots and efficiently send snapshots over the network, and my nas runs FreeBSD which support ZFS natively.
Anyway, I’m going to show I can format an external drive and create ZFS filesystem on it.
[root@w ~]# udisksctl status
MODEL REVISION SERIAL DEVICE
--------------------------------------------------------------------------
...omitted for clarity...
ST2000DM Z4ZE 0062 67304734999999999999 sde
Upon connecting the drive to my Fedora 33 machine, it showed up as sde. And here is another confirmation. Notice the existing partitions (sde1, sde2,…, sde5) on this this.
[root@w ~]# dmesg | grep sd
...
[ 8816.437064] scsi 5:0:0:0: Direct-Access ST2000DM Z4ZE PQ: 0 ANSI: 2
[ 8816.437279] scsi 5:0:0:0: Attached scsi generic sg4 type 0
[ 8816.438217] sd 5:0:0:0: [sde] 3907029168 512-byte logical blocks: (2.00 TB/1.82 TiB)
[ 8816.438700] sd 5:0:0:0: [sde] Write Protect is off
[ 8816.438702] sd 5:0:0:0: [sde] Mode Sense: 1a 0c 00 00
[ 8816.439276] sd 5:0:0:0: [sde] No Caching mode page found
[ 8816.439277] sd 5:0:0:0: [sde] Assuming drive cache: write through
[ 8816.492838] sde: sde1 sde2 sde3 sde4 sde5
[ 8816.493900] sd 5:0:0:0: [sde] Attached SCSI disk
Now, let’s create a new ZFS pool called tank7 on this sde device.
[root@w ~]# zpool create tank7 /dev/sde
invalid vdev specification
use '-f' to override the following errors:
/dev/sde1 contains a filesystem of type 'ntfs'
So it failed to create a new zpool. Let’s force it!
[root@w ~]# zpool create -f tank7 /dev/sde
[root@w ~]# zpool status tank7
pool: tank7
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
tank7 ONLINE 0 0 0
sde ONLINE 0 0 0
errors: No known data errors
I’m going to enable compression on the new pool too.
[root@w ~]# zfs set compression=lz4 tank7
[root@w ~]# zfs get compression tank7
NAME PROPERTY VALUE SOURCE
tank7 compression lz4 local
Before this external drive is removed from the machine, make sure to export this pool first.
[root@w ~]# zpool export tank7
[root@w ~]# zpool status tank7
cannot open 'tank7': no such pool
Likewise, before the pool (tank7) can be used, I also need to re-import the pool every time. We don’t have to remember the pool name. We can run zpool import to list available zpool.
[root@w ~]# zpool import
pool: tank7
id: 14730787628652357370
state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:
tank7 ONLINE
sde ONLINE
[root@w ~]# zpool import tank7
[root@w ~]# zpool status tank7
pool: tank7
state: ONLINE
scan: resilvered 60K in 0 days 00:00:00 with 0 errors on Thu Nov 12 23:37:48 2020
config:
NAME STATE READ WRITE CKSUM
tank7 ONLINE 0 0 0
sde ONLINE 0 0 0
errors: No known data errors
Read more:
- ZFS basics: enable or disable compression - good read about ZFS compression