To summarize, I retain:
Create a .conf file into:
/etc/sysctl.d/
and apparently no more into /etc/
Any name will do.
As I said, it’ll help, that a swap partition creation, to ask for the swappiness, because the default 60 is very different if you have 8Gb or 32Gb and HDD or SSD.
Now, if you have:
/etc/sysctl.d/10-swappiness.conf
/etc/sysctl.d/20-swappiness.conf
/etc/sysctl.d/30-swappiness.conf
…
then it’s even more confusing, because you wonder which one is active and how you know that.
All configuration files are sorted by their filename in lexicographic order, regardless of which of the directories they reside in. If multiple files specify the same option, the entry in the file with the lexicographically latest name will take precedence. Thus, the configuration in a certain file may either be replaced completely (by placing a file with the same name in a directory with higher priority), or individual settings might be changed (by specifying additional settings in a file with a different name that is ordered later).
It seems you (still) misunderstand what that value means.
It’s not a percentage of the size of the swap space - it is used by the kernel to calculate how readily swap is utilized in favor of RAM.
If you have that, you had to have done it yourself - and if you find that confusing, you confused yourself by doing it that way.
It’s a pretty contrived example …
But if you follow your example and create these files, each one containing a different, step by step higher value, then you can see for yourself which value / which file ends up getting used.
Solution:
If these files contain the same key vm.swappiness in this case
but a different value for that key,
the value in the file name with the highest number will end up being used.
The swappinesssysctl parameter represents the kernel’s preference for writing to swap instead of files. It can have a value between 0 and 200 (max 100 if Linux < 5.8); the default value is 60. A low value causes the kernel to prefer freeing up open files, a high value causes the kernel to try to use swap space, and a value of 100 means IO cost is assumed to be equal.
Note: There is a common misconception that swappiness affects the memory threshold or prevents using swap space, but it only affects the preference for freeing up file pages over swap. See: this article for a more detailed explanation or the kernel source code where it is used.
To check the current swappiness value:
$ sysctl vm.swappiness
Alternatively, the file /proc/sys/vm/swappiness can be read in order to obtain the raw integer value.