Difference between revisions of "Swap"

3,424 bytes removed ,  1 year ago
Removed instructions on hybrid swap with systemd-swap and zswap
(Removed section on systemd-swap.)
(Removed instructions on hybrid swap with systemd-swap and zswap)
Line 199: Line 199:
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>
=Automated Swap Management with systemd-swap= <!--T:54-->
</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><!--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>
==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>
<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
NAME      TYPE      SIZE USED PRIO
/swapfile file        4G  0B  -2
/dev/sda3 partition 8.4G  0B  -3
<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 /dev/sda3
<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>
sudo rm /swapfile
<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
/swapfile none swap defaults 0 0
<translate><!--T:100-->
With hibernation configured it will also be necessary to edit {{ic|/etc/default/grub}}. Find and remove option {{ic|<nowiki>resume=UUID=...</nowiki>}} or replace the UUID with a new proper value.  In the example above, we would remove this text:
resume=UUID=c2430cf1-8ea9-4422-a5c5-5a38779194c3
Then run:
sudo update-grub
If removing hibernation entirely then also delete {{ic|resume}} from the {{ic|HOOKS}} line in {{ic|/etc/mkinitcpio.conf}} and run:
sudo mkinitcpio -P
</translate>
<translate><!--T:67--> Next reboot.  After the reboot, when running {{ic|swapon}} you should see something similiar to the following:</translate>
NAME                          TYPE SIZE USED PRIO
/var/lib/systemd-swap/swapfc/1 file 512M  0B  -2
<translate><!--T:68--> systemd-swap will add and remove swapfiles as your memory usage dictates.</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>
==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.
<!--T:72-->
To enable zswap with systemd-swap, simply alter the instructions above and set Linux Kernel parameter  zswap_enabled=1</translate>
<translate>
<translate>
=Tuning & Performance Considerations= <!--T:73-->
=Tuning & Performance Considerations= <!--T:73-->
Moderators, translator
455

edits