Increasing swap space

I am using Fedora KDE 41. I noticed that my swap space is seemingly located on dev/zram0 and it shows as a separate disk. This is weird because I have 2 disks and it is not shown as a part of either of them. How would I go about increasing my swap to 32 GiB, so I can hibernate my laptop, in case I have to?
Also, how is ZRAM different from swap space I would create my downsizing any of my “regular” partitions? Can I delete this zram and just create a 32 GiB partition with mountpoint as linuxswap? Would the end result be the same thing?

Hi MM,

Have a look here:

I think the zram block is hard coded into Fedora, meaning you can’t really disable it without some workarounds. Still new to Fedora myself, so I could be wrong. You can create your own swap space (either a file or a partition) but Fedora will still prioritize the zram block. You can modify your zram (make it smaller or bigger). Zram lives inside your system RAM, so you won’t find it on your physical drives. I guess you can create a swap partition just to hibernate, should not be a problem. It just won’t be used during regular use (unless you manage to saturate your zram space).

As I understand it, zram stores compressed data into RAM. Meaning instead of you using 8GB of RAM (just to put a number), some of that will be compressed into zram lowering your actual RAM usage to say 6GB. It’s more useful for low RAM machines (<16GB), but it’s still faster than a regular swap space on a drive (even if it’s a speedy SSD). Depends also on how you use your machine (regular home desktop use, specific workstation tasks, server, etc).

Hi Melcar,

You can disable zram with a kernel command line entry in grub, systemd.zram=0 … looks like this:
in /etc/default/grub:

GRUB_CMDLINE_LINUX=“psmouse.elantech_smbus=0 rhgb systemd.zram=0 mitigations=off nouveau.modeset=0 modprobe.blacklist=nouveau rd.driver.blacklist=nouveau”

NOTE:
Make certain you either create a swapfile or a swap partition with it’s entry in /etc/fsatb BEFORE you apply the kernel command line entry systemd.zram=0

Thank you for the responses. I am confused about a few things, though.
My zram looks like a 3rd disk on KDE partitition manager, and I cannot resize it.
Right now, I have 8 GiB “regular” swap partition and another 8 GiB from zram. Would it be better in performance, if I just had 32 GiB of zram? My RAM is 32 GiB, by the way.

If it is the case, how do I resize zram?

That is described int tha man page for zram-generator.conf. Run

man zram-generator.conf

to see that.

Keep in mind that zram swap space can’t be used for hibernation. Also that increasing the zram size will reduce your normal available memory.

Does your system have a problem that more swap space will solve?

If not you are better off leaving the zram swap setup.
It will use only a few KiB until you actually start paging (using swap space).

so, zram is just faster swap that can’t be used for hibernation?

Well, my understanding was that in order to successfully hibernate a computer, swap space should equal RAM, right? So, I was stuck with either increasing the swap space or zram. Now that I now swap can’t be used for hibernation, I decided to increase the capacity of the actual swap space. Space is not an issue for me. I have a 2+ TiB disk.

One thing I didn’t get, though: My zram is shown as a separate disk. It doesn’t tell me which disk it took the 8 GiB from, although I know for a fact that it is taken from the disk with my linux root partition on it, as I didn’t use the other disk during installation. However, theoretically, how do I see what disk it belongs to? my disks are dev/nvme0n1 and dev/nvme1n1. Zram is shown separately, as dev/zram0. This doesn’t make sense to me.

Ok. Yes for hibernation you need persistent storage.

Zram swap uses the computers RAM, not a disk.

I assume you would add a lower priority disk backed swap file as you described, but leave zram configured.

So, I increased my swap to accommodate 32 GiB and my zram is at 8 GiB.
I am given to understand that for my setup 8GiB of zram is way more than enough and I should leave it as it is then?

8GiB Is the default and seems to work well.

You can use zramctl to see the amount of RAM that is in use.

Here is what I see on my system with the various swap/meminfo commands that has both zram and disk swap:

$ free -h
               total        used        free      shared  buff/cache   available
Mem:            15Gi       1.2Gi       346Mi       9.4Mi        14Gi        14Gi
Swap:           15Gi       251Mi        15Gi
$ swapon
NAME       TYPE      SIZE   USED PRIO
/dev/dm-3  partition 7.8G     0B   -2
/dev/zram0 partition   8G 251.8M  100
$ zramctl
NAME       ALGORITHM DISKSIZE   DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle         8G 251.2M 76.6M 79.8M       4 [SWAP]

So, my zramctl returns this:

NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle 8G 4K 80B 12K 16 [SWAP]

but my free -hreturns this:

               total        used        free      shared  buff/cache   available
Mem:            31Gi       5,3Gi       7,6Gi       165Mi        18Gi        25Gi
Swap:           39Gi          0B        39G

Is this normal? What is weird is that my zram and swap are exactly 8 GiB and 32 GiB respectively. I don’t know why it shows 39 here. Apart from that, everything seems normal to me.

Looks normal. The 39Gi is likely because of a rounding down of the 8GiB to 7.9GiB to account for some overhead in zram.

1 Like