Files
2021-06-28 00:14:58 +08:00

22 lines
714 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
echo "
Creat-SWAP by yanglc
本脚本仅在Debian系系统下进行过测试
"
now=`free -m| grep "Swap:"| awk '{print $2}'`
echo "当前系统swap分区大小为:$now Mb"
echo "请输入要增加的swap分区大小(单位Mb):"
read -e swap
echo "###########开始添加SWAP分区##########"
sudo dd if=/dev/zero of=/mnt/swap bs=1M count=${swap}
echo -e
echo " ###########设置交换分区文件##########"
mkswap /mnt/swap
echo -e
echo " ###########启动SWAP分区中...#########"
swapon /mnt/swap
echo -e
echo " ###########设置开机自启动############"
echo '/mnt/swap swap swap defaults 0 0' >> /etc/fstab
echo "All doneThanks for using this shell script"