I have a FreeBSD server which used to run of a smaller SSD drive. When replaced with a larger capacity SSD by using dd command to clone the disk, there is free space allocated. I want to extend the existing zroot pool to use this space. The following describes how I achieve this with the help of a forum post.

Let’s list some information about the zroot pool:

root@nas:~ # zfs list zroot
NAME    USED  AVAIL  REFER  MOUNTPOINT
zroot  4.88G  50.8G   144K  none

List the partition scheme of the drive I’d like to extend my zroot zpool with:

root@nas:~ # gpart show
=>       34  488397101  ada4  GPT  (233G)
         34       1024     1  freebsd-boot  (512K)
       1058    4194304     2  freebsd-swap  (2.0G)
    4195362  120850029     3  freebsd-zfs  (58G)
  125045391  363351744        - free -  (173G)

The first step is to resize the partition (I think it’ss called slice in FreeBSD term or something):

root@nas:~ # gpart resize -i3 /dev/ada4
ada4p3 resized       

root@nas:~ # gpart show
=>       34  488397101  ada4  GPT  (233G)
         34       1024     1  freebsd-boot  (512K)
       1058    4194304     2  freebsd-swap  (2.0G)
    4195362  484201766     3  freebsd-zfs  (231G)
  488397128          7        - free -  (3.5K)
  • -i3: index #3 in the partition table

Next check to ensure that the autoexpand property of the pool is set to on. If not then set it using zpool set autoexpand=on zfspoolname:

root@nas:~ # zpool get autoexpand zroot
NAME   PROPERTY    VALUE   SOURCE
zroot  autoexpand  on      local

My zroot pool’s autoexpand property has already been set to “on”;. Next I’m ready to expand my zpool. I should have mentioned that the device named I used for my zpool is /dev/gpt/zfs0. If it were something different, e.g. ada4p3, then adjust it accordingly:

root@nas:~ # zpool online -e zroot /dev/gpt/zfs0
root@nas:~ # zfs list zroot
NAME    USED  AVAIL  REFER  MOUNTPOINT
zroot  4.88G   218G   144K  none

That’s it.

Ref: https://forums.freebsd.org/threads/extend-zfs-partition.55964/