HOWTO: Remove SWAP post-install and resize /
chuchuchu last edited by
I managed to install 2.3.2 on a 1GB Compactflash.
Due to the ammount of RAM in the system, the SWAP partition is not needed.
For those of you who forgot to disable SWAP during setup or moved to SSD later or for what ever reason this should be handy …
get ssh and connect to box / or via console
STEP ONE: Get your disk info:
/root: gpart show ada0 => 63 1989729 ada0 MBR (972M) 63 1989729 1 freebsd [active] (972M)
my cf card is rec. as the only IDE dev so ada0
in slice 1 of the UFS we can find the / of pfSense:
/root: gpart show ada0s1 => 0 1989729 ada0s1 BSD (972M) 0 16 - free - (8.0K) 16 1989713 1 freebsd-ufs (972M) 1234 5678 2 swap~ (123MB)
/root: df -h Filesystem Size Used Avail Capacity Mounted on /dev/ada0s1a 937M 593M 268M 69% / devfs 1.0K 1.0K 0B 100% /dev /dev/md0 3.4M 112K 3.0M 3% /var/run devfs 1.0K 1.0K 0B 100% /var/dhcpd/dev
see that / has the same size as slice 1 :
63 1989729 1 freebsd [active] (972M) /dev/ada0s1a 937M 593M 268M 69% /
STEP TWO: ok … so we need to disable swap ...
(i know we can do by swapof but i think this is fine either... )
/root: edit /etc/fstab
in fstab comment the line with ~swap~ by adding a # at the beginning
# Device Mountpoint FStype Options Dump Pass# /dev/ada0s1a / ufs rw 1 1 #/dev/label/swap0 none swap sw 0 0
note that in pfSense default fstab the / partition is mounted by ufsid
… better change that now to ada0s1 or where ever your / partition is hanging around ...
otherwise later after resizing of the slize the ufsid changes and pfSense will hang in boot...
After reboot u can see that there is no swap in top:
/root:top last pid: 61459; load averages: 0.00, 0.05, 0.12 up 0+00:38:53 02:17:44 43 processes: 1 running, 42 sleeping CPU: 0.0% user, 0.0% nice, 1.2% system, 2.0% interrupt, 96.9% idle Mem: 45M Active, 36M Inact, 54M Wired, 43M Buf, 8228M Free Swap:
STEP THREE: ok so now let's delete the SWAP partition…
/root: gpart delete ada0s1b ---bla bla deleted...
it is ada0s1b because it is the second sub(is that the correct word ?) in slice 1 in ada0:
=> 0 1989729 ada0s1 BSD (972M) 0 16 - free - (8.0K) 16 1989713 1 freebsd-ufs (972M) 1234 5678 2 swap~ (123MB)
after that we can resize the /
we wanna resize to maximum capacity so we dont need -s param. Otherwise u could specify the final size by eg. -s 4GB
-i is index of / … so in our example 1
/root: gpart resize -i 1 (-s 4GB) ada0s1
after that we can resize our filesystem by doing:
growfs /dev/ada0s1 yes bla bla warning bla bla... done...
now you have the new filesystem size….
you can show it in dashboard or in # by
/root: df -h
please feel free to leave a comment if sth is wrong or u know it better …
also if you have any questions or sth. ...
Sorry 4 my english... it's my second language ...
hAh0L13 last edited by
1. fstab now using ufsid addressing, so instead of /dev/ada0s1a I see /dev/ufsid/blablabla. Replace it with correct string - /dev/ada0s1a cause successful boot.
2. gpart delete ada0s1b return "Option 'i' not specified", so I need to gpart show and make this coomand - gpart delete -i 2 /dev/ada0s1
3. Command growfs /dev/ada0s1 return "superblock not recognized", so I replace command with growfs /dev/ada0s1a
After that, my swap come part of / and usage decreased form 99 to 73 percent.
Big thanks for this great HOW-TO
doktornotor Banned last edited by
- You could (and probably should) use /usr/local/sbin/ufslabels.sh to switch /etc/fstab to using the labels again after you are done.
- Using /etc/rc.d/growfs from single user mode would probably take care of everything once you've nuked the swap partition.