LoginSignup
0
0

More than 1 year has passed since last update.

一時的なswapのつくりかたおさらい

Posted at

概要

GCE e2-microみたいなメモリが少ない環境でswapを作成する。
Ansible流してって言われたときにあまりにスペックが低すぎてメモリが足りずに踏み台サーバが壊れたのでやむ無しにswapを作って流した。
最近swapなんて使うことがないので、すっかり忘れていた。

参考: https://centos.bungu-do.jp/archives/65

作業

# dd if=/dev/zero of=/mnt/swapfile bs=1M count=2048
2048+0 records in
2048+0 records out
# mkswap /mnt/swapfile
mkswap: /mnt/swapfile: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=7d4c9699-a66c-4d84-9cac-d38b71cb4f5c
# chmod 600 /mnt/swapfile
# swapon /mnt/swapfile
# swapon -s
Filename				Type		Size	Used	Priority
/mnt/swapfile                          	file    	2097148	0	-2
# echo '/mnt/swapfile swap swap defaults,nofail 0 0' >> /etc/fstab
$ sudo reboot
$ free -mh
              total        used        free      shared  buff/cache   available
Mem:          708Mi       252Mi       198Mi       4.0Mi       257Mi       347Mi
Swap:         2.0Gi          0B       2.0Gi

最後に

素直に一時的にサーバスペックを高いものにして流すとかしましょう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0