You are not logged in.
Pages: 1
Hello. I've recently noticed that my swap space isn't being used:
free -h
total used free shared buff/cache available
Mem: 7.8G 4.0G 1.8G 126M 2.0G 3.3G
Swap: 7.8G 0B 7.8G
What's the big idea? Here's my setup:
fdisk -l /dev/sda
Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5d60a6ae
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 206847 204800 100M 83 Linux
/dev/sda2 206848 472066047 471859200 225G 83 Linux
/dev/sda3 72066048 488396799 16330752 7.8G 82 Linux swap / Solaris
I've got a 250GB SSD with a LUKS partition for the entire install, and a swap at the end (not encrypted - yet). I do not use LVM.
My fstab:
# /dev/sda1
UUID=89a2ebbd-a775-45fd-a9ea-8a9d41f1111c /boot ext4 rw,relatime,stripe=4,data=ordered 0 2
# /dev/sda2
UUID=ace99b22-8998-415e-bd84-e9417fc54f21 / ext4 defaults,noatime,discard 0 1
# /dev/sda3 swap
UUID=a23212f8-69a3-4cd4-8bf4-d6bf2bf6c0a9 swap swap defaults,noatime,discard 0 0
Any help would be appreciated. Thanks!
Last edited by yochaigal (2016-05-18 20:14:02)
Offline
What's your /proc/sys/vm/swappiness set to?
You have enough free memory so strictly speaking no need for swap (yet).
Offline
Ah right forgot to say that. It's set to 60.
Offline
Under Windows, the swap is aggressively used whereas under Linux, it is used as needed. As frost points out, you likely don't need it.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Do you want it to be used more pro-actively or do you just want to test whether it would work if actually needed?
You could temporarily set swappiness to 100 and see if something happens. You could use more memory (for example by installing memtester and letting it test your entire free memory [3.3G in your above output]) and then open another browser or whatever; even with low swappiness surely something would start swapping at that point.
Basically I'd not be worried about it, unless you have errors showing up in dmesg, everything seems to be normal.
Last edited by frostschutz (2016-05-18 17:26:20)
Offline
I'm just confused as to why NONE is being used - my there other Arch systems all use it a fair amount.
Offline
None because you have 8g memory dim...
Open many applications to stress it and you'll see that it will use some swap
Last edited by alex.theoto (2016-05-18 17:57:18)
Offline
But why should swap space be used as long as there is even only a byte free RAM left? Swap is so much slower, so why should Linux prefer hard disk memory over actual RAM at a point where you have enough RAM?
Offline
I'm just curious as to why it is always zero - regardless of what I'm doing. I do max out RAM occasionally, if I had setup my swap wrong or something I wouldn't be surprised.
Offline
Swap is for pc's hibernation state.
Also, it is very useful on systems with low memory.
In my example, I have 2gb memory and 5gb swap:
free -h
total used free shared buff/cache available
Mem: 2.0G 590M 512M 2.1M 901M 1.2G
Swap: 4.7G 0B 4.7G
Last edited by alex.theoto (2016-05-18 18:28:19)
Offline
Well, if you really want to see your swap being used, just save this as "memfill.c", compile it ("gcc -o memfill memfill.c"), and run it:
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
int
main()
{
char *p;
size_t s = 100 * 1024 * 1024;
for (;;)
{
p = malloc(s);
bzero(p, s);
sleep(1);
}
/* unreached */
}
Watch memory consumption in something like htop. At some point, your swap will be used.
As others have pointed out, if your swap was not being used before, it simply means there was no need to.
(IMHO, if you do not intend to use hibernation, just turn off swap space altogether. 8GB is more than enough memory for common tasks. And, if you really do need more memory than 8GB, you should try to buy more RAM. Swap is so utterly slow, I try to avoid it at all costs.)
Offline
This is exactly what I did (a friend sent me a stackexchange article suggesting exactly this).
It seems to be being used (only 1M so far). So hurray! I'll mark this as solved.
Offline
Pages: 1