<?xml version="1.0" encoding="ISO-8859-15"?>
<rss version="2.0"><channel>
<title>configuring on-disk swap for fedora 33</title>
<link>http://sange.fi/~atehwa/cgi-bin/piki.cgi/</link>
<description>Recent changes in configuring on-disk swap for fedora 33</description>
<item><title>configuring on-disk swap for fedora 33</title>
<link>http://sange.fi/~atehwa/cgi-bin/piki.cgi/configuring%20on-disk%20swap%20for%20fedora%2033</link>
<guid>http://sange.fi/~atehwa/cgi-bin/piki.cgi/#1618213777</guid>
<description>&lt;p&gt;&lt;ins&gt;!!! Background&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;Fedora 33 doesn't use on-disk swap by default. Instead, it 
configures a zram device to compress memory when it's low (see 
https://fedoraproject.org/wiki/Changes/SwapOnZRAM). I find this very 
questionable.&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;!!! Why?&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;Because for me the point of swap was never to extend the memory 
for an actively used memory workload. The point of swap is to have a 
place where to store memory that is not actually actively used - to 
avoid worrying whether you're filling your memory with all those 
processes that just sit there (and /tmp, also). Having everything in 
RAM means that all that crap doesn't have anywhere to go to. For 
instance, it means that if some stupid program leaves data in your /tmp 
(assuming it's on tmpfs), that data will consume central memory from 
useful stuff until /tmp is cleaned up. "Useful stuff" includes all 
processes that are actively using their memory, but also files (such as 
shared libraries) that are being used a lot and thus are cached in 
memory.&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;You can probably guess that I disagree with the change's 
rationale ("Swap is useful, except when it's slow").&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;I noticed that there's very little documentation available for 
those who would like to use real, disk-based swap on F33. I also 
noticed that while the user can request on-disk swap at installation 
(it's just not there by default), it's configured in a suboptimal way 
(see 
https://www.reddit.com/r/Fedora/comments/jpp7nm/zram_and_swap_partition_
fedora_33/gbj57pg/?utm_source=reddit&amp;utm_medium=web2x&amp;context=3). 
Basically, when you run out of in-memory swap, there's no way to evict 
stuff from that swap to disk swap, so the in-memory swap just sits 
there eating precious memory.&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;!!! How?&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;The easiest way to use on-disk swap is to configure a swapfile. 
I think you will need a swap partition for hibernate and kernel core 
dumps to work, but let's suppose you're not interested in those. F33 
ships with btrfs by default, so you need to do an extra chattr for the 
swapfile.&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;{{{ # SIZE_IN_GB=16 # example, change # touch /swapfile # chmod 
600 /swapfile # chattr +C /swapfile # dd if=/dev/zero of=/swapfile 
bs=1024 count=$(($SIZE_IN_GB * 1024 * 1024)) # mkswap /swapfile # 
swapon /swapfile # systemctl stop swap-create@zram0.service }}}&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;That configures the swap for you temporarily. You can see the 
list of swaps and total swap by:&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;{{{ # swapon # free }}}&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;To make the changes permanent (so that it's done the same way 
in the next boot), you need to:&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;{{{ # echo /swapfile swap swap defaults 0 0 &gt;&gt; /etc/fstab # 
echo -e '[zram0]\nhost-memory-limit=0' &gt; 
/etc/systemd/zram-generator.conf }}}&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;----&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;* [merkintä: 2021-04] * [atehwa] * [kategoria: 
päiväkirjamerkintä] * [kernel dump]&lt;/ins&gt;

</description>
<pubDate>Mon, 12 Apr 2021 07:49:37 +0000</pubDate>
</item>

</channel></rss>
