Increase size of swap file?

I have a 2GB swap file. Something tells me I want it bigger. How do I just increase the size? I don’t want a second swap file which I know is equivalent to the same thing, I just want a bigger one. Where is the swap file? I’m running version 8.8.

Show current swap and memory usage:

swapon -v
free -h

The default installation does allocate a separate partition (not a file) for swap. The partition is probably LVM LV, so it could be resized, if the VG has free extents.

However, it should be totally fine to create additional swap files (or partitions).

IME, if system has to resort to swap extensively, then something is already wrong – or at least will be terribly slow.

Check out:

With with AL 8.x

Scroll down to “Removing a Swap File”

2GB swap if fine for most applications. Just monitor the memory usage and swap size and make sure you get an alert if the usage unusually high. When that happens you probably have a software that needs more RAM so you increase the RAM, not the swap.

I’ve made it several times. Swap files on my servers are located on /, so all I have to do is:

  1. make sure that I have RAM sufficient to temporarily shutdown swap (stop services and applications if you don’t have)

  2. turn swap off

  3. delete swap file

  4. create a new swap file with the same name as previous (you don’t need to edit fstab if you use the same name.) I use dd command to do it .

  5. turn swap on.

are swaps sometimes partitions? see mine is a “block special”.

main(/etc): cat fstab
/dev/mapper/almalinux-root      /       xfs     defaults,uquota 0       0
UUID=e1a12e98-0061-4707-92b3-08f2a300d72b /boot                   xfs     defaults        0 0
/dev/mapper/almalinux-home      /home   xfs     defaults,uquota 0       0
/dev/mapper/almalinux-swap none                    swap    defaults        0 0
/usr/tmpDSK             /tmp                    ext3    defaults,noauto        0 0
main(/etc): file /dev/mapper/almalinux-swap
/dev/mapper/almalinux-swap: symbolic link to ../dm-1
main(/etc): file /dev/dm-1
/dev/dm-1: block special (253/1)

Yes, it’s actually pretty common for swap to be in its own partition. See jlehtone’s earlier answer.