How to increase swap size?

Solution 1:

You decided to create a separate swap partition upon installation. You can't resize it online - even an offline resize is going to take a considerable amount of time and bear the potential risk of damaging your subsequent filesystem on /dev/sdc2.

The easiest option to work around this is to either create a new swap partition on a different disk you don't currently use (or can afford to offline for re-partitioning) or simply use a swap file within an existing filesystem (which comes with some minor performance penalty due to the filesystem overhead).

The general procedure to add a swap partition/file:

  • create either a new partition of type 82h or a new 8 GB file using dd if=/dev/zero of=/swapfile bs=1M count=8192
  • initialize it using mkswap /swapfile or mkswap /dev/sdXX
  • use swapon /swapfile or swapon /dev/sdXX respectively to enable your new swap space on-the-fly
  • add an entry to /etc/fstab to make sure your new swap space gets activated upon reboot

Your current swap partition remains in use, you may want to get rid of it for the sake of complexity reduction. Just use swapoff /dev/sdc1 to disable its usage for the moment and remove the reference in /etc/fstab

Solution 2:

Would you be needing swap in this case? I do not know what you have running on your system system, but i try to have enough memory in my servers to avoid swap completely... (i do have it, but only as a failsafe, if my server starts swapping, i buy more memory...)

Solution 3:

You have to repartition the disk. If I remember well moving the begining of Linux partition isn't supported in parted but you can shrink your linux filesystem and partition as well and then make another swap at the end of your disk. You can't do this while the system is online.

Alternate solution is to use a big file as swap. (Don't know if it is a good idea nowdays.)