Expanding ZFS pool online
Published in linux.
At work I’m setting up a new syslog server and wanted the logs to be stored raw on disk (that is not compressed using gzip). To do that I created a ZFS pool with compression enabled allowing for transparent compression.
First I created a zpool with a single disk (this is a VM so no redundancy is needed):
# Create a pool with the name 'zlog' zpool create zlog /dev/sdb # Enable compression zfs set compression=on zlog # Set the mountpoint mkdir /logs zfs set mountpoint=/logs logpool
This results in a mounted zfs volume:
root@zfs-test:/logs# zpool list NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT zlog 19.5G 552K 19.5G - - 0% 0% 1.00x ONLINE -
This is fine but I need to be able to expand the pool on the fly.
I expanded the disk in the hypervisor from 20GB to 25GB.
Trigger a rescan so Linux detects the disk size change:
echo 1 > /sys/block/sdb/device/rescan
Extend the zpool with
zpool online -e zlog sdb
And the pool shows the updated size:
root@zfs-test:/logs# zpool list NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT zlog 24.5G 684K 24.5G - - 0% 0% 1.00x ONLINE -
It is possible to autoexpand the pool using
# At pool creation zpool create -o autoexpand=on zlog /dev/sdb # or later with zfs set compression=on zlog
However you always need to either reboot the server or trigger a device rescan for the autoexpand to trigger.