How to identify a swap file or partition?

I used this command to find a swap partition on my system:

$ swapon --show --verbose
NAME       TYPE      SIZE   USED PRIO
/dev/zram0 partition   8G 178.9M  100
$

Does this mean that my system is currently using 178.9M of the swap partition (has swapped 178.9M of RAM)?

Shouldn’t ‘df’ show swap partitions? I don’t see anything that indicates that there is a swap partition (it’s certainly possible that I’m not understanding the output).

$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/nvme0n1p3 975097856 203858208 768549616  21% /
devtmpfs            4096         0      4096   0% /dev
tmpfs           14211384     91856  14119528   1% /dev/shm
efivarfs             128        30        94  24% /sys/firmware/efi/efivars
tmpfs            5684556      2384   5682172   1% /run
tmpfs               1024         0      1024   0% /run/credentials/systemd-journald.service
tmpfs               1024         0      1024   0% /run/credentials/systemd-network-generator.service
tmpfs               1024         0      1024   0% /run/credentials/systemd-udev-load-credentials.service
tmpfs               1024         0      1024   0% /run/credentials/systemd-tmpfiles-setup-dev-early.service
tmpfs               1024         0      1024   0% /run/credentials/systemd-sysctl.service
tmpfs               1024         0      1024   0% /run/credentials/systemd-tmpfiles-setup-dev.service
tmpfs               1024         0      1024   0% /run/credentials/systemd-vconsole-setup.service
tmpfs           14211388     21876  14189512   1% /tmp
/dev/nvme0n1p3 975097856 203858208 768549616  21% /home
/dev/nvme0n1p2    996780    428964    499004  47% /boot
/dev/nvme0n1p1    613184     19796    593388   4% /boot/efi
tmpfs               1024         0      1024   0% /run/credentials/systemd-tmpfiles-setup.service
tmpfs               1024         0      1024   0% /run/credentials/systemd-resolved.service
tmpfs            2842276      3840   2838436   1% /run/user/1000

And here is my /etc/fstab file:

UUID=4a972d32-b4a0-418e-8f6d-f1aabcbe6b5f  /            btrfs       subvol=root,compress=zstd:1 0 0
UUID=0a70d693-9894-45d2-9668-122dffac9304  /boot        ext4        defaults                    1 2
UUID=EBC8-9DD9                             /boot/efi    vfat        umask=0077,shortname=winnt  0 2
UUID=4a972d32-b4a0-418e-8f6d-f1aabcbe6b5f  /home        btrfs       subvol=home,compress=zstd:1 0 0

Is there anything in the /etc/fstab file that indicates/specifies a swap partition? Or, does the kernel create one automatically based on some internal algorithm such as using some percentage of detected RAM?

ZRAM doesn’t use a disk partition. It compresses the memory (when necessary) instead.

https://fedoraproject.org/wiki/Changes/SwapOnZRAM

4 Likes

OK, many thanks, @glb I guess the kernel sets up the zram internally.

Now… the next task to do today. On each of those two external hard drives, I defined a 128GiB partition to use as swap. One such partition is enough, but the second drive is going to be for backup in case the first one fails.

I’ll work on this today… doing some reading on mkswap, swapon, swapoff, etc… and some internet pages that look promising so I can learn ‘the right way’ to do it.
:grin:

1 Like

128GB of swap space? Nonsense. Nowadays, the recommended swap size is much smaller:
https://jfearn.fedorapeople.org/fdocs/en-US/Fedora/20/html/Installation_Guide/s2-diskpartrecommend-x86.html

2 Likes

It depends on how many processes you’re running and how much virtual memory is needed or in use by all those processes.

If you need 192GB to run your stuff, better buy more ram instead of waiting for the swap. Read the link and google around for more examples.

I have already purchased an additional 32GB of RAM, making a total of 64GB RAM.

But the issue is always the trade-off between performance and cost. That is the reason virtual memory was created in the first place.

By the way, all those estimates of ‘swap’ space size or chock full of presumptions about how a system is going to be used.

@caesar

This disagreement is not necessary.
It is 100% up to the user how to configure swap and everything seen online must be taken as either suggestions or anecdotal.

Nothing is ‘set in stone’ as to how swap should be configured. Every use case is different and swap should be adjusted accordingly.

2 Likes

I apologize if I sounded ‘argumentative’ or disagreeable. I was just trying to share my thoughts via discussion.

I agreed 100%…! Each case is different. There are many considerations. And there are many parameters in an OS environment to help one tune one’s platform for the performance profile that is most optimal or amenable to the intended use.

No problem
Each is entitled to their own opinion.
The only thing I was trying to do was de-escalate the conflicts in the opinions voiced. Each seemed firmly set and it felt there was potential for more disagreement.

We try to assist as much as possible and not be overbearing when voicing suggestions nor have hard feelings anywhere.

1 Like

Thanks @computersavvy

I’m not sure if you were referring to anything I wrote. Upon reviewing all of my comments, I don’t see anything that sounds dogmatic, argumentative, aggressive, or critical. But let me know if I had an offensive tone anywhere. It certainly wasn’t my intention.

I have to state my position or what I believe is correct or factual (call it opinion if you like) in order to precipitate a discussion (not an argument). That being said, if I state something that is wrong, then I’d like to know what is wrong with it so I can learn.

1 Like

I’d argue 1TB swap might not be enough :stuck_out_tongue: OOM kills Plasma 6?

Oh my…! Thanks for sharing this thread, @Espionage724 … very interesting reading…!
Interesting comments in there about the OS killing off processes.

As you didn’t provide any example of your usage we had to guess. If you use 192GB of space once in a lifetime, you could survive even with 8GB of ram and else swap on hd.
I estimated what would happen on a run I did for several weeks on a configuration swapping out 128GB on nvme (not a sata ssd). The access is slower at least an order of magnitude wrt ram, considering what was doing the necessary runtime would be at least of 1 year. Certainly not worth saving the price for further 64GB.