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