You are not logged in.
Two days ago I've set swappiness to 70 because at 60 apparently it didn't work but nothing change.
What i have to do ?
Output of sysctl vm.swappiness :
vm.swappiness = 70output of free -m :
total used free shared buff/cache available
Mem: 3,8Gi 896Mi 1,8Gi 178Mi 1,0Gi 2,5Gi
Swap: 9,3Gi 0B 9,3Gioutput of lsblk :
sda 8:0 0 465,8G 0 disk
├─sda1 8:1 0 456,1G 0 part /
├─sda2 8:2 0 380,5M 0 part /boot
└─sda3 8:3 0 9,3G 0 part [SWAP]My fstab swap partition options :
UUID=xxxxxxxxxxxx none swap default,pri=10 0 0Zram script attivation that doesn't work
#!/bin/bash
modprobe zram num_devices=1
totalmem=3941608
mem=$(( ($totalmem)* 1024 *3))
echo $mem > /sys/block/zram0/disksize
mkswap /dev/zram0
swapon -p 5 /dev/zram0I've also read the https://wiki.archlinux.org/index.php/swap and i do everything what is written but nothing changes
Last edited by Khere (2020-10-23 15:59:00)
Fan of Giorgio Moroder & Mohammad Ammax enemy
Offline
vm.swappiness does most likely not what you think it does; read up https://bbs.archlinux.org/viewtopic.php?id=231265 and if things remain unclear, please clarify your expectations.
Offline
wm.swappiness it's the preference value for using the swap? If the value increase , the swap % used in relation to the RAM increase ?
Fan of Giorgio Moroder & Mohammad Ammax enemy
Offline
No. Please read the linked thread.
Offline
I've read It but i don't understand, btw how can i use swap and not only RAM ?
Fan of Giorgio Moroder & Mohammad Ammax enemy
Offline
By allocating a lot of memory.
There's no general point in utilizing slow SWAP if there's still perferctly good RAM available, but maybe this is an xy-problem.
What do you actually want to achieve (that you believe will require you to store information in the SWAP rather than the RAM)
Offline
I've wont to start to use swap when RAM is at 70-80%, cause i have 4gb RAM and use SWAP is essential for me.
Last edited by Khere (2020-10-23 10:29:56)
Fan of Giorgio Moroder & Mohammad Ammax enemy
Offline
I assume you meant that you want to start using the SWAP when the 70% of RAM are used but that makes no sense (again: you will only slow down stuff) and does especially not explain why you think you should do that.
What problem are you trying to solve?
You can constrain the RAM usage of processes w/ cgroups, but I don't even know whether that's your intention here.
Offline
I'm trying to use the swap because 4 gb of ram are very few, since I have a laptop almost completely broken it is not convenient to open it.
For this reason I am trying to use more volatile memory
Fan of Giorgio Moroder & Mohammad Ammax enemy
Offline
The kernel will invoke the swap when it needs it. Depending on the cause for the requirement, this can lead to significant slowdowns, but such causes are typically buggy processes that overallocate masses of memory and "force" the kernel to swap out more valuable processes.
You want to jail such misbehaving processes in a cgroup to force them to be moved to the slow swap.
Every comment you *will* find on the interwebz to play w/ swappiness to make the kernel use swap sooner/later is bullshit. The variable controls the preference of using swap for anonymous memory pages over simply dropping file caches (which can lead to very bad thrashing) and outside special usecases and knowing exactly what and why you're doing, the default value is the best choice.
Altering the overcommit parameters will only make random processes crash (the sum of all processes can claim more memory than you actually have, the kernel allows that, assuming not all of it is actually being used - denying that will typically make every process claiming memory after you entire memory has been claimed - but probably not used - crash hard)
Here's how to limit memory for a process:
https://wiki.archlinux.org/index.php/Cg … hoc_groups
If there's no known offender, just don't do anything but having swap space around.
Offline
In addition to what has already been said, you should not regard SWAP as a cheap replacement for insufficient RAM.
Historically SWAP is there to keep your system from going into undefined states or even crashing (see oomkiller) when there's not enough RAM left.
Nowadays, especially on mobile devices such as laptops, SWAP can also be used to provide disk space for suspend-to-disk functionality.
But it's not the cheap RAM replacement you're looking for.
If you need more RAM, give your system more RAM. If your system starts swapping, you're gonna notice it - and not in a good way.
Last edited by schard (2020-10-23 15:25:57)
Inofficial first vice president of the Rust Evangelism Strike Force
Offline
since I have a laptop almost completely broken it is not convenient to open it
But in general, yes: If you're constantly OOM, get more RAM.
Offline
Thank @Seth for for the patience, I understood that the only way to add volatile memory it's add RAM stick, thing that i can't do.
I'll close the post, someone may one day will have the same doubt as me
Last edited by Khere (2020-10-23 20:10:51)
Fan of Giorgio Moroder & Mohammad Ammax enemy
Offline
SWAP is "volatile" in the sense that the data isn't preserved to the OS across a reboot, the disk is however not (by default) erased, but you could, to some extent, emulate that by overwriting it on shutdowns or use an encrypted swap.
(nb. that swap inside a LVM is reported to be a massive CPU hog, but just encrypted swap doesn't seem to be)
zram can increase the amount of available memory by compressing the pages in the RAM, but that's not swap related at all.
Offline