Answer the question
In order to leave comments, you need to log in
How to make swap file with dynamic size in Linux?
In Windows, the pagefile.sys file is responsible for the swap and it can be configured so that it gains weight as needed, no more than a certain size, and so that it takes a strictly defined size all the time.
In Linux, I am not strong in those guides that I read, either they created a partition of a strictly specified size for swap, or they created a file of a given size and assigned it as a swap.
How to create a swap file in Linux so that it increases and decreases in size depending on whether data from RAM needs to be moved to swap or not?
Answer the question
In order to leave comments, you need to log in
How to create a dynamically sized swap file in Linux?
There is no dynamic swap file in linux (initially, only a fixed-size partition could be a swap, but then the placement on file systems was added, if they support it, with reservations), but it is possible to dynamically connect and disconnect new swap files or devices using the swapon and swapoff console commands, the contents of the file must be 'formatted' by mkswap before being included, this avoids the mistake of specifying a normal file.
Swap can be placed as a file on popular file systems such as ext4 or network nfs, iscsi devices can be used, there should be no 'holes' (sparce files) in the file, i.e. it will not be possible to allocate a fast place using dd seek, (on something like fat it will work), and compression and cow should also be turned off (see chattr) if btrfs is used for example
if you don’t have an old computer and have more than 4GB, and you don’t suffer from sleep mode,
then you don’t need swap,
at least some crooked applications / programs require
me 8 RAM + 1GB / swap in the file
in the sysctl configs
kernel.sysrq = 1
vm.swappiness = 15
vm.vfs_cache_pressure = 50
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question