Resize live UFS filesystem on FreeBSD 11

NILI am using FreeBSD in virtual machines and sometimes I need to

increase the disk capacity of the storage. From your VM Host, increase

the capacity of the storage backend, then on the FreeBSD system (10.3

when writing), you should see this in the last line of dmesg.

GEOM_PART: vtbd0 was automatically resized.

  Use `gpart commit vtbd0` to save changes or `gpart undo vtbd0` to revert them.

Here is the gpart show output on the system:

>       34  335544253  vtbd0  GPT  (160G)

        34       1024      1  freebsd-boot  (512K)

      1058  159382528      2  freebsd-ufs  (76G)

 159383586    8388540      3  freebsd-swap  (4.0G)

 167772126  167772161         - free -  (80G)

The process is a bit harder here because I have my partition swap at

the end of the storage, so if I want to increase the size of the ufs

partition, I will need to remove the swap partition, increase the data

partition and recreate the swap. This is not that hard but having the

freebsd-ufs partition at the end would have been easier.

  1. swapoff the device : swapoff /dev/vtbd0p3

  1. delete the swap partition : gpart delete -i 3 vtbd0

  1. resize the freebsd-ufs partition : gpart resize -i 2 -a 4k -s 156G vtbd0

  1. create the swap : gpart add -t freebsd-swap -a 4k vtbd0

  1. swapon : swapon /dev/vtbd0p3

  1. tell UFS to resize : growfs /

If freebsd-ufs was the latest in the gpart order, only steps 3 and 6

would have been necessary.

Sources: FreeBSD Handbook and gpart(8)

Proxy Information
Original URL
gemini://perso.pw/blog//articles/10.gmi
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
132.831559 milliseconds
Gemini-to-HTML Time
0.575227 milliseconds

This content has been proxied by September (ba2dc).