How to resize a FreeBSD partition
After upgrading your service you might need to expand an existing partition to take advantage of additional disk space. Below is a practical step-by-step guide to resizing a FreeBSD partition and expanding a ZFS pool.
1. Identify the Disk and Partition
Start by listing all disks and partitions using gpart
:
gpart show
This will display something like:
=> 40 104857520 da0 GPT (50G)
40 1024 1 freebsd-boot (512K)
1064 2097152 2 freebsd-swap (1.0G)
2098216 102400000 5 freebsd-zfs (48G)
- Disk name:
da0
- Partition to resize:
da0p5
(index5
)
2. Recover Partition Table (If Needed)
Sometimes gpart show
may display [CORRUPT]
next to your disk after resizing it in the hypervisor. To fix this, run:
gpart recover da0
This will rebuild the partition table so the system recognizes the full disk size.
3. Resize the Partition
Next, resize the partition itself. Use the partition index you identified earlier (-i 5
in this example):
gpart resize -i 5 da0
This command expands partition 5 on disk da0 to fill the available space.
4. Expand the ZFS Pool
Even though the partition is larger, ZFS won’t automatically use the new space. Tell ZFS to expand the pool:
zpool online -e zroot da0p5
zroot
is the name of the ZFS pool.da0p5
is the resized partition.
After this, your ZFS pool should immediately reflect the additional storage.
5. Verify the Expansion
Finally, check that the pool size has increased:
zpool list
You should now see the new, larger capacity available.
Summary
To resize a FreeBSD partition and expand a ZFS pool:
- Identify the disk and partition:
gpart show
- Recover partition table if needed:
gpart recover da0
- Resize the partition:
gpart resize -i 5 da0
- Expand the ZFS pool:
zpool online -e zroot da0p5
- Verify the results:
zpool list
This process is quick, safe, and requires no reboot in most cases.
Updated on: 11/09/2025
Thank you!