124
120

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

1分でできる!AmazonEC2のmicroインスタンスでswap領域を作る

Last updated at Posted at 2013-05-31

microインスタンスではデフォルトでswap領域が存在しないので自分で作る必要があります。
1分でできるのでさくっとやっちゃいましょう。

1GBのswap領域を作成する方法

rootで、

dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile

サーバ起動時に自動マウントされるように、/etc/fstab に以下を追記

/etc/fstab
/swapfile swap swap defaults 0 0

自動マウント確認のためにサーバを再起動

結果確認

topコマンドを叩いて下記のようにSwap: 1048568k totalと表示されていれば成功です!

top - 14:11:40 up 3 min,  1 user,  load average: 0.07, 0.04, 0.00
Tasks:  76 total,   1 running,  75 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    604944k total,   204632k used,   400312k free,    10228k buffers
Swap:  1048568k total,        0k used,  1048568k free,    90488k cached
124
120
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
124
120

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?