swap分区扩容
If you have less than 2048MB of memory (between your RAM and SWAP), you can add temporary swap space by creating a temporary swap file. This way you do not have to use a raw device or even more drastic, rebuild your system.
As root, make a file that will act as additional swap space, let's say about 500MB:
# dd if=/dev/zero of=tempswap bs=1k count=500000
Now we should change the file permissions:
# chmod 600 tempswap
Finally we format the "partition" as swap and add it to the swap space:
# mke2fs tempswap
# mkswap tempswap
# swapon tempswap
增加Swap分区文件大小
创建一个足够大的文件(此处为256M):
dd if=/dev/zero of=/swapfile bs=1024 count=262144
把这个文件变成swap文件:
mkswap /swapfile
启用这个swap文件:
swapon /swapfile
在每次开机的时候自动加载swap文件, 需要在/etc/fstab 文件中增加一行:
/swapfile swap swap defaults 0 0