Resize disk in FreeBSD

Resizing the disk in FreeBSD consists of three steps:

  1. Add more physical or virtual disk space
  2. Resize the partition
  3. Resize the filesystem

Add more disk space

It is more common to resize a VM, therefore, this tutorial has a focus on such. Adding more disk space start with assiging more space via the hardware section of the hypervisor. Simple resize the virtual disk, that the hypervisor provides. This can be done when the VM is powered off, as well as when it is powered on.

Resize the partition

Resizing the partition is done with the gpart command. In this example we want to grow the partition 3 (freebsd-ufs) of the disk ada0.

gpart show # shows all partitions and its size
# possible result
#=>      40  16777136  ada0  GPT  (8.0G)
#        40    532480     1  efi  (260M)
#    532520      1024     2  freebsd-boot  (512K)
#    533544  16243632     3  freebsd-ufs  (7.7G)
ada0 represents the disk, while the numbers (1,2,3) below represent the partitions on the disk.
gpart recover ada0 # recovers the newly assigned space to the disk and its partition scheme.
gpart modify -i 3 ada0 # resize partition 3 of disk ada0 and assign all available space to it
gpart show # check space assignment again to validate

Resize the filesystem

The last step is to resize the filesystem.

growfs /dev/gpt/rootfs # resize the filesystem to use all available space on partition

Previous Blog Entry


Last update: 2025-05-09