差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン | |||
linux:fedora:extend_zram_swap [2024/02/04 13:37] – 削除 - 外部編集 (Unknown date) 非ログインユーザー | linux:fedora:extend_zram_swap [2024/02/04 13:37] (現在) – ↷ linux:fedora_extend_zram_swap から linux:fedora:extend_zram_swap へページの移動と名称変更しました。 ともやん | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== Fedora 33 以降で標準になった ZRAM スワップの容量を拡張する ====== | ||
+ | |||
+ | [[wpjp> | ||
+ | |||
+ | ===== ZRAM スワップの構成を確認 ===== | ||
+ | ブロックデバイス zram0 が SWAP としてマウントされている。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | NAME | ||
+ | sr0 | ||
+ | zram0 251:0 0 970M 0 disk [SWAP] | ||
+ | vda 252:0 0 100G 0 disk | ||
+ | ├─vda1 252:1 0 1M 0 part | ||
+ | ├─vda2 252:2 0 | ||
+ | └─vda3 252:3 0 1G 0 part /boot | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | 複数のスワップ領域が存在する場合は、swapon で優先順位なども分かります。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | NAME | ||
+ | /dev/zram0 partition 970M 174M 100 | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ZRAM スワップの利用状況を表示する。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | NAME | ||
+ | /dev/zram0 lzo-rle | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== ZRAM スワップの設定変更 ===== | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | 標準の設定では使用可能な物理メモリー容量または最大 8GB の設定になっている。\\ | ||
+ | そして、使用可能メモリー容量の 1 倍の設定です。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_mincode>< | ||
+ | # This config file enables a /dev/zram0 device with the default settings: | ||
+ | # — size — same as available RAM or 8GB, whichever is less | ||
+ | # — compression — most likely lzo-rle | ||
+ | # | ||
+ | # To disable, uninstall zram-generator-defaults or create empty | ||
+ | # / | ||
+ | [zram0] | ||
+ | zram-size = min(ram, 8192) | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ZRAM スワップの設定を、使用可能な物理メモリー容量の 3 倍に変更する事も可能だが...🤔(< | ||
+ | 物理メモリー容量を超えてスワップした場合に、メモリー圧縮しながら更にディスクスワップするので、最悪の場合マシンにログイン不能なほどパフォーマンスが劇的に悪化する😱\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_mincode>< | ||
+ | [zram0] | ||
+ | #zram-size = min(ram, 8192) | ||
+ | zram-fraction = 3.0 | ||
+ | max-zram-size = 8192 | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ZRAM スワップの設定は標準のままにする。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_mincode>< | ||
+ | [zram0] | ||
+ | zram-size = min(ram, 8192) | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | その代わりに従来のスワップファイルを追加する。\\ | ||
+ | btrfs 上の swap ファイルは nocow(copy on write禁止) フラグを設定して生成する必要がある。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | ---------------C------ /var/swap | ||
+ | </ | ||
+ | |||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | スワップ空間バージョン 1 を設定します。サイズ = 3 GiB (3221221376 バイト) | ||
+ | ラベルはありません, | ||
+ | </ | ||
+ | |||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | swapon: /var/swap: 署名が見つかりました: | ||
+ | swapon: /var/swap: ページサイズ=4096, | ||
+ | スワップ /var/swap を有効化しています | ||
+ | </ | ||
+ | |||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | / | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | サービス名を調べる。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | systemd-zram-setup@zram0.service | ||
+ | system-systemd\x2dzram\x2dsetup.slice | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | サービスを再起動する。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ZRAM スワップ+スワップファイルの容量が増えていることを確認する。(大きい priority が優先される🤔ここでは 1 の zram0 から優先して使われる😻)\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | NAME | ||
+ | /dev/zram0 partition 964M 295.3M | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | NAME | ||
+ | /dev/zram0 lzo-rle | ||
+ | </ | ||
+ | |||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | | ||
+ | Mem: 987588 | ||
+ | Swap: 4132856 | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Linux スワップの優先度について ===== | ||
+ | <WRAP left round tip 80%> | ||
+ | </ | ||
+ | |||
+ | ===== 参考文献 ===== | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[qita> | ||
+ | [[qita> | ||
+ | [[https:// | ||
+ | |||
+ | ==== 付録 ==== | ||
+ | [[tw> | ||
+ | [[tw> | ||
+ | [[tw> | ||