pfSense Freebsd Increase Disk Partition Size
Jake G October 30, 2022 #pfSense #SysAdmin #Partitions #Filesystem #FreeBSDI recently increased the size of a disk for a pfSense proxmox VM, this outlines how.
Increasing the disk size in promox is simple
- Select the VM
- click Hardware
- click on the disk you want to increase
- click disk action
- select resize
- enter the amount of GiB you want to increase the disk size by.
To make use of the newly allocated space in the pfsense/freebsd VM here are the steps:
Disable and Delete Existing Swap Partition
Find the existing swap entry in /etc/fstab, then turn the swap off and delete the partition.
In this example my disks are identified by gptid, but the procedure is the same if it is by label.
cat /etc/fstab
/dev/gptid/ae09f6d0-b2dc-11ec-ac87-71ed21a342e4 / ufs rw,noatime 1 1
/dev/gptid/ae10d27b-b2dc-11ec-ac87-71ed21a342e4 none swap sw 0 0
swapoff /dev/gptid/ae10d27b-b2dc-11ec-ac87-71ed21a342e4
Find the correct swap partition and delete it. vtbd0 is the disk name and 3 is the partition index.
gpart show
=> 40 33554352 vtbd0 GPT (16G)
40 409600 1 efi (200M)
409640 31047680 2 freebsd-ufs (15G)
31457320 1677312 3 freebsd-swap (819M)
33134632 419760 - free - (205M)
gpart delete -i 3 vtbd0Resize root partition
My disk was 16gb in size and I increased it to 32gb. I will allocate 31gb to the root file system and leave the remaining 1gb for the swap.
gpart resize -i 2 -a 4k -s 31G vtbd0
growfs /
-i 2 (index partition 2) -a 4k (block size) -s 31G (size) vtbd0 (device)
Recreate Swap
This command will add a swap partition with a 4k block size to the vtbd0 disk device.
gpart add -t freebsd-swap -a 4k vtbd0
Now enable the swap, first identify the gptid of the swap, I use glabel list and find the gptid with the correct size (my new swap)
glabel list
swapon /dev/gptid/9ba77482-57dd-11ed-ae7c-d927ed59507a
Now correct /etc/fstab to remove the old swap entry and enter the new swap entry.
nano /etc/fstab
/dev/gptid/ae09f6d0-b2dc-11ec-ac87-71ed21a342e4 / ufs rw,noatime 1 1
/dev/gptid/9ba77482-57dd-11ed-ae7c-d927ed59507a none swap sw 0 0
After a reboot you should see the proper root file system and swap size in pfsense.