Swap partition at 0% usage

Hello everyone, I have a problem with my swap partition, (it is not being used), I don’t know why this happens, I have a 7GB partition for swap, and I have configured the swapinness in /etc/sysctl, I set it to 90% and nothing happens, the free -h command shows me that 0B has been used, and that I have 7.1GB free, try to turn off the swap using the swapoff command, then activate it and it tells me the following: swapon: /dev/mmcblk0p4: swapon failed: Device or resource busy, I hope you can help me

I am using Manjaro Linux, kernel: 6.11.11-1-MANJARO

This kernel is EOL, switch to an LTS kernel or 6.12.

swap is extra space being used only if needed (normal behavior), so please exlain again why you assume it should have been used.

Please provide

cat /etc/fstab

so that we can see how you implemented the swap partition.

4 Likes

error: package not found: linux-lts

swap helps with the performance of the ram memory, to manage it better, also I don’t understand why I have a swap partition that is not used, I would like to use it to see if it really helps with the performance

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=F85A-9A74                            /boot/efi      vfat    umask=0077 0 2
UUID=ab0aaa2b-a95c-4235-97ee-ca07933fb53b /              ext4    defaults,noatime 0 1
UUID=c5244109-b0a6-4f39-bfe0-cffd147c5cdd /home          ext4    defaults,noatime 0 2
UUID=7e856b9f-b4b7-4033-92d3-9ad374265986 swap           swap    defaults,noatime 0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0

You should install the new kernel via mhwd-kernel or via the manjaro-settings-manager.

Do not remove the old kernel until you’ve rebooted into the newly installed one.

It all depends on how much RAM you have, and possibly whether you choose to hibernate the machine or not.

Not with performance directly, but it does prevent processes from getting killed and/or hogging the processors with I/O when your RAM is full.

3 Likes

You have misunderstandings what is what. Not needing to use swap is good. Cause the disk is a lot slower than ram. So if you have enough ram it will not be used.

3 Likes

I’ve got 16GB RAM with 8GB swapspace:

$ free -h
               total        used        free      shared  buff/cache   available
Mem:            15Gi       8.2Gi       1.2Gi       134Mi       6.6Gi       7.3Gi
Swap:          7.8Gi       412Mi       7.4Gi

With my swappiness set to 10:

$ sysctl vm.swappiness
vm.swappiness = 10

And my swap is also rarely used, as you can see in the first output. So I wouldn’t worry 'bout it if I were you.

This is a good read:

1 Like

Manjaro isn’t Arch. There is no package called linux-lts. Every available LTS kernel has its own package.

2 Likes

To be fair, I’ve got 16 GiB in this machine, and I’ve been running without swap for over five years now without any problems whatsoever.

Granted, I’m not a gamer, and I also do not hibernate my machine. I also don’t have any VMs.

:man_shrugging:

1 Like

Exactly the same here! Except I have 3 games installed:

  • Starcraft II;
  • Cities: Skylines; (yeah, I played it a long time ago. So long, I forgot whether it’s “Cities: Skylines” or “Skylines: Cities”, but I suspect the former); and
  • Contraption maker (like the old, almost ancient now, game “TIM”).

That I never really play anyway.

Edit:

HA! I was right:

and

Btw, swappiness 90 which the OP has customized from the default 60 makes exactly the opposite of what the OP expects - it tells the system not to use swap unless ram is 90% full. And yet it does not matter that much as in manjaro other kernel parameters are set too, so it is pretty much the default to try not to use swap if possible. Which is good for performance and ssd health.
For the record, mine is almost always 0 in light usage scenarios, even with 8 gb ram.

2 Likes

I’ve set up the laptop of my wife almost three years ago with Manjaro. It has 16 GB too with out Swap.
She’s not a gamer, but she’s one of the people having 20+ tabs open in browser.

Not a single issue about low memory reported by her so far. Otherwise it would be a major incident here :rofl:

4 Likes

Quite often the case but I’d always recommend having at least some swap, as a safety net.

free -h
free -h
               total        used        free      shared  buff/cache   available
Mem:           7.5Gi       5.0Gi       460Mi       630Mi       3.0Gi       2.4Gi
Swap:           15Gi       256Ki        15Gi

In my case I have extra swap defined, as it’s likely the system will have a RAM upgrade at some point (same with the other machine). I also do depend on hibernate being functional.

From what I’ve read, it has nothing to do with the percentage of used RAM. It’s used to set 2 variables:

anon_prio = swappiness
file_prio = 200 - swappiness

It’s essentially

a ratio of how costly reclaiming and refaulting anonymous memory is compared to file memory.

You should read the link @Mirdarthos posted, specifically the section titled “What should my swappiness setting be?” (which is where the quote came from).

A value of 90 will tell the system that the cost is nearly equal (anon_prio=90, file_prio=110), so it will try to drop file cache less and swap anonymous pages more. A lower value (for swappiness and therefore anon_prio) biases the system towards dropping file cache rather than swapping anonymous pages.

Here’s another link:
https://www.howtogeek.com/449691/what-is-swapiness-on-linux-and-how-to-change-it/

6 Likes

Same here, only with 32GiB in the desktop and newer laptop, but only 8GiB in the old laptop. Which is so old and slow (1.5Mhz 2C/2T) one doesn’t want to run more than one thing at a time.

Haven’t used swap in I can’t remember how long. Well over a decade, perhaps two. I just throw as much RAM as I care to afford into the box and call it good.

Cheap as chips, as it were…

1 Like

I do all of that – though, kMahjongg and a few (free) Steam games hardly qualifies me as a gamer. Even if hibernation isn’t desired it’s always best to have some swap rather than none.

The recommended Manjaro defaults are fine in most scenarios, but even with greater than average RAM (64GB in my case), I’m more comfortable with knowing swap is available when it’s needed;

even if that need is infrequent.

I would suggest Members avoid propagating the blanket falsehood that swap is not needed, as the need for swap depends greatly on any given use case.

3 Likes

Well, I come from the opposite vantage. To paraphrase your words, I would suggest that members refrain from pointing out that someone doesn’t have any swap as a knee-jerk response, as if not having swap would by definition be the cause of someone’s problems.

:man_shrugging:

Fair point. Neither she nor me are using that function. And at least for her no RAM upgrade is planned. She would rather get a new device with more RAM :wink:

Actually, it’s a valid thing to point out. It is of course up to the individual (and dependent on their use case) as to whether or not they choose to act on it.

I might often mention, for example: “You might wish to attend to swap; you have none defined.” There are those who then evaluate their need for swap, and others who simply ignore the comment.

Then there are the increasing number of … newer Members to consider, who somehow manage to miss the opportunity to configure swap during install.

There are some that tend to pounce on the absence of swap as a cure for all ills, if it is missing; that’s another blanket response that could use some taming.

People are people.

1 Like

Can you post inxi -Fza, wheter the swap is on.

Only if it’s pertinent. As you noted yourself… :point_down:

That is what I’m talking about. :point_up:

1 Like