How to increase SWAP size in Fedora Linux?

Hello everyone!

One of my games actually freezes the whole system while loading this game. After some analysis, I saw the SWAP completely occupied. So I want to increase this SWAP size to at least 16 or 32 GB (8 GB is not enough for the game).

I could just go to Google and search for how to do that but… Since I use Fedora, I heard that :

Swap is useful, except when it’s slow. zram is a RAM drive that uses compression. Create a swap-on-zram during start-up. And no longer use swap partitions by default.

So does this means that the normal steps in distros like Ubuntu don’t work on Fedora because of this? If so, could you show me the steps since all of that is currently unclear to me.


I would advise against SWAP in any of the sizes requested as this will slow down your system; however, here are the commands anyway, they should work on Fedora although I have not tested.

sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Please note that your swapfile may need re-adding on boot. To do this add the following command to any script which runs at boot.

sudo swapon /swapfile

How much RAM do you have?

I have 8GB of RAM.

Seems like Fedora uses ZRAM instead of SWAP and I find the solution for it.

  1. Create a file named zram-generator.conf on the directory /etc/systemd

  2. Copy/paste that (it’s my configuration, change it depending on what you want)


zram-fraction seems to be a value, for example if the value is 1.X it means that the ZRAM will be equal to the amount of physical ram of your PC. If the value is 2.X, the ZRAM size will be the double of the physical RAM of your computer.

max-zram-size is actually the maximum ZRAM size you want.

Use a live USB of the distro of your choice, fire up Gparted, and repartition your drive that way. Needless to say that you do this at your own risk.

Name of the partition is zram while the mount point is called [SWAP] so yea it can be a bit tricky

So I won’t pretend to be anything close to an expert with respect to ZRAM, but my basic understanding is that ZRAM creates a swapfile in RAM.

If this is accurate (correct me if it isn’t), I don’t see how ZRAM could ever be larger in practice than the amount of physical memory you have (+ whatever the compression ratio is). In other words, it seems that if you use ZRAM the size of swap should be less than the amount of physical ram not more. If you are using swap to compensate for a shortage of RAM, it seems like ZRAM is likely not the best approach.

It seems to me that the best option in more ways tha none would be to add RAM if at all possible.

EDIT: Looks like what I wrote above is at least partially incorrect