Difference between revisions of "Swap/en"

Updating to match new version of source page
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 16: Line 16:




This article tries to be as comprehensive as possible but even more information can be found in the [[Special:MyLanguage/#See_Also|articles linked below]]
This article tries to be as comprehensive as possible but even more information can be found in the [[Swap#See_Also|articles linked below]]
=Do I Need Swap=
=Do I Need Swap=


Line 32: Line 32:
* 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.
* 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.


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!
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 than 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!


Taking into account all of the above, this brings us to the following table:
Taking into account all of the above, this brings us to the following table:
Line 75: Line 75:
  if [ "$(whoami)" = 'root' ]; then
  if [ "$(whoami)" = 'root' ]; then
   dmesg | grep "zswap:" | grep --silent "load"
   dmesg | grep "zswap:" | grep --silent "load"
   if [[ $? -eq 0 ]]; then
   if [ $? -eq 0 ]; then
     # zswap is active
     # zswap is active
     echo "zswap information:"
     echo "zswap information:"
Line 94: Line 94:
==Creating and Enabling a Swap Partition==
==Creating and Enabling a Swap Partition==


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 [[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 {{ic|linuxswap}}.
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 [[#Using_a_Swapfile|#Using_a_Swapfile]]. A swap partition can be created in any disk management / partition management tool and should be set as type {{ic|linuxswap}}.


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:
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:
Line 109: Line 109:
{{note|Be sure to replace /dev/sda3 in the above commands with your actual swap partition.}}
{{note|Be sure to replace /dev/sda3 in the above commands with your actual swap partition.}}
{{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.}}
=Using a Swapfile=
=Using a Swapfile=


Line 143: Line 144:
As of kernel 5.0 and higher, swapfiles are supported on btfrs.  They still require some special handling in addition to the above steps.
As of kernel 5.0 and higher, swapfiles are supported on btfrs.  They still require some special handling in addition to the above steps.


Prior to running the {{ic|fallocate}} step above, you should run these commands:
Prior to running the {{ic|dd}} step above, you should run these commands:
  sudo truncate -s 0 /swapfile
  sudo truncate -s 0 /swapfile
  sudo chattr +C /swapfile
  sudo chattr +C /swapfile
Line 214: Line 215:
Then run:
Then run:
  sudo update-grub
  sudo update-grub
If removing hibernation entirely then also delete {{ic|resume}} from the {{ic|HOOKS}} line in {{ic|/etc/mkinitpcio.conf}} and run:
If removing hibernation entirely then also delete {{ic|resume}} from the {{ic|HOOKS}} line in {{ic|/etc/mkinitcpio.conf}} and run:
  sudo mkinitpcio -P
  sudo mkinitcpio -P




8,560

edits