$

Ubuntu22.04にSwapfileを追加する

これも毎回忘れる。クソボケ。

設定確認

$ sudo swapon --show

あれば表示。そこになければないですね。

お前を消す方法

$ sudo swapoff /swap.img

もしあれば一時的に無効にする
同名で作り直すならファイル削除してから下記手順を継続

作成

$ sudo fallocate -l 16G /swap.img

一般的に積んでるメモリの倍がよいと言われている。今回は8GBの倍で設定

設定

$ chmod 600 /swap.img
$ sudo mkswap /swap.img
$ sudo swapon /swap.img
$ sudo swapon --show

設定できたらなんか表示されるはず

永続化

$ sudo vim /etc/fstab
/swapfile none swap sw 0 0

上記を追記。これやらんといちいち再起動のたびにswaponが必要になる。

Privacy Policy

This website uses Google Analytics to collect traffic information for site improvement. Google Analytics may use cookies and similar technologies to measure page views and usage patterns.

By continuing to use this site, you acknowledge that your site usage may be recorded for analytics purposes.

Disclaimer

The content published on this website is based on publicly accessible information available on the Internet and other open sources, and represents the author's personal views. Paid training materials, non-public materials, and similar sources are not used as information sources.

The content of this website does not represent the views, policies, or positions of any organization, group, company, or other third party with which the author is affiliated or has a relationship.

No warranty is made as to the accuracy, completeness, or usefulness of the information on this website. The author assumes no responsibility for any damages arising from the use of, or inability to use, the content of this website.