I 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.
- swapoff the device :
- delete the swap partition :
gpart delete -i 3 vtbd0
- resize the freebsd-ufs partition :
gpart resize -i 2 -a 4k -s 156G vtbd0
- create the swap :
gpart add -t freebsd-swap -a 4k vtbd0
- swapon :
- tell UFS to resize :
If freebsd-ufs was the latest in the gpart order, only steps 3 and 6 would have been necessary.