Getting Started with ZFS in Ubuntu 20.04
ZFS in Ubuntu 20.04
I upgraded one of the smallest servers at home office to Ubuntu 20.04 recently and realised that ZFS support has been added to Ubuntu for quite some time - so maybe I should explore it more. I actually quite miss ZFS from my Sun Microsystems days.
Loading ZFS modules in Linux
Most likely you don’t have the ZFS modules loaded by default:
greys@server:~ $ lsmod | grep zfs
… meaning you need to probe ZFS modules to activate this functionality:
greys@server:~ $ sudo modprobe zfs
As you can see, there’s quite a few modules are loaded now:
greys@server:~ $ lsmod | grep zfs
zfs 4030464 0
zunicode 331776 1 zfs
zavl 16384 1 zfs
icp 286720 1 zfs
zcommon 90112 2 zfs,icp
znvpair 81920 2 zfs,zcommon
spl 126976 5 zfs,icp,znvpair,zcommon,zavl
zlua 147456 1 zfs
Installing ZFS utils in Ubuntu
Alright, next step is installing tools that provide all these z-commands for managing ZFS:
# apt-get install zfsutils
Creating ZFS pool from virtual disks
First, I’ll need a few virtual disks:
# fallocate -l 512M /vdisks/disk1.img
# fallocate -l 512M /vdisks/disk2.img
# fallocate -l 512M /vdisks/disk3.img
# fallocate -l 512M /vdisks/disk4.img
Nice! Now let’s create a ZFS pool (it’s like a RAID array if you’re familiar with mdadm):
zpool create -f newvol raidz /vdisks/disk1.img /vdisks/disk2.img /vdisks/disk3.img /vdisks/disk4.img
Confirm ZFS pool status in Ubuntu
Show ZFS pools: zpool list
Here it is: my newly created ZFS pool called newvol:
# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
newvol 1.88G 212K 1.87G - - 0% 0% 1.00x ONLINE -
Show ZFS pool status and member disks
Let’s get a bit more information about the pool - for instance, confirm which disks are in it:
# zpool status
pool: newvol
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
newvol ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
/vdisks/disk1.img ONLINE 0 0 0
/vdisks/disk2.img ONLINE 0 0 0
/vdisks/disk3.img ONLINE 0 0 0
/vdisks/disk4.img ONLINE 0 0 0
errors: No known data errors
I’m quite happy! Will be cool to use ZFS and snapshots for home directory on this box.
See Also
ZFS in Ubuntu 20.04
I upgraded one of the smallest servers at home office to Ubuntu 20.04 recently and realised that ZFS support has been added to Ubuntu for quite some time - so maybe I should explore it more. I actually quite miss ZFS from my Sun Microsystems days.
Loading ZFS modules in Linux
Most likely you don’t have the ZFS modules loaded by default:
greys@server:~ $ lsmod | grep zfs
… meaning you need to probe ZFS modules to activate this functionality:
greys@server:~ $ sudo modprobe zfs
As you can see, there’s quite a few modules are loaded now:
greys@server:~ $ lsmod | grep zfs
zfs 4030464 0
zunicode 331776 1 zfs
zavl 16384 1 zfs
icp 286720 1 zfs
zcommon 90112 2 zfs,icp
znvpair 81920 2 zfs,zcommon
spl 126976 5 zfs,icp,znvpair,zcommon,zavl
zlua 147456 1 zfs
Installing ZFS utils in Ubuntu
Alright, next step is installing tools that provide all these z-commands for managing ZFS:
# apt-get install zfsutils
Creating ZFS pool from virtual disks
First, I’ll need a few virtual disks:
# fallocate -l 512M /vdisks/disk1.img
# fallocate -l 512M /vdisks/disk2.img
# fallocate -l 512M /vdisks/disk3.img
# fallocate -l 512M /vdisks/disk4.img
Nice! Now let’s create a ZFS pool (it’s like a RAID array if you’re familiar with mdadm):
zpool create -f newvol raidz /vdisks/disk1.img /vdisks/disk2.img /vdisks/disk3.img /vdisks/disk4.img
Confirm ZFS pool status in Ubuntu
Show ZFS pools: zpool list
Here it is: my newly created ZFS pool called newvol:
# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
newvol 1.88G 212K 1.87G - - 0% 0% 1.00x ONLINE -
Show ZFS pool status and member disks
Let’s get a bit more information about the pool - for instance, confirm which disks are in it:
# zpool status
pool: newvol
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
newvol ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
/vdisks/disk1.img ONLINE 0 0 0
/vdisks/disk2.img ONLINE 0 0 0
/vdisks/disk3.img ONLINE 0 0 0
/vdisks/disk4.img ONLINE 0 0 0
errors: No known data errors
I’m quite happy! Will be cool to use ZFS and snapshots for home directory on this box.