Update create-swap.sh
parent
5660e39c6e
commit
e6d7921b55
|
@ -4,11 +4,9 @@ NO_COLOR="\033[0m"
|
||||||
GREEN="\033[32m\033[01m"
|
GREEN="\033[32m\033[01m"
|
||||||
BLUE="\033[0;36m"
|
BLUE="\033[0;36m"
|
||||||
FUCHSIA="\033[0;35m"
|
FUCHSIA="\033[0;35m"
|
||||||
echo "export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH" >> ~/.bashrc
|
echo "
|
||||||
source ~/.bashrc
|
${GREEN} Creat-SWAP by yanglc
|
||||||
sleep 3
|
${GREEN} 本脚本仅在Debian系系统下进行过测试"
|
||||||
echo "Creat-SWAP by yanglc"
|
|
||||||
echo "本脚本仅在ubuntu下进行过测试"
|
|
||||||
get_char()
|
get_char()
|
||||||
{
|
{
|
||||||
SAVEDSTTY=`stty -g`
|
SAVEDSTTY=`stty -g`
|
||||||
|
@ -19,20 +17,17 @@ get_char()
|
||||||
stty echo
|
stty echo
|
||||||
stty $SAVEDSTTY
|
stty $SAVEDSTTY
|
||||||
}
|
}
|
||||||
echo "按任意键添加SWAP分区:"
|
echo " ${GREEN} 按任意键添加1G大小的SWAP分区:"
|
||||||
echo "使用CTRL+C退出脚本。。。"
|
|
||||||
echo "Press any key to continue:"
|
|
||||||
echo " CTRL+C break command bash..."#CTRL+C EXIT
|
|
||||||
char=`get_char`
|
char=`get_char`
|
||||||
echo "Please set the partition size you want:"
|
echo " ${GREEN} ###########开始添加SWAP分区##########"
|
||||||
read -p "请输入要添加的大小:" size
|
dd if=/dev/zero of=/mnt/swap bs=1M count=1024
|
||||||
sleep 1
|
|
||||||
echo "###########开始添加SWAP分区##########"
|
|
||||||
dd if=/dev/zero of=/mnt/swap bs=1M count='$size'
|
|
||||||
echo -e
|
echo -e
|
||||||
echo "###########设置交换分区文件##########"
|
echo " ${GREEN} ###########设置交换分区文件##########"
|
||||||
mkswap /mnt/swap
|
mkswap /mnt/swap
|
||||||
echo -e
|
echo -e
|
||||||
echo "###########设置开机自启动############"
|
echo " ${GREEN} ###########启动SWAP分区中...#########"
|
||||||
|
swapon /mnt/swap
|
||||||
|
echo -e
|
||||||
|
echo " ${GREEN} ###########设置开机自启动############"
|
||||||
echo '/mnt/swap swap swap defaults 0 0' >> /etc/fstab
|
echo '/mnt/swap swap swap defaults 0 0' >> /etc/fstab
|
||||||
echo "All done!Thanks for using this shell script"
|
echo " ${GREEN} All done!Thanks for using this shell script"
|
||||||
|
|
Loading…
Reference in New Issue