Increase disk size for Pfsense on Vmware
This was done on the Pfsense 2.4.5.
Check disk size:
[2.4.5-RELEASE][root@server1]/root: gpart show
=> 63 104857537 da0 MBR (50G)
63 1 - free - (512B)
64 104857535 1 freebsd [active] (50G)
104857599 1 - free - (512B)
=> 0 104857535 da0s1 BSD (50G)
0 98566144 1 freebsd-ufs (47G)
98566144 5242880 2 freebsd-swap (2.5G)
103809024 1048511 - free - (512M)
On vmware increase the disk size of the Virtual Machine. I did this with the VM powered down.
Power on the Pfsense machine.
Check disk size again:
[2.4.5-RELEASE][root@server1]/root: gpart show
=> 63 629145537 da0 MBR (300G)
63 1 - free - (512B)
64 104857535 1 freebsd [active] (50G)
104857599 524288001 - free - (250G)
=> 0 104857535 da0s1 BSD (50G)
0 98566144 1 freebsd-ufs (47G)
98566144 5242880 2 freebsd-swap (2.5G)
103809024 1048511 - free - (512M)
[2.4.5-RELEASE][root@server1]/root:
As you can see, the system can see the new disk size.
As you can see we have free disk space, but for increase the root partition, we will need disable the swap, remove the swap partition and increase.
Swap will be increased again, you can use this oportunity to increase or decrease swap space if you want.
Disable the swap with swappof command like below:
[2.4.5-RELEASE][root@server1]/root: swapoff -a
swapoff: removing /dev/label/swap0 as swap device
[2.4.5-RELEASE][root@server1]/root: gpart show
=> 63 629145537 da0 MBR (300G)
63 1 - free - (512B)
64 629145536 1 freebsd [active] (300G)
=> 0 629145536 da0s1 BSD (300G)
0 98566144 1 freebsd-ufs (47G)
98566144 5242880 2 freebsd-swap (2.5G)
103809024 525336512 - free - (250G)
Now delete the swap partition, the -i parameter is for the partition number
[2.4.5-RELEASE][root@server1]/root: gpart delete -i 2 da0s1
da0s1b deleted
Check disk space again, as you can see, only the root partition on the disk now:
[2.4.5-RELEASE][root@server1]/root: gpart show
=> 63 629145537 da0 MBR (300G)
63 1 - free - (512B)
64 629145536 1 freebsd [active] (300G)
=> 0 629145536 da0s1 BSD (300G)
0 98566144 1 freebsd-ufs (47G)
98566144 530579392 - free - (253G)
[2.4.5-RELEASE][root@server1]/root:
Now extend the root partition, the parameter of size will be the final size of the partition, on my case I leave 10G free to be used by the swap:
#The math below is: old size root + free size - swap size
[2.4.5-RELEASE][root@server1]/root: gpart resize -i 1 -s 290G da0s1
da0s1a resized
Check again disk space and you see that the root partition was increased without downtime:
[2.4.5-RELEASE][root@server1]/root: gpart show
=> 63 629145537 da0 MBR (300G)
63 1 - free - (512B)
64 629145536 1 freebsd [active] (300G)
=> 0 629145536 da0s1 BSD (300G)
0 608174080 1 freebsd-ufs (290G)
608174080 20971456 - free - (10G)
[2.4.5-RELEASE][root@server1]/root
Now, recreate the swap partition, the command below will create and use the free space available, da0s1 is the disk name:
[2.4.5-RELEASE][root@server1]/root: gpart add -t freebsd-swap -a 4k da0s1
da0s1b added
[2.4.5-RELEASE][root@server1]/root: gpart show
=> 63 629145537 da0 MBR (300G)
63 1 - free - (512B)
64 629145536 1 freebsd [active] (300G)
=> 0 629145536 da0s1 BSD (300G)
0 608174080 1 freebsd-ufs (290G)
608174080 20971456 2 freebsd-swap (10G)
Before activate the swap, you need check /etc/fstab, on my case, as I recreated the device, the name changed, so I changed as well on the fstab, the previous fstab was:
[2.4.5-RELEASE][root@server1]/root: cat /etc/fstab
/dev/ufsid/5f64f3dc9fb6febe / ufs rw 1 1
/dev/label/swap0 none swap sw 0 0
As I dont have the /dev/label/swap0 I used the new device that was showed during the swap creation:
[2.4.5-RELEASE][root@server1]/root: vi /etc/fstab
/dev/ufsid/5f64f3dc9fb6febe / ufs rw 1 1
/dev/da0s1b none swap sw 0 0
After that I issued:
swapon -a
Check swap with swapinfo
And for last, you need increase the filesystem / with:
growfs /
After that space will be ok:
[2.4.5-RELEASE][root@server1]/root: df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/ufsid/5f64f3dc9fb6febe 281G 1.8G 257G 1% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/md0 3.4M 136K 3.0M 4% /var/run
devfs 1.0K 1.0K 0B 100% /var/dhcpd/dev
[2.4.5-RELEASE][root@server1]/root: swa
swanctl swapctl swapinfo swapoff swapon
[2.4.5-RELEASE][root@server1]/root: swap
swapctl swapinfo swapoff swapon
[2.4.5-RELEASE][root@server1]/root: swapinfo
Device 1K-blocks Used Avail Capacity
/dev/da0s1b 10485728 0 10485728 0%
[2.4.5-RELEASE][root@server1]/root: gpart show
=> 63 629145537 da0 MBR (300G)
63 1 - free - (512B)
64 629145536 1 freebsd [active] (300G)
=> 0 629145536 da0s1 BSD (300G)
0 608174080 1 freebsd-ufs (290G)
608174080 20971456 2 freebsd-swap (10G)
Comentários
Postar um comentário