Increase ZFS Pool Size

Hello,

I'm running a FreeBSD 12 VM with ZFS and GELI disk encryption. As I was running out of space, I've tried to increase the virtual disk.

To do so, I've shut down the VM and increased the virtual disk. After I've increased the virtual disk, I booted the system into single user mode and increased the partition size with # gpart resize -i 4 da0. # gpart show showed me the bigger partition.
After that, I've tried to increase the ZFS pool size with # zpool set autoexpand=on zroot, but it did not work. After a reboot, I was not able to mount the zroot pool.

Obviously I did something wrong. What would be correct procedure to increase the size of a zfs partition?
 
You have a GELI layer sitting between ZFS and the disk. You resized the partition, now you have to tell GELI to resize the encrypted volume too. This is in the man page geli(8):
geli resize [-v] -s oldsize prov

So, you have to call geli resize and enter the old size and GELI will relocate the metadata where needed.
When you do that, you can expand the ZFS pool manually, if it did not do it automatically already:
Bash:
zpool online -e zroot da0p4
 
You could also expand a disk without a downtime (thanks to the wonderful file system ZFS!)
What you do is:
  1. Create a new virtual disk image with bigger size.
  2. Attach the new disk to the VM while it's running. I use QEMU and this can be done with virtual disk of type SCSI VirtIO and a SCSI VirtIO controller.
  3. Inside the VM partition the new disk appropriately (you can just copy the partitioning of the original disk but the root is larger).
  4. Copy the boot code with gpart bootcode or dd from the original boot partition.
  5. Attach the new partition to the zroot pool in a mirror.
  6. After resilvering, detach the old disk.
  7. Expand the pool with zpool online -e zroot da1p4.
 
Back
Top