translator
278
edits
m (Prepared for translation) |
(Marked this version for translation) |
||
Line 2: | Line 2: | ||
<languages /> | <languages /> | ||
<translate> | <translate> | ||
=Overview= | =Overview= <!--T:1--> | ||
<!--T:2--> | |||
Swap space is used to extend the amount of memory(RAM) available for running programs.</translate> | Swap space is used to extend the amount of memory(RAM) available for running programs.</translate> | ||
* <translate>Without swap space, if you run out of memory, applications ''will'' be terminated up to and including the entire system crashing.</translate> | * <translate><!--T:3--> Without swap space, if you run out of memory, applications ''will'' be terminated up to and including the entire system crashing.</translate> | ||
* <translate>With swap space available to the system, the kernel can take less frequently accessed memory pages from inactive applications / services and write them to disk ("swapping" them), allowing more actual RAM to be available for active applications.</translate> | * <translate><!--T:4--> With swap space available to the system, the kernel can take less frequently accessed memory pages from inactive applications / services and write them to disk ("swapping" them), allowing more actual RAM to be available for active applications.</translate> | ||
<translate>There are three different ways in which swap can be managed in Manjaro:</translate> | <translate><!--T:5--> There are three different ways in which swap can be managed in Manjaro:</translate> | ||
* <translate>A swap partition</translate> | * <translate><!--T:6--> A swap partition</translate> | ||
* <translate>A swap file</translate> | * <translate><!--T:7--> A swap file</translate> | ||
* <translate>zswap</translate> | * <translate><!--T:8--> zswap</translate> | ||
<translate>This article tries to be as comprehensive as possible but even more information can be found in the [[<tvar|link>Special:MyLanguage/#See_Also</>|articles linked below]]</translate> | <translate><!--T:9--> This article tries to be as comprehensive as possible but even more information can be found in the [[<tvar|link>Special:MyLanguage/#See_Also</>|articles linked below]]</translate> | ||
<translate> | <translate> | ||
=Do I Need Swap= | =Do I Need Swap= <!--T:10--> | ||
<!--T:11--> | |||
That is a question that cannot be answerd without having a look at your configuration and even with plenty of available memory, it is often used as a safety net or even sometimes due to specific application requirements so have a look at the following non-exhaustive list:</translate> | That is a question that cannot be answerd without having a look at your configuration and even with plenty of available memory, it is often used as a safety net or even sometimes due to specific application requirements so have a look at the following non-exhaustive list:</translate> | ||
* <translate>If you use hibernation: ''yes, you need swap!''</translate> | * <translate><!--T:12--> If you use hibernation: ''yes, you need swap!''</translate> | ||
* <translate>If you have services that are not always active, but are still running all the time: ''yes, you need swap!''</translate> | * <translate><!--T:13--> If you have services that are not always active, but are still running all the time: ''yes, you need swap!''</translate> | ||
* <translate>If you have an application that allocates virtual memory directly for temporary storage instead of RAM: ''yes, you need swap!''</translate> | * <translate><!--T:14--> If you have an application that allocates virtual memory directly for temporary storage instead of RAM: ''yes, you need swap!''</translate> | ||
* <translate>If you have an application that has a memory leak: ''yes, you need swap!''</translate> | * <translate><!--T:15--> If you have an application that has a memory leak: ''yes, you need swap!''</translate> | ||
* <translate>If you have a server with 1TB of RAM that you're using as a desktop without applications allocating virtual memory or having memory leaks: ''No, you don't need swap!''</translate> | * <translate><!--T:16--> If you have a server with 1TB of RAM that you're using as a desktop without applications allocating virtual memory or having memory leaks: ''No, you don't need swap!''</translate> | ||
<translate> | <translate> | ||
=How Much Swap do I Need= | =How Much Swap do I Need= <!--T:17--> | ||
<!--T:18--> | |||
The amount of swap you need is highly variable based on ''your'' specific applications and workload. There is no universal formula on swap size without monitoring usage over a period of time. A reasonable place to start would be:</translate> | The amount of swap you need is highly variable based on ''your'' specific applications and workload. There is no universal formula on swap size without monitoring usage over a period of time. A reasonable place to start would be:</translate> | ||
* <translate>For less then 4GB of physical memory (RAM), it's highly recommended that the swap space should, as a base minimum, be equal to the amount of RAM. Also, it's recommended that the swap space is maximum twice the amount of RAM depending upon the amount of disk space available for the system because of diminishing returns.</translate> | * <translate><!--T:19--> For less then 4GB of physical memory (RAM), it's highly recommended that the swap space should, as a base minimum, be equal to the amount of RAM. Also, it's recommended that the swap space is maximum twice the amount of RAM depending upon the amount of disk space available for the system because of diminishing returns.</translate> | ||
* <translate>For more modern systems (>4GB), your swap space should be at a minimum be equal to your physical memory (RAM) size '''if you use hibernation''', otherwise you need a minimum of ROUNDUP(SQRT(RAM)) I.E. the square root of your RAM size rounded up to the next GB. The maximum, is again twice the amount of RAM, again because of diminishing returns.</translate> | * <translate><!--T:20--> For more modern systems (>4GB), your swap space should be at a minimum be equal to your physical memory (RAM) size '''if you use hibernation''', otherwise you need a minimum of ROUNDUP(SQRT(RAM)) I.E. the square root of your RAM size rounded up to the next GB. The maximum, is again twice the amount of RAM, again because of diminishing returns.</translate> | ||
* <translate>The only downside to having more swap space than you will actually use, is the disk space you will be reserving for it cannot be used for application or system data.</translate> | * <translate><!--T:21--> The only downside to having more swap space than you will actually use, is the disk space you will be reserving for it cannot be used for application or system data.</translate> | ||
<translate>The "diminishing returns" means that if you need more swap space than twice your RAM size, you would be better off adding more RAM as Hard Disk Drive (HDD) access is about 10³ slower then RAM access, so something that would take 1 second, suddenly takes more then 15 minutes! And on a Solid State Drive (SSD) the same operation that took 1 second in RAM will still take about 1 minute on that SSD!</translate> | <translate><!--T:22--> The "diminishing returns" means that if you need more swap space than twice your RAM size, you would be better off adding more RAM as Hard Disk Drive (HDD) access is about 10³ slower then RAM access, so something that would take 1 second, suddenly takes more then 15 minutes! And on a Solid State Drive (SSD) the same operation that took 1 second in RAM will still take about 1 minute on that SSD!</translate> | ||
<translate>Taking into accound all of the above, this brings us to the following table: | <translate><!--T:23--> | ||
Taking into accound all of the above, this brings us to the following table: | |||
(last 3 columns denote swap space)</translate> | (last 3 columns denote swap space)</translate> | ||
<translate>RAM No hibernation With Hibernation Maximum</translate> | <translate><!--T:24--> RAM No hibernation With Hibernation Maximum</translate> | ||
1GB 1GB 2GB 2GB | 1GB 1GB 2GB 2GB | ||
2GB 2GB 3GB 4GB | 2GB 2GB 3GB 4GB | ||
Line 44: | Line 48: | ||
4GB 4GB 6GB 8GB | 4GB 4GB 6GB 8GB | ||
<translate>RAM No hibernation With Hibernation Maximum</translate> | <translate><!--T:25--> RAM No hibernation With Hibernation Maximum</translate> | ||
5GB 2GB 7GB 10GB | 5GB 2GB 7GB 10GB | ||
6GB 2GB 8GB 12GB | 6GB 2GB 8GB 12GB | ||
Line 60: | Line 64: | ||
4TB 64GB 4160GB 8TB | 4TB 64GB 4160GB 8TB | ||
8TB 91GB 8283GB 16TB | 8TB 91GB 8283GB 16TB | ||
{{note|<translate>The largest server one of the authors of this wiki has ever installed had, indeed, 8TB of RAM</translate>}} | {{note|<translate><!--T:26--> The largest server one of the authors of this wiki has ever installed had, indeed, 8TB of RAM</translate>}} | ||
<translate> | <translate> | ||
=Displaying Swap Information= | =Displaying Swap Information= <!--T:27--> | ||
<!--T:28--> | |||
The command {{ic|swapon}} will display your current swap information. For example:</translate> | The command {{ic|swapon}} will display your current swap information. For example:</translate> | ||
swapon | swapon | ||
Line 69: | Line 74: | ||
/dev/sda7 partition 20G 44.3M -2 | /dev/sda7 partition 20G 44.3M -2 | ||
<translate>The following script will:</translate> | <translate><!--T:29--> The following script will:</translate> | ||
* <translate>show whether zswap is active or not and if active, give zswap parameters if run with the `sudo` command</translate> | * <translate><!--T:30--> show whether zswap is active or not and if active, give zswap parameters if run with the `sudo` command</translate> | ||
* <translate>display a list of all applications / services that take up swap and how much they take up in descending order</translate> | * <translate><!--T:31--> display a list of all applications / services that take up swap and how much they take up in descending order</translate> | ||
#!/bin/bash | #!/bin/bash | ||
Line 92: | Line 97: | ||
done | sort --key 2 --numeric --reverse | more | done | sort --key 2 --numeric --reverse | more | ||
<translate> | <translate> | ||
=Using a Swap Partition= | =Using a Swap Partition= <!--T:32--> | ||
<!--T:33--> | |||
A swap partition is the traditional way of managing swap. In this scenario, a dedicated partition (or partitions) are created for holding swap.</translate> | A swap partition is the traditional way of managing swap. In this scenario, a dedicated partition (or partitions) are created for holding swap.</translate> | ||
<translate> | <translate> | ||
==Creating and Enabling a Swap Partition== | ==Creating and Enabling a Swap Partition== <!--T:34--> | ||
<!--T:35--> | |||
To create a swap partition, you need enough unallocated disk space to create an additional partition. If you do not have enough space, skip to the next section [[<tvar|link>Special:MyLanguage/#Using_a_swap_file</>|#Using_a_swap_file]]. A swap partition can be created in any disk management / partition management tool and should be set as type `linuxswap`.</translate> | To create a swap partition, you need enough unallocated disk space to create an additional partition. If you do not have enough space, skip to the next section [[<tvar|link>Special:MyLanguage/#Using_a_swap_file</>|#Using_a_swap_file]]. A swap partition can be created in any disk management / partition management tool and should be set as type `linuxswap`.</translate> | ||
<translate>Once you have a swap partition you will need to initialize the swap partition with {{ic|mkswap}}. For example, if your swap partition is {{ic|/dev/sda3}}, you could use the command:</translate> | <translate><!--T:36--> Once you have a swap partition you will need to initialize the swap partition with {{ic|mkswap}}. For example, if your swap partition is {{ic|/dev/sda3}}, you could use the command:</translate> | ||
sudo mkswap /dev/sda3 | sudo mkswap /dev/sda3 | ||
<translate>Next we need to enable the swap partition with the {{ic|swapon}} command. Following our example above this could be done with:</translate> | <translate><!--T:37--> Next we need to enable the swap partition with the {{ic|swapon}} command. Following our example above this could be done with:</translate> | ||
sudo swapon /dev/sda3 | sudo swapon /dev/sda3 | ||
<translate>In order to ensure that the swap is enabled at boot we can add an entry to {{ic|/etc/fstab}}. It is best to use the UUID instead of the device name for this purpose. You can add the line to fstab manually or using the command:</translate> | <translate><!--T:38--> In order to ensure that the swap is enabled at boot we can add an entry to {{ic|/etc/fstab}}. It is best to use the UUID instead of the device name for this purpose. You can add the line to fstab manually or using the command:</translate> | ||
sudo bash -c "echo UUID=$(lsblk -no UUID /dev/sda3) none swap defaults 0 0 >> /etc/fstab" | sudo bash -c "echo UUID=$(lsblk -no UUID /dev/sda3) none swap defaults 0 0 >> /etc/fstab" | ||
Line 114: | Line 121: | ||
{{tip|''If you're using a HDD'' (spinning rust) put the swap partition *at the beginning of the disk* as the speed of the disk is higher on the inside tracks. On an SSD this doesn't matter.}} | {{tip|''If you're using a HDD'' (spinning rust) put the swap partition *at the beginning of the disk* as the speed of the disk is higher on the inside tracks. On an SSD this doesn't matter.}} | ||
<translate> | <translate> | ||
=Using a Swapfile= | =Using a Swapfile= <!--T:39--> | ||
<!--T:40--> | |||
Using a swap partition has one major disadvantage: Changing the size of swap or adding swap requires repartitioning the disk. In current Linux kernels, it is possible to use a swap file instead of a dedicated partition and as from kernel 2.6 onwards there is no performance difference any more between the two.</translate> | Using a swap partition has one major disadvantage: Changing the size of swap or adding swap requires repartitioning the disk. In current Linux kernels, it is possible to use a swap file instead of a dedicated partition and as from kernel 2.6 onwards there is no performance difference any more between the two.</translate> | ||
<translate> | <translate> | ||
==Creating and Enabling a Static Swapfile== | ==Creating and Enabling a Static Swapfile== <!--T:41--> | ||
</translate> | </translate> | ||
{{tip|<translate>There is no reason you can't have both a swap partition and a swapfile. This is an easy way to add more swap without repartitioning</translate>}} | {{tip|<translate><!--T:42--> There is no reason you can't have both a swap partition and a swapfile. This is an easy way to add more swap without repartitioning</translate>}} | ||
<translate>First create and intialize the file to hold the swap. For example, to create a 4GB swapfile, you could use the command:</translate> | <translate><!--T:43--> First create and intialize the file to hold the swap. For example, to create a 4GB swapfile, you could use the command:</translate> | ||
sudo fallocate -l 4G /swapfile | sudo fallocate -l 4G /swapfile | ||
sudo mkswap /swapfile | sudo mkswap /swapfile | ||
<translate>Set the appropriate permissions on the file. It should be readable and writable only by {{ic|root}}. This can be done with the command:</translate> | <translate><!--T:44--> Set the appropriate permissions on the file. It should be readable and writable only by {{ic|root}}. This can be done with the command:</translate> | ||
sudo chmod u=rw,go= /swapfile | sudo chmod u=rw,go= /swapfile | ||
<translate>Next we need to enable the swapfile with the {{ic|swapon}} command. Following our example above this could be done with:</translate> | <translate><!--T:45--> Next we need to enable the swapfile with the {{ic|swapon}} command. Following our example above this could be done with:</translate> | ||
sudo swapon /swapfile | sudo swapon /swapfile | ||
<translate>In order to ensure that the swap is enabled at boot we can add an entry to {{ic|/etc/fstab}}. You can add the line to ftab manually or using the command:</translate> | <translate><!--T:46--> In order to ensure that the swap is enabled at boot we can add an entry to {{ic|/etc/fstab}}. You can add the line to ftab manually or using the command:</translate> | ||
sudo bash -c "echo /swapfile none swap defaults 0 0 >> /etc/fstab" | sudo bash -c "echo /swapfile none swap defaults 0 0 >> /etc/fstab" | ||
<translate> | <translate> | ||
==Swapfiles on BTRFS== | ==Swapfiles on BTRFS== <!--T:47--> | ||
<!--T:48--> | |||
As of kernel 5.0 and higher, swapfiles are supported on btfrs. They still require some special handling in addition to the above steps.</translate> | As of kernel 5.0 and higher, swapfiles are supported on btfrs. They still require some special handling in addition to the above steps.</translate> | ||
<translate>Prior to running the {{ic|fallocate}} step above, you should run these commands:</translate> | <translate><!--T:49--> Prior to running the {{ic|fallocate}} step above, you should run these commands:</translate> | ||
sudo truncate -s 0 /swapfile | sudo truncate -s 0 /swapfile | ||
sudo chattr +C /swapfile | sudo chattr +C /swapfile | ||
Line 151: | Line 160: | ||
<translate>These commands create an empty swapfile, disable COW for that file and ensure that compression is disabled.</translate> | <translate><!--T:50--> These commands create an empty swapfile, disable COW for that file and ensure that compression is disabled.</translate> | ||
<translate> | <translate> | ||
==Swapfiles on ZFS== | ==Swapfiles on ZFS== <!--T:51--> | ||
<!--T:52--> | |||
zfs doesn't support swapfiles, however you can achieve a similar benefit using a zvol as a swap volume. | zfs doesn't support swapfiles, however you can achieve a similar benefit using a zvol as a swap volume. | ||
<!--T:53--> | |||
Detailed instructions on how to accomplish this can be found in this [<tvar|link>https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-use-a-zvol-as-a-swap-device</> ZoL guide]. | Detailed instructions on how to accomplish this can be found in this [<tvar|link>https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-use-a-zvol-as-a-swap-device</> ZoL guide]. | ||
</translate> | </translate> | ||
<translate> | <translate> | ||
=Automated Swap Management with systemd-swap= | =Automated Swap Management with systemd-swap= <!--T:54--> | ||
</translate> | </translate> | ||
{{note|<translate>Using systemd-swap with on btrfs/zfs or with hibernation support requires special handling beyond the scope of this article</translate>}} | {{note|<translate><!--T:55--> Using systemd-swap with on btrfs/zfs or with hibernation support requires special handling beyond the scope of this article</translate>}} | ||
<translate>It is possible to automatically manage the size of your swapfile using {{ic|systemd-swap}}. It can create swap files dynamically based on memory needs. It is also an easy way to enable/manage [[<tvar|link>#Using_zswap_with_systemd-swap</>|zswap]]</translate> | <translate><!--T:56--> It is possible to automatically manage the size of your swapfile using {{ic|systemd-swap}}. It can create swap files dynamically based on memory needs. It is also an easy way to enable/manage [[<tvar|link>#Using_zswap_with_systemd-swap</>|zswap]]</translate> | ||
<translate> | <translate> | ||
==Installing and Configuring systemd-swap== | ==Installing and Configuring systemd-swap== <!--T:57--> | ||
<!--T:58--> | |||
First, install and enable {{ic|systemd-swap}}</translate> | First, install and enable {{ic|systemd-swap}}</translate> | ||
pamac install systemd-swap | pamac install systemd-swap | ||
Line 176: | Line 188: | ||
<translate>Next enable dynamic swap management by creating a file {{ic|/etc/systemd/swap.conf.d/myswap.conf}} with the following parameters:</translate> | <translate><!--T:59--> Next enable dynamic swap management by creating a file {{ic|/etc/systemd/swap.conf.d/myswap.conf}} with the following parameters:</translate> | ||
zswap_enabled=0 | zswap_enabled=0 | ||
zram_enabled=0 | zram_enabled=0 | ||
Line 182: | Line 194: | ||
<translate>If you would prefer a single command to create this file you could use:</translate> | <translate><!--T:60--> If you would prefer a single command to create this file you could use:</translate> | ||
sudo bash -c 'echo -e "zswap_enabled=0\nzram_enabled=0\nswapfc_enabled=1" > /etc/systemd/swap.conf.d/myswap.conf' | sudo bash -c 'echo -e "zswap_enabled=0\nzram_enabled=0\nswapfc_enabled=1" > /etc/systemd/swap.conf.d/myswap.conf' | ||
<translate> | <translate> | ||
==Remove Other Swap== | ==Remove Other Swap== <!--T:61--> | ||
<!--T:62--> | |||
In order for systemd_swap to be effective you need to remove any traditional swap devices you have.</translate> | In order for systemd_swap to be effective you need to remove any traditional swap devices you have.</translate> | ||
<translate>To display your current swap devices you can use the command {{ic|swapon}}. For example, my test machine displays the following:</translate> | <translate><!--T:63--> To display your current swap devices you can use the command {{ic|swapon}}. For example, my test machine displays the following:</translate> | ||
swapon | swapon | ||
NAME TYPE SIZE USED PRIO | NAME TYPE SIZE USED PRIO | ||
Line 198: | Line 211: | ||
<translate>In this example there are two swap devices. A swapfile and a swap partition. To turn them off we can use the command {{ic|swapoff}}.</translate> | <translate><!--T:64--> In this example there are two swap devices. A swapfile and a swap partition. To turn them off we can use the command {{ic|swapoff}}.</translate> | ||
sudo swapoff /swapfile | sudo swapoff /swapfile | ||
sudo swapoff /dev/sda3 | sudo swapoff /dev/sda3 | ||
<translate>Next we need to remove them. | <translate><!--T:65--> | ||
Next we need to remove them. | |||
The swap partition will need to be deleted using your favorite partitioning tool. You can remove the swapfile by simply deleting it.</translate> | The swap partition will need to be deleted using your favorite partitioning tool. You can remove the swapfile by simply deleting it.</translate> | ||
sudo rm /swapfile | sudo rm /swapfile | ||
<translate>We need to also remove any lines related to swap from {{ic|/etc/fstab}}. Edit the file with an [[<tvar|link>Special:MyLanguage/Viewing_and_editing_configuration_files</>|appropriate text editor]] and remove or comment out the lines for the swap space. In the example above, we would remove these lines:</translate> | <translate><!--T:66--> We need to also remove any lines related to swap from {{ic|/etc/fstab}}. Edit the file with an [[<tvar|link>Special:MyLanguage/Viewing_and_editing_configuration_files</>|appropriate text editor]] and remove or comment out the lines for the swap space. In the example above, we would remove these lines:</translate> | ||
UUID=c2430cf1-8ea9-4422-a5c5-5a38779194c3 swap swap defaults,noatime 0 2 | UUID=c2430cf1-8ea9-4422-a5c5-5a38779194c3 swap swap defaults,noatime 0 2 | ||
/swapfile none swap defaults 0 0 | /swapfile none swap defaults 0 0 | ||
<translate>Next reboot. After the reboot you should see something similiar to the following when running {{ic|swapon}}</translate> | <translate><!--T:67--> Next reboot. After the reboot you should see something similiar to the following when running {{ic|swapon}}</translate> | ||
NAME TYPE SIZE USED PRIO | NAME TYPE SIZE USED PRIO | ||
/var/lib/systemd-swap/swapfc/1 file 512M 0B -2 | /var/lib/systemd-swap/swapfc/1 file 512M 0B -2 | ||
<translate>systemd-swap will add and remove swapfiles as your memory usage dictates.</translate> | <translate><!--T:68--> systemd-swap will add and remove swapfiles as your memory usage dictates.</translate> | ||
{{note|<translate>If you don't delete your existing swap partition it will be automatically activated by systemd even though you have removed it from fstab</translate>}} | {{note|<translate><!--T:69--> If you don't delete your existing swap partition it will be automatically activated by systemd even though you have removed it from fstab</translate>}} | ||
<translate> | <translate> | ||
==Using zswap with systemd-swap== | ==Using zswap with systemd-swap== <!--T:70--> | ||
<!--T:71--> | |||
zswap is compressed swap kept in RAM. zswap keeps the most frequently used pages in RAM and writes less frequently used pages to the swap space on disk. In many workloads, this will result in increased swap performance and less wear and tear on SSDs. | zswap is compressed swap kept in RAM. zswap keeps the most frequently used pages in RAM and writes less frequently used pages to the swap space on disk. In many workloads, this will result in increased swap performance and less wear and tear on SSDs. | ||
<!--T:72--> | |||
To enable zswap with systemd-swap, simply alter the instructions above and set {{ic|zswap_enabled to 1}}</translate> | To enable zswap with systemd-swap, simply alter the instructions above and set {{ic|zswap_enabled to 1}}</translate> | ||
<translate> | <translate> | ||
=Tuning & Performance Considerations= | =Tuning & Performance Considerations= <!--T:73--> | ||
<!--T:74--> | |||
Although swap seems like a great way to expand memory, excessive swap use will cause severe performance degradation, as mentioned before.</translate> | Although swap seems like a great way to expand memory, excessive swap use will cause severe performance degradation, as mentioned before.</translate> | ||
<translate>There are couple of parameters that can be used to tune swap utilization. These are swappiness and vfs_cache_pressure. To see your current settings for these you can use the following commands:</translate> | <translate><!--T:75--> There are couple of parameters that can be used to tune swap utilization. These are swappiness and vfs_cache_pressure. To see your current settings for these you can use the following commands:</translate> | ||
cat /proc/sys/vm/swappiness | cat /proc/sys/vm/swappiness | ||
cat /proc/sys/vm/vfs_cache_pressure | cat /proc/sys/vm/vfs_cache_pressure | ||
<translate>{{ic|swappiness}} controls how likely a page is to be transferred to swap. This value represents the percentage of the free memory before activating swap. The lower the value, the less swapping is used and the more memory pages are kept in physical memory where:</translate> | <translate><!--T:76--> {{ic|swappiness}} controls how likely a page is to be transferred to swap. This value represents the percentage of the free memory before activating swap. The lower the value, the less swapping is used and the more memory pages are kept in physical memory where:</translate> | ||
* <translate>0 disables swap</translate> | * <translate><!--T:77--> 0 disables swap</translate> | ||
* <translate>60 is the default value which is ideal for a server running a lot of services</translate> | * <translate><!--T:78--> 60 is the default value which is ideal for a server running a lot of services</translate> | ||
* <translate>100 is very aggressive swapping.</translate> | * <translate><!--T:79--> 100 is very aggressive swapping.</translate> | ||
<translate>For ''most'' desktops/laptops the recommended value is 10: Theoretically, this means to only start swapping when RAM usage reaches around 90 percent.</translate> | <translate><!--T:80--> For ''most'' desktops/laptops the recommended value is 10: Theoretically, this means to only start swapping when RAM usage reaches around 90 percent.</translate> | ||
<translate>{{ic|vfs_cache_pressure}} is a percentage value that controls the tendency of the kernel to *reclaim* the memory which is used for caching of directory and inode objects. The default value is 100.</translate> <translate>Increasing this value will increase the rate in which these objects are removed from the RAM cache. Decreasing it will allow these objects to be cached in memory longer, consuming additional RAM over time.</translate> <translate>Depending on your specific workload, increasing or decreasing this value too far can have significant negative impacts on system performance.</translate> <translate>Experimentation is needed to find the appropriate balance and the default value is reasonable. In general, it is more common to optimize swappiness before experimenting with vfs_cache_pressure.</translate> | <translate><!--T:81--> {{ic|vfs_cache_pressure}} is a percentage value that controls the tendency of the kernel to *reclaim* the memory which is used for caching of directory and inode objects. The default value is 100.</translate> <translate><!--T:82--> Increasing this value will increase the rate in which these objects are removed from the RAM cache. Decreasing it will allow these objects to be cached in memory longer, consuming additional RAM over time.</translate> <translate><!--T:83--> Depending on your specific workload, increasing or decreasing this value too far can have significant negative impacts on system performance.</translate> <translate><!--T:84--> Experimentation is needed to find the appropriate balance and the default value is reasonable. In general, it is more common to optimize swappiness before experimenting with vfs_cache_pressure.</translate> | ||
<translate>To set these values you can use the command {{ic|sysctl}}. For example, to set the swappiness value to 10 you could use:</translate> | <translate><!--T:85--> To set these values you can use the command {{ic|sysctl}}. For example, to set the swappiness value to 10 you could use:</translate> | ||
sudo sysctl vm.swappiness=10 | sudo sysctl vm.swappiness=10 | ||
'''<translate>There is no preset defined answer on the optimal values for these parameters.</translate>''' <translate>Experimentation is needed to find the optimum configuration for your specific hardware and workload.</translate> | '''<translate><!--T:86--> There is no preset defined answer on the optimal values for these parameters.</translate>''' <translate><!--T:87--> Experimentation is needed to find the optimum configuration for your specific hardware and workload.</translate> | ||
<translate> | <translate> | ||
=See Also= | =See Also= <!--T:88--> | ||
</translate> | </translate> | ||
* <translate>The Arch Wiki page on [<tvar|link>https://wiki.archlinux.org/index.php/Swap</> swap]</translate> | * <translate><!--T:89--> The Arch Wiki page on [<tvar|link>https://wiki.archlinux.org/index.php/Swap</> swap]</translate> | ||
* <translate>The Arch Wiki page on [<tvar|link>https://wiki.archlinux.org/index.php/Zswap</> zswap]</translate> | * <translate><!--T:90--> The Arch Wiki page on [<tvar|link>https://wiki.archlinux.org/index.php/Zswap</> zswap]</translate> | ||
* <translate>The Linux kernel documentation on [<tvar|link>https://www.kernel.org/doc/Documentation/vm/zswap.txt</> zswap]</translate> | * <translate><!--T:91--> The Linux kernel documentation on [<tvar|link>https://www.kernel.org/doc/Documentation/vm/zswap.txt</> zswap]</translate> | ||
* <translate>The Linux kernel documentation on [<tvar|link>https://www.kernel.org/doc/Documentation/sysctl/vm.txt</> swappiness and vfs_cache_pressure]</translate> | * <translate><!--T:92--> The Linux kernel documentation on [<tvar|link>https://www.kernel.org/doc/Documentation/sysctl/vm.txt</> swappiness and vfs_cache_pressure]</translate> | ||
* <translate>The opensuse guide to [<tvar|link>https://doc.opensuse.org/documentation/leap/tuning/html/book.sle.tuning/cha.tuning.memory.html</> tuning memory]</translate> | * <translate><!--T:93--> The opensuse guide to [<tvar|link>https://doc.opensuse.org/documentation/leap/tuning/html/book.sle.tuning/cha.tuning.memory.html</> tuning memory]</translate> | ||
* <translate>The [<tvar|link>https://github.com/Nefelim4ag/systemd-swap</> systemd-swap page]</translate> | * <translate><!--T:94--> The [<tvar|link>https://github.com/Nefelim4ag/systemd-swap</> systemd-swap page]</translate> | ||
* <translate>The ZFS on Linux guide on [<tvar|link>https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-use-a-zvol-as-a-swap-device</> Swap Volumes]</translate> | * <translate><!--T:95--> The ZFS on Linux guide on [<tvar|link>https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-use-a-zvol-as-a-swap-device</> Swap Volumes]</translate> | ||
[[Category:Contents Page]] | [[Category:Contents Page]] |