In the PROC file system, you also find kernel tunables.
And to work with them, you use sysctl.
Sysctl is a utility that makes persistent settings
in PROC SYS.
You can use sysctl minus A for an overview of all parameters.
These parameters are shown as file names
that are relative to slash PROC SYS,
which use a dot as a path separator instead of a slash.
So slash PROC, slash SYS, slash VM, slash swappiness
will show as VM.swappiness.
To change settings, you can add the parameter
with the desired value to a file in etc.sysctl.d.
And package-provided optimizations
are typically installed in usrlib.sysctl.d.
We have already seen that there is another way
to work with these parameters, and that is the tune-d.
And the reapply sysctl parameter in etc.tune-d tune-d main.conf
determines whether or not sysctl or tune-d parameters
will be applied.
Now, let me show you a little bit more
about these sysctl tunables.
So I'm going into PROC SYS.
In PROC SYS, we see different interfaces
that relate to different parts of the operating system,
like VM, which is for memory management.
So here we have all the different memory management
parameters, including the so-called swappiness
parameter that we talked about earlier.
Now, you know what?
Let's do another one.
Let's do the dirty expire sentisex.
What is that?
Well, this relates to the way our files are written on Linux.
I already mentioned, when you write a file to the Linux
operating system, it will be written to the buffers.
And that's an area in memory.
This is the so-called dirty cache.
When in your buffers you have files
that need to be committed to disk,
then you see these files as dirty cache.
And related to that dirty cache, there's a couple of parameters.
And here we can see that the dirty expire
sentisex is set to 3,000.
A sentisex is a 100th of a second.
So that means that the maximum amount of time
that data remains in the buffer cache is 30 seconds.
If you want to make that longer for more efficient writes,
then you can echo the value into it right here.
So echo 6,000 greater than dirty expire sentisex
is one way of doing it.
And now if I use sysctl, not to be confused with systemctl,
minus a pipe grab dirty, we can see that the new value
is already operational.
So normally you would be testing.
And if you like the new value, you
are going to make it persistent.
So vm.dirty expire sentisex is what I'm going to need.
Now, if I like that, I need to go into etcc.
So if I like that, I need to go into etcc sysctl.d.
And I create a file with a name like vm99-dirty.conf.
The name of the file is not so very important.
So I'm using vm.dirty underscore expire underscore
sentisex is 600.
And that makes that the parameter
is going to be persistent.
Oh, no, not 600, but 6,000, because we want
it to be a complete minute.
So that is how it works.
And that is how you can make these parameters persistent.
Now, the number in the file name is kind of important.
And that is because these files are
loaded in alphabetical order.
And if you want to influence which
file is the highest priority, you give it a high number.
99 is loaded before 50.
So if you want to make sure in an environment
where you have multiple files that you influence the order,
you are going to play with these numbers.
As you can see here, not much is happening.
So the number in this case is not so very important.