Difference between revisions of "Swap/de"

4,681 bytes removed ,  9 months ago
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 196: Line 196:
<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Detailed instructions on how to accomplish this can be found in this [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 [https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-use-a-zvol-as-a-swap-device ZoL guide].
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
=Automated Swap Management with systemd-swap=
</div>
{{note|<span lang="en" dir="ltr" class="mw-content-ltr">Using systemd-swap with on btrfs/zfs or with hibernation support requires special handling beyond the scope of this article</span>}}
<span lang="en" dir="ltr" class="mw-content-ltr">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 [[#Using_zswap_with_systemd-swap|zswap]]</span>
<div lang="en" dir="ltr" class="mw-content-ltr">
==Installing and Configuring systemd-swap==
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
First, install and enable {{ic|systemd-swap}}:
</div>
pamac install systemd-swap
sudo systemctl enable systemd-swap.service
<span lang="en" dir="ltr" class="mw-content-ltr">Next enable dynamic swap management by creating a file {{ic|/etc/systemd/swap.conf.d/myswap.conf}} with the following parameters:</span>
zswap_enabled=0
zram_enabled=0
swapfc_enabled=1
<span lang="en" dir="ltr" class="mw-content-ltr">If you would prefer a single command to create this file you could use:</span>
sudo bash -c 'echo -e "zswap_enabled=0\nzram_enabled=0\nswapfc_enabled=1" > /etc/systemd/swap.conf.d/myswap.conf'
<div lang="en" dir="ltr" class="mw-content-ltr">
==Remove Other Swap==
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
In order for systemd-swap to be effective you need to remove any traditional swap devices you have.
</div>
<span lang="en" dir="ltr" class="mw-content-ltr">To display your current swap devices you can use the command {{ic|swapon}}.  For example, my test machine displays the following:</span>
swapon
NAME      TYPE      SIZE USED PRIO
/swapfile file        4G  0B  -2
/dev/sda3 partition 8.4G  0B  -3
<span lang="en" dir="ltr" class="mw-content-ltr">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}}.</span>
sudo swapoff /swapfile
sudo swapoff /dev/sda3
<div lang="en" dir="ltr" class="mw-content-ltr">
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.
</div>
sudo rm /swapfile
<span lang="en" dir="ltr" class="mw-content-ltr">We need to also remove any lines related to swap from {{ic|/etc/fstab}}.  Edit the file with an [[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:</span>
UUID=c2430cf1-8ea9-4422-a5c5-5a38779194c3 swap          swap    defaults,noatime 0 2
/swapfile none swap defaults 0 0
<div lang="en" dir="ltr" class="mw-content-ltr">
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
</div>
<span lang="en" dir="ltr" class="mw-content-ltr">Next reboot.  After the reboot, when running {{ic|swapon}} you should see something similiar to the following:</span>
NAME                          TYPE SIZE USED PRIO
/var/lib/systemd-swap/swapfc/1 file 512M  0B  -2
<span lang="en" dir="ltr" class="mw-content-ltr">systemd-swap will add and remove swapfiles as your memory usage dictates.</span>
{{note|<span lang="en" dir="ltr" class="mw-content-ltr">If you don't delete your existing swap partition it will be automatically activated by systemd even though you have removed it from fstab</span>}}
<div lang="en" dir="ltr" class="mw-content-ltr">
==Using zswap with systemd-swap==
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
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.
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
To enable zswap with systemd-swap, simply alter the instructions above and set Linux Kernel parameter  zswap_enabled=1
</div>
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 323: Line 232:
* <span lang="en" dir="ltr" class="mw-content-ltr">The Linux kernel documentation on [https://www.kernel.org/doc/Documentation/vm/zswap.txt zswap]</span>
* <span lang="en" dir="ltr" class="mw-content-ltr">The Linux kernel documentation on [https://www.kernel.org/doc/Documentation/vm/zswap.txt zswap]</span>
* <span lang="en" dir="ltr" class="mw-content-ltr">The Linux kernel documentation on [https://www.kernel.org/doc/Documentation/sysctl/vm.txt swappiness and vfs_cache_pressure]</span>
* <span lang="en" dir="ltr" class="mw-content-ltr">The Linux kernel documentation on [https://www.kernel.org/doc/Documentation/sysctl/vm.txt swappiness and vfs_cache_pressure]</span>
* <span lang="en" dir="ltr" class="mw-content-ltr">The [https://github.com/Nefelim4ag/systemd-swap systemd-swap page]</span>
* <span lang="en" dir="ltr" class="mw-content-ltr">The ZFS on Linux guide on [https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-use-a-zvol-as-a-swap-device Swap Volumes]</span>
* <span lang="en" dir="ltr" class="mw-content-ltr">The ZFS on Linux guide on [https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-use-a-zvol-as-a-swap-device Swap Volumes]</span>




[[Category:Contents Page{{#translation:}}]]
[[Category:Contents Page{{#translation:}}]]
8,138

edits