Skip to content

Expanding a ZFS filesystem on LUKS/md-raid

I run my backups on a stack that consists of:

  1. md-raid mirror
  2. LUKS encryption
  3. ZFS zvol

This works nicely as it’s easy to split off an encrypted backup disk to take offsite, but since ZFS encryption hasn’t come to Linux yet, it’s still a stack of technologies to manage.  My backup set gets ever larger, so to expand the backups capacity, I bought a pair of Hitachi 3TB SATA drives.  Assuming:

  • the old drives were sdc and sdd
  • the new drives are sde and sdf
  • the md mirror is md3
  • the LUKS volume is called backup and presents as dm-0
  • the zfs pool is called ‘backup’

to expand the stack:

  1. mdadm –add /dev/md3 /dev/sde
  2. mdadm –fail /dev/md3 /dev/sdc
  3. mdadm –remove /dev/md3 /dev/sdc
  4. wait for rebuild to finish (cat /proc/mdstat)
  5. mdadm –add /dev/md3 /dev/sdf
  6. mdadm –fail /dev/md3 /dev/sdd
  7. mdadm –remove /dev/md3 /dev/sdd
  8. wait for rebuilt to finish
  9. mdadm –grow –size=max /dev/md3
  10. cryptsetup resize backup
  11. zpool online -e backup dm-0

and then run ‘zfs list’ to ensure the size is updated.  Conveniently, this can all be done without taking any of the filesystems offline.