両方とも前のリビジョン 前のリビジョン | |
linux:fedora:extend_zram_swap [2025/10/02 04:42] – [ZRAM スワップの構成を確認] ともやん | linux:fedora:extend_zram_swap [2025/10/03 05:57] (現在) – [ZRAM スワップの設定変更] ともやん |
---|
<WRAP color_term> | <WRAP color_term> |
<WRAP color_command><html><pre> | <WRAP color_command><html><pre> |
<b class=GRN>$</b> <b class=HIY>sudo</b> nano /usr/lib/systemd/zram-generator.conf | <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">nano</font> <u style="text-decoration-style:solid">/usr/lib/systemd/zram-generator.conf</u> |
</pre></html></WRAP> | |
<WRAP color_result><html><pre> | |
</pre></html></WRAP> | </pre></html></WRAP> |
</WRAP> | </WRAP> |
そして、使用可能メモリー容量の 1 倍の設定です。\\ | そして、使用可能メモリー容量の 1 倍の設定です。\\ |
<WRAP color_term> | <WRAP color_term> |
<WRAP color_mincode><code autoconf /usr/lib/systemd/zram-generator.conf> | <WRAP color_mincode><html><pre> |
# This config file enables a /dev/zram0 device with the default settings: | <font color="#839496"> 1</font> <font color="#75715E"># This config file enables a /dev/zram0 device with the default settings:</font> |
# — size — same as available RAM or 8GB, whichever is less | <font color="#839496"> 2</font> <font color="#75715E"># — size — same as available RAM or 8GB, whichever is less</font> |
# — compression — most likely lzo-rle | <font color="#839496"> 3</font> <font color="#75715E"># — compression — most likely lzo-rle</font> |
# | <font color="#839496"> 4</font> <font color="#75715E">#</font> |
# To disable, uninstall zram-generator-defaults or create empty | <font color="#839496"> 5</font> <font color="#75715E"># To disable, uninstall zram-generator-defaults or create empty</font> |
# /etc/systemd/zram-generator.conf file. | <font color="#839496"> 6</font> <font color="#75715E"># /etc/systemd/zram-generator.conf file.</font> |
[zram0] | <font color="#839496"> 7</font> <font color="#F8F8F2">[</font><font color="#A6E22E">zram0</font><font color="#F8F8F2">]</font> |
zram-size = min(ram, 8192) | <font color="#839496"> 8</font> <font color="#F92672">zram-size</font><font color="#F8F8F2"> = </font><font color="#E6DB74">min(ram, 8192)</font> |
</code></WRAP> | </pre></html></WRAP> |
</WRAP> | </WRAP> |
| |
物理メモリー容量を超えてスワップした場合に、メモリー圧縮しながら更にディスクスワップするので、最悪の場合マシンにログイン不能なほどパフォーマンスが劇的に悪化する😱\\ | 物理メモリー容量を超えてスワップした場合に、メモリー圧縮しながら更にディスクスワップするので、最悪の場合マシンにログイン不能なほどパフォーマンスが劇的に悪化する😱\\ |
<WRAP color_term> | <WRAP color_term> |
<WRAP color_mincode><code autoconf /usr/lib/systemd/zram-generator.conf> | <WRAP color_mincode><html><pre> |
[zram0] | <font color="#839496"> 1</font> <font color="#75715E"># This config file enables a /dev/zram0 device with the default settings:</font> |
#zram-size = min(ram, 8192) | <font color="#839496"> 2</font> <font color="#75715E"># — size — same as available RAM or 8GB, whichever is less</font> |
zram-fraction = 3.0 | <font color="#839496"> 3</font> <font color="#75715E"># — compression — most likely lzo-rle</font> |
max-zram-size = 8192 | <font color="#839496"> 4</font> <font color="#75715E">#</font> |
</code></WRAP> | <font color="#839496"> 5</font> <font color="#75715E"># To disable, uninstall zram-generator-defaults or create empty</font> |
| <font color="#839496"> 6</font> <font color="#75715E"># /etc/systemd/zram-generator.conf file.</font> |
| <font color="#839496"> 7</font> <font color="#F8F8F2">[</font><font color="#A6E22E">zram0</font><font color="#F8F8F2">]</font> |
| <font color="#839496"> 8</font> <font color="#75715E">#zram-size = min(ram, 8192)</font> |
| <font color="#839496"> 9</font> <font color="#F92672">zram-fraction</font><font color="#F8F8F2"> = </font><font color="#E6DB74">3.0</font> |
| <font color="#839496"> 10</font> <font color="#F92672">max-zram-size</font><font color="#F8F8F2"> = </font><font color="#E6DB74">8192</font> |
| </pre></html></WRAP> |
</WRAP> | </WRAP> |
| |
ZRAM スワップの設定は標準のままにする。\\ | ZRAM スワップの設定は標準のままにする。\\ |
<WRAP color_term> | <WRAP color_term> |
<WRAP color_mincode><code autoconf /usr/lib/systemd/zram-generator.conf> | <WRAP color_mincode><html><pre> |
[zram0] | <font color="#839496"> 1</font> <font color="#75715E"># This config file enables a /dev/zram0 device with the default settings:</font> |
zram-size = min(ram, 8192) | <font color="#839496"> 2</font> <font color="#75715E"># — size — same as available RAM or 8GB, whichever is less</font> |
</code></WRAP> | <font color="#839496"> 3</font> <font color="#75715E"># — compression — most likely lzo-rle</font> |
| <font color="#839496"> 4</font> <font color="#75715E">#</font> |
| <font color="#839496"> 5</font> <font color="#75715E"># To disable, uninstall zram-generator-defaults or create empty</font> |
| <font color="#839496"> 6</font> <font color="#75715E"># /etc/systemd/zram-generator.conf file.</font> |
| <font color="#839496"> 7</font> <font color="#F8F8F2">[</font><font color="#A6E22E">zram0</font><font color="#F8F8F2">]</font> |
| <font color="#839496"> 8</font> <font color="#F92672">zram-size</font><font color="#F8F8F2"> = </font><font color="#E6DB74">min(ram, 8192)</font> |
| </pre></html></WRAP> |
</WRAP> | </WRAP> |
| |
<WRAP color_term> | <WRAP color_term> |
<WRAP color_command><html><pre> | <WRAP color_command><html><pre> |
<b class=GRN>$</b> <b class=HIY>sudo</b> truncate -s 0 /var/swap | <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">truncate</font> <font color="#A347BA">-s</font> 0 /var/swap |
<b class=GRN>$</b> <b class=HIY>sudo</b> chattr +C /var/swap | <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">chattr</font> +C <u style="text-decoration-style:solid">/var/swap</u> |
<b class=GRN>$</b> <b class=HIY>sudo</b> fallocate -l 3072M /var/swap | <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">fallocate</font> <font color="#A347BA">-l</font> 3072M <u style="text-decoration-style:solid">/var/swap</u> |
<b class=GRN>$</b> <b class=HIY>sudo</b> lsattr /var/swap | <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">lsattr</font> <u style="text-decoration-style:solid">/var/swap</u> |
</pre></html></WRAP> | </pre></html></WRAP> |
<WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
---------------C------ /var/swap | ---------------C------ /var/swap |
| </pre></html></WRAP> |
| <WRAP color_command><html><pre> |
| <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">chmod</font> 600 <u style="text-decoration-style:solid">/var/swap</u> |
</pre></html></WRAP> | </pre></html></WRAP> |
| |
<WRAP color_command><html><pre> | <WRAP color_command><html><pre> |
<b class=GRN>$</b> <b class=HIY>sudo</b> mkswap /var/swap | <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">mkswap</font> <u style="text-decoration-style:solid">/var/swap</u> |
</pre></html></WRAP> | </pre></html></WRAP> |
<WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
スワップ空間バージョン 1 を設定します。サイズ = 3 GiB (3221221376 バイト) | Setting up swapspace version 1, size = 3 GiB (3221221376 bytes) |
ラベルはありません, UUID=c15d187b-3a3b-4b6c-8eb3-fce516ba5121 | no label, UUID=d79c6784-7da2-480d-b0bf-4985d2d8aea1 |
</pre></html></WRAP> | </pre></html></WRAP> |
| |
<WRAP color_command><html><pre> | <WRAP color_command><html><pre> |
<b class=GRN>$</b> <b class=HIY>sudo</b> swapon -v /var/swap | <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">swapon</font> <font color="#A347BA">-v</font> <u style="text-decoration-style:solid">/var/swap</u> |
</pre></html></WRAP> | </pre></html></WRAP> |
<WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
swapon: /var/swap: 署名が見つかりました: [ページサイズ=4096, 署名=swap] | swapon: /var/swap: found signature [pagesize=4096, signature=swap] |
swapon: /var/swap: ページサイズ=4096, スワップサイズ=3221225472, デバイスサイズ=3221225472 | swapon: /var/swap: pagesize=4096, swapsize=3221225472, devsize=3221225472 |
スワップ /var/swap を有効化しています | swapon /var/swap |
</pre></html></WRAP> | </pre></html></WRAP> |
| |
<WRAP color_command><html><pre> | <WRAP color_command><html><pre> |
<b class=GRN>$</b> <b class=HIY>echo</b> '/var/swap none swap sw 0 0' | sudo tee -a /etc/fstab | <font color="#0087FF"><b>$</b></font> <font color="#26A269">echo</font> <font color="#A2734C">'/var/swap none swap sw 0 0'</font> <font color="#12488B"><b>|</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">tee</font> <font color="#A347BA">-a</font> <u style="text-decoration-style:solid">/etc/fstab</u> |
</pre></html></WRAP> | </pre></html></WRAP> |
<WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
<WRAP color_term> | <WRAP color_term> |
<WRAP color_command><html><pre> | <WRAP color_command><html><pre> |
<b class=GRN>$</b> <b class=HIY>systemctl</b> | grep systemd-zram | <font color="#0087FF"><b>$</b></font> <font color="#26A269">systemctl</font> <font color="#12488B"><b>|</b></font> <font color="#26A269">grep</font> systemd-zram |
</pre></html></WRAP> | </pre></html></WRAP> |
<WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
systemd-zram-setup@zram0.service loaded active exited Create swap on /dev/zram0 | <font color="#C01C28"><b>systemd-zram</b></font>-setup@zram0.service loaded active exited Create swap on /dev/zram0 |
system-systemd\x2dzram\x2dsetup.slice loaded active active Slice /system/systemd-zram-setup | system-systemd\x2dzram\x2dsetup.slice loaded active active Slice /system/<font color="#C01C28"><b>systemd-zram</b></font>-setup |
</pre></html></WRAP> | </pre></html></WRAP> |
</WRAP> | </WRAP> |
<WRAP color_term> | <WRAP color_term> |
<WRAP color_command><html><pre> | <WRAP color_command><html><pre> |
<b class=GRN>$</b> <b class=HIY>sudo</b> systemctl restart systemd-zram-setup@zram0 | <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> restart systemd-zram-setup@zram0 |
</pre></html></WRAP> | |
<WRAP color_result><html><pre> | |
</pre></html></WRAP> | </pre></html></WRAP> |
</WRAP> | </WRAP> |