# Increase ZFS Pool Size



## KthorLasshar (Oct 5, 2019)

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?


----------



## D-FENS (Oct 5, 2019)

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:

```
zpool online -e zroot da0p4
```


----------



## D-FENS (Oct 5, 2019)

You could also expand a disk without a downtime (thanks to the wonderful file system ZFS!)
What you do is:

Create a new virtual disk image with bigger size.
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.
Inside the VM partition the new disk appropriately (you can just copy the partitioning of the original disk but the root is larger).
Copy the boot code with `gpart bootcode` or dd from the original boot partition.
Attach the new partition to the zroot pool in a mirror.
After resilvering, detach the old disk.
Expand the pool with `zpool online -e zroot da1p4`.


----------



## KthorLasshar (Oct 7, 2019)

Thanks for the hint regarding geli. 
I've found by the way this article on how to grow a geli encrypted zfs pool. Worked very well. https://stderr.at/blog/freebsd/2015/09/20/freebsd-geli-resize/


----------



## D-FENS (Oct 8, 2019)

Yes, they do the same thing - use `geli resize`. Glad that it worked!


----------

