HOWTO: Remove SWAP post-install and resize /
-
Hi all,
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
like this:
# 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...
Reboot...
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 ...Greets
Chris
-
Small remarks:
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/ada0s1aAfter that, my swap come part of / and usage decreased form 99 to 73 percent.
Big thanks for this great HOW-TO
-
Notes:
- 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.
-
Just the refreshment (based on this thread and on https://unix.stackexchange.com/questions/117023/expanding-the-disk-size-on-pfsense-under-vmware-esxi). pfSense is a Proxmox VM, virtual hard drive is virtio0.
[root@gw-2 ~]# swapoff -a swapoff: removing /dev/label/swap0 as swap device [root@gw-2 ~]# df -h / Filesystem Size Used Avail Capacity Mounted on /dev/ufsid/59d3a17dccecce22 2.9G 2.5G 180M 93% / [root@gw-2 ~]# gpart show => 63 8388545 vtbd0 MBR (4.0G) 63 8388513 1 freebsd [active] (4.0G) 8388576 32 - free - (16K) => 0 8388513 vtbd0s1 BSD (4.0G) 0 16 - free - (8.0K) 16 6291345 1 freebsd-ufs (3.0G) 6291361 2097152 2 freebsd-swap (1.0G)
After the virtual drive expansion (added 2G in the Proxmox interface):
[root@gw-2 ~]# gpart show => 63 12582849 vtbd0 MBR (6.0G) 63 8388513 1 freebsd [active] (4.0G) 8388576 4194336 - free - (2.0G) => 0 8388513 vtbd0s1 BSD (4.0G) 0 16 - free - (8.0K) 16 6291345 1 freebsd-ufs (3.0G) 6291361 2097152 2 freebsd-swap (1.0G) [root@gw-2 ~]# gpart resize -i 1 vtbd0 vtbd0s1 resized [root@gw-2 ~]# gpart show => 63 12582849 vtbd0 MBR (6.0G) 63 12582849 1 freebsd [active] (6.0G) => 0 12582849 vtbd0s1 BSD (6.0G) 0 16 - free - (8.0K) 16 6291345 1 freebsd-ufs (3.0G) 6291361 6291488 - free - (3.0G) [root@gw-2 ~]# gpart resize -i 1 -s 5GB vtbd0s1 vtbd0s1a resized [root@gw-2 ~]# gpart show => 63 12582849 vtbd0 MBR (6.0G) 63 12582849 1 freebsd [active] (6.0G) => 0 12582849 vtbd0s1 BSD (6.0G) 0 16 - free - (8.0K) 16 10485760 1 freebsd-ufs (5.0G) 10485776 2097073 - free - (1.0G) [root@gw-2 ~]# growfs /dev/ufsid/59d3a17dccecce22 Device is mounted read-write; resizing will result in temporary write suspension for /. It's strongly recommended to make a backup before growing the file system. OK to grow filesystem on /dev/ufsid/59d3a17dccecce22, mounted on /, from 3.0GB to 5.0GB? [yes/no] yes super-block backups (for fsck_ffs -b #) at: 6411392, 7693632, 8975872, 10258112 [root@gw-2 ~]# df -h / Filesystem Size Used Avail Capacity Mounted on /dev/ufsid/59d3a17dccecce22 4.8G 2.5G 1.9G 56% / [root@gw-2 ~]# gpart add -t freebsd-swap vtbd0s1 vtbd0s1b added [root@gw-2 ~]# /sbin/glabel label swap0 /dev/vtbd0s1b [root@gw-2 ~]# swapon -a swapon: adding /dev/label/swap0 as swap device
-
J jimp moved this topic from Problems Installing or Upgrading pfSense Software on