Created
September 10, 2020 08:00
-
-
Save yamada28go/eb6d5abadf32301ac34a7a705bf56f2f to your computer and use it in GitHub Desktop.
This file contains 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
# ec2にswapを追加するコマンド | |
# | |
# [使い方] | |
# shellに保存してsudoで実行すること。 | |
# | |
# [変数] | |
# _T_SWAP_PATH : スワップファイルのパス領域 | |
# _T_SWAP_SIZE : スワップサイズ Mbyte | |
# | |
# 参考 | |
# AWS Amazon Linux スワップファイル作成によりSwap領域のサイズを増やす | |
# https://qiita.com/na0AaooQ/items/278a11ed905995bd16af | |
_T_SWAP_PATH=/data/swap/swapfile && | |
_T_SWAP_SIZE=2048 && | |
mkdir -p $(dirname ${_T_SWAP_PATH})&& | |
dd if=/dev/zero of=${_T_SWAP_PATH} bs=1M count=${_T_SWAP_SIZE} | |
chmod 600 ${_T_SWAP_PATH} && | |
mkswap ${_T_SWAP_PATH} && | |
echo "Before" && | |
swapon ${_T_SWAP_PATH} && | |
swapon -s && | |
free -h && | |
echo "${_T_SWAP_PATH} swap swap defaults 0 0" >> /etc/fstab | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment