Do I need to be nervous about swapping?

Do I need to be nervous about swapping? I have left the default settings about swapping, will something bad happen?

inxi -b
System:
Host: hgyamada-AR5 Kernel: 5.15.0-67-generic x86_64 bits: 64
Desktop: Gnome 3.38.4 Distro: Zorin OS 16.2
Machine:
Type: Desktop System: Thirdwave product: AR5 v: N/A
serial: <superuser/root required>
Mobo: ASRock model: A300M-STX serial: <superuser/root required>
UEFI: American Megatrends v: P3.52W date: 07/03/2019
CPU:
Quad Core: AMD Ryzen 5 2400G with Radeon Vega Graphics type: MT MCP
speed: 1476 MHz min/max: 1600/3600 MHz
Graphics:
Device-1: AMD Raven Ridge [Radeon Vega Series / Radeon Vega Mobile Series]
driver: amdgpu v: kernel
Display: x11 server: X.Org 1.20.13 driver: amdgpu
resolution: 1920x1080~60Hz
OpenGL: renderer: AMD Radeon Vega 11 Graphics (RAVEN DRM 3.42.0
5.15.0-67-generic LLVM 12.0.0)
v: 4.6 Mesa 21.2.6
Network:
Device-1: Intel Dual Band Wireless-AC 3168NGW [Stone Peak] driver: iwlwifi
Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
driver: r8169
Drives:
Local Storage: total: 261.73 GiB used: 20.82 GiB (8.0%)
Info:
Processes: 285 Uptime: 2h 07m Memory: 13.58 GiB used: 1.94 GiB (14.3%)
Shell: bash inxi: 3.0.38

Swapping what?

Swap from main memory to storage.

Nothing to be nervous about...

I thought that might be it, but then I wondered if you meant having swapped out some hardware...

1 Like

It's a bad habit of mine to accidentally forget to write down necessary information. :sweat:

It seems that outdated information regarding memory swapping is misleading. It is my understanding that swapping is done from data that is not accessed very often, so there is no sudden drop in performance. Also, the lifespan of SSDs has improved over the years, so swapping is unlikely to be a problem from that standpoint.

One thing you have to worry about with using the swap drive is that the kernel expects quick access to that data, and it'll panic if that data is delayed, so you shouldn't use the swap drive for anything else.

This is especially bad with older, slower spinning-rust drives, for SMR (shingled) drives if they're more than ~60% full and you're doing a lot of data writing (they slow way down in that circumstance), and for older USB sticks that don't have simultaneous bidirectional data transfer (ie: < USB 3.0).

Another is that if you're hitting the swap, you're riding right on the edge... you're using all your RAM, and the default swap is a tiny 2 GB.

The 2 GB default partition on the main drive is bad design... the OS partition could be busy at the same time that the swap partition is, and it's too small. That's why I've got 2 swap drives, a sum total of 4x my RAM.

I'm buying new CMR (as opposed to SMR) drives for the rpool mirror (and I'll be setting up a bpool mirror which should cut my boot time by half), and while I'm at it, I'll purchase some fast USB sticks to use as swap drives. That way the swap and the OS drives are completely separate.

It also depends what drive you have. SSD no swap needed. HDD with manual install I always create swap at end of logical partition and make it double the size of physical RAM.

You can always reduce the reason for swapping by lowering the cache-pressure.

Approach: I assume gedit is a text-editor on your system, and, of course, you can always use another one of your preference.

sudo gedit /ect/sysctl.conf

Add a line (if it is not there)
vm.swappiness=10 (the value out-of -the-box is 60 : that is for servers and professional workstations maybe a good setting, but in a normal situation far too high)
Value 10 is a value that handles the underlying reason for swap well. Don't, for now, set this to 0 (zero) ... at that point you are pure gambling that Zorin, Ubuntu, does not need to swap at all .... Maybe correct, maybe not ... gambling thus.

Save and close the editor and do a reboot for the value to be up and running.

You can test before making it permanent ! Just run your session of Zorin and open a terminal and type:

sudo sysctl vm.swappiness=10

The system will instant adapt to the new value. But, mind you, this is NOT remembered when you would restart or reboot. But this method allows you to do a test before you dive into the sys-files as root editting. Some people are prudent, some totally not (me lol). So I give it to you for extra advise.

Remember that swap in memory is much faster than a swap on disk ... So evaluate what is important for you. Note: after real using Linux from 10.04 LTS on, I have never ever seen my computer swap regardless what I was doing in my testing. Phonorix explained how you can make your OS in a brutal forcing to swap ... But it learned me that is "maybe" a worst case scenario for coders and developers on this system. And it never really changed in any way, better: it just got more and more stable. So even in my alpha-testing (Lunar Lobster from Ubuntu) I never get that OS to swap for rescue ....

A lot on internet is to be found regarding swap and Linux .... I would say just relax set your swap to disk and notice very well it is even pointless to do so, yet ... gambling on a production-machine is maybe not really good thinking.
My Google Chrome even jumped in that many open Tabs will no longer consume my RAM in full but works more and more from out of swap-cloud (Drive, One), and for free even !!!
HDD should be become totally obsolete at this time-stamp: an SSD is no longer $$$$ ... Swap on SSD will almost NEVER occur in the reality of a stable OS that Ubuntu, Zorin, Debian really is.

1 Like

Swap file are use when you have less that 4Gig memory, not mention that it put a strain on the hdd. I have 16G and never use swap files

My understanding of swap is that it uses disk space as temporary memory when there's not enough RAM. Unless you are using that much memory frequently, I wouldn't worry about enabling it at all. It's also probably cheaper to add more RAM if you actually need more, than toying with swap at least for desktops/laptops.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.