Today's article is only useful to those who use swap...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
11,499
Reaction score
9,995
Credits
95,342
I still use swap. That horse is dead and not worth beating. If you do not use swap then you will not be all that interested in today's article. The next one might be one that strikes your fancy, so there's always that. (And chances are there will be a next one!)

So, it's just a couple of ways to monitor swap usage:


I do enjoy the feedback. I end up learning quite a bit that way.
 


I still use swap. That horse is dead and not worth beating. [...]
For those of us who want to see the corpse for themselves, can you recommend a few links related to the discussion? Is the dead horse about not using swap, or whether to choose a swap partition vs a swap file, or something else?
 
Just root around for 'swap' and you'll likely find people saying they don't use swap and why. You'll also find people saying you don't need swap if you have enough RAM. I don't have any specific threads but it has been a topic all sorts of times. It's not a hill anyone picks to die on, so they're not drama-filled threads or anything like that.

But, now that you bring it up, someone may chime in with their thoughts on the matter. It's not a topic that draws that much drama.

I should also point out that they're likely correct - that you don't need swap with enough RAM. But, needing and utilizing are two different things. I figure the kernel is smarter than I am, or at least written by people smarter than I am. If the kernel uses swap when available, I tend to provide the kernel with swap. It's definitely not a hill to die on.

I do not always. I do the majority of times - the vast majority of times... I have a desktop with 64 GB of RAM and no swap, but that's 'cause I forgot to enable it during install and just haven't come around to adding it.
 
Just root around for 'swap' and you'll likely find people saying they don't use swap and why. [...]
Thanks for this input. It helped me understand the question.

I searched before and after my post above. What I found were descriptions of the purpose of the swapfile and how it is used. I did not find arguments for or against using swap. A few websites explained how swap can be helpful even in "plenty of RAM" situations. For example, Linux can use swap out a dormant "RAM-hog" application and use the freed RAM as a drive cache to improve system performance. (Assume that the "RAM-hog" application is not doing anything but waiting for activation or background input, so it does not matter if it is in RAM or swap.)

I looked at my currently active Linux instances and was surprised. All are fairly recent distros. Some are VPSs, some are VPSs, and some are VMware virtual machines. Here are the difference swap settings for the "default" installations. A "Template" installation has been modified by others for compatibility with the OpenVZ or Oracle Cloud Infrastructure virtualization schemes.

Name
Linux
Version
Virtualization
Installation
Swap
Desktop
deb10vpsDebian
10​
OpenVZTemplatenonenone
deb11vpsDebian
11​
KVM.iso/dev/vda5none
olOracle Linux
8​
Oracle CloudTemplate/.swapfilenone
ulUbuntu
22.04​
Oracle CloudTemplatenonenone
deb serverDebian
11​
Vmware.iso/dev/sda5none
deb desktopDebian
11​
Vmware.iso/dev/sda5XFCE
mintMint
21.1​
Vmware.iso/swapfileCinnamon
mxMX Linux
21.3​
Vmware.iso/dev/sda2XFCE
manjaroManjaro
22.1​
Vmware.isononeXFCE

There is no consistency in how swap is installed, which surprised me. Even the two non-partition swapfiles differ - one is hidden, the other not.

Related, barely:
Be wary. You may find unexpectedly kinky references when you search for "swap". ;-)
 
I can really only speak about Ubuntu in those regards. I believe they default to swap. If not, it's a mere tick during the graphical installation to enable it as a swapfile. You'd have to manually create a swap partition if you wanted one. Let me check...

Yeah, that's the case in at least Lubuntu - which is the first VM I decided to boot - and I think it's consistent across the flavors...

18MlsTi.png


As you can see by the various defaults you've listed, there's a variety of opinions about swap being beneficial/necessary or not.

I've tried to understand what swap is with a ton of reading. In the end, I concluded that I'd keep it enabled so long as the kernel was using it. I mean, it's gotta have a reason for that? As stated above, I just assume the kernel is smarter than I am. I decided completely understanding swap was beyond my skill level and/or motivation, but I did make it a point to try to understand the basics.
 
David, I meant to hit the Whack A Mole for 5, but hit 3 by mistake - I hope you can adjust that.

The reason I went for a 5, even though I do not use swap on any of my 89 Distros, is that I figure that users cannot be expected to subscribe to my point of view if they do not at least monitor their usage of existing swap, and your article provided that succinctly. :)

Cheers

Wizard
 
David, I meant to hit the Whack A Mole for 5, but hit 3 by mistake - I hope you can adjust that.

LOL I could adjust it, but it'll be kind of amusing to me when I see it. It's a bit of weirdness to remove the votes, but it's possible to do so.
 
I installed a desktop Ubuntu and desktop Lubuntu following the default installations. I did not view or alter the default disk configuration during installation. Both created /swapfile in the root ( / ) filesystem. Both systems were identical: 4 Gbytes RAM, 2 cores, 40 Gbyte drive.

For its default installation, Ubuntu created a 4 Gbyte swapfile. Lubuntu created a 500 Mbyte swapfile.
 
Ubuntu and desktop Lubuntu

Yeah, I think all the Ubuntu/flavors default to a swapfile. When at the installation screen is at the point where you decide partitioning and format options, you can disable it.

Disk space is cheap these days. So, there's another reason why one might just as well let it exist. You can turn it off if it is enabled and you don't like it. That's easy enough to do.
 

Members online


Latest posts

Top