Solved [SOLVED] Resizing HD swap partition

Few days ago I installed FreeBSD 10.0-RELEASE in VirtualBox. I used the default disk layout: full disk 32 GB, swap space 2 GB. Now gpart info are

Code:
# gpart show
=>      34  67108797  ada0  GPT  (32G)
        34       128     1  freebsd-boot  (64K)
       162  62914432     2  freebsd-ufs  (30G)
  62914594   3354624     3  freebsd-swap  (1.6G)
  66269218    839613        - free -  (410M)

The swap partition size is 1.6 GB and there is about half of a GB free. I also see this behavior when changed my home server to a better hardware and installed FreeBSD 9.2-RELEASE on it, the same command on the server shows

Code:
# gpart show
=>       34  625142381  ada0  GPT  (298G)
         34          6        - free -  (3.0k)
         40        128     1  freebsd-boot  (64k)
        168  616562552     2  freebsd-ufs  (294G)
  616562720    8388608     3  freebsd-swap  (4.0G)
  624951328     191087        - free -  (93M)

there are 93 MB of free space. Back to the virtua machine I wish to resize the swap partition to use that 410 MB free space. What command I have to use? I guess it is # gpart resize, but I don't know with what parameters to call it. What index and geom parameters stand for? It's right to call it without specifying the size? Thank you
 
Re: Resizing HD swap partition

Use swapoff -a to disable swap. Then resize the partition: gpart resize -i3 ada0. Then turn swap back on with swapon -a.

"Index" is the number of the partition to work on, shown in the output above. "GEOM" is the disk device to work on.
 
Re: Resizing HD swap partition

Thank you, @wblock, perfectly done. My daily 'five seconds of fear'.
 
Last edited by a moderator:
Back
Top