8
8

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.

ボリュームを拡張できない時のSWAP領域の拡張方法

Last updated at Posted at 2014-10-01

CentOSで物理サーバーを構築してもらったのですが、論理ボリュームは一つのみで、全ての物理領域が割り当ててある状態。
しかも、SWAP領域が少なくて、FTP時などSWAP不足になってしまっていました。

SWAPの拡張を行おうとしても、拡張できる領域は無いし、割り当てられているデバイスは「/」なので、アンマウントしようとしてもビジーになるので、減らすこともできません。

そこで、ファイルを用いたSWAP領域の拡張を行いました。

まず、SWAP領域となるためのファイルを作成します。


# dd if=/dev/zero of=/swapfile bs=1G count=4

0埋めされた4Gbyteの/swapfileが作成されます

次に、作成した/swapfileをSWAP領域として作成します。


# mkswap /swapfile

これで、SWAP領域の準備ができました。

後は、この領域を有効にするだけです。


# swapon /swapfile

freeコマンドなどで、作成した領域がSWAPとして有効であることが確認できます。

当初、ボリューム拡張できなくて戸惑ったのですが、容量に余裕があれば結構簡単に変更できました。

最後に、このままだと再起動したときにせっかく拡張した領域がマウントされないので、以下のファイルを修正します。
/etc/fstab

ここに、以下を追記します。


/swapfile swap swap defaults 0 0
8
8
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
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?