Created
February 28, 2015 12:25
-
-
Save toshihirock/41ed46d96979da1b5796 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WAPFILENAME=/swap.img | |
MEMSIZE=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'` | |
if [ $MEMSIZE -lt 2097152 ]; then | |
SIZE=$(($MEMSIZE * 2))k | |
elif [ $MEMSIZE -lt 8388608 ]; then | |
SIZE=${MEMSIZE}k | |
elif [ $MEMSIZE -lt 67108864 ]; then | |
SIZE=$(($MEMSIZE / 2))k | |
else | |
SIZE=4194304k | |
fi | |
fallocate -l $SIZE $SWAPFILENAME && mkswap $SWAPFILENAME && swapon $SWAPFILENAME |
Author
toshihirock
commented
Feb 28, 2015
- /etc/rc.local
- 参考:Amazon EC2(Linux)のswap領域ベストプラクティス
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment