swapの追加

https://www.cloudbooklet.com/how-to-add-swap-space-on-ubuntu-18-04-google-cloud/

メモ:

メモリ2GB未満はメモリの2倍は必要.

確認:

sudo swapon --show

swapfileを作成:

 sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile

swapの管理:

$ sudo mkswap /swapfile
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=afc7d594-7352-4f77-9f0a-aeba9d7fea85

swapの有効化:

sudo swapon /swapfile

swapの有効化の確認:

$ sudo swapon --show
NAME      TYPE SIZE USED PRIO
/swapfile file   2G   0B   -2

$ free -m
              total        used        free      shared  buff/cache   available
Mem:            579         295          47          24         236         168
Swap:          2047           0        2047

/etc/fstabへswapを追加:

/swapfile swap swap defaults 0 0