加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

利用shell脚本实现对系统的自动分区

发布时间:2016-09-27 18:37:18 所属栏目:Linux 来源:站长网
导读:#!/bin/bash function print { if [ $# = 2 ]; then if [ $1 = warning ]; then echo -e 33[33m33[5m$233[0m elif [ $1 = error ]; then echo -e 33[31m33[5m$233[0m elif [ $1 = notice ]; then echo -e 33[36m33[5m$233[0m fi echo $2 elif [ $# = 1 ];
#!/bin/bash

function print {
if [ $# = 2 ]; then
if [ "$1" = "warning" ]; then
echo -e "33[33m33[5m$233[0m"
elif [ "$1" = "error" ]; then
echo -e "33[31m33[5m$233[0m"
elif [ "$1" = "notice" ]; then
echo -e "33[36m33[5m$233[0m"
fi
echo $2
elif [ $# = 1 ]; then
echo -e "33[32m33[5m$133[0m"
echo $1
fi
return
}
#定义显示颜色方案
function format_disk()
{
fdisk /dev/sda << EOF
d
1
d
2
d
3
d
4
n
p
1
+1G
n
p
2
+20G
n
p
3

wq
EOF
print "==============fdsik sda to three parttions====================="
return 0
}
#分区大小为boot 1GB swap 20GB /根分区余下空间全用
function MKFS()
{
partprobe
mkfs.reiserfs -q /dev/sda1
[ $? != 0 ] && print "error" "mkfs sda1 is failed" && exit 0
mkswap /dev/sda2
[ $? != 0 ] && print "error" "mkswap sda2 is failed" && exit 0
swapon /dev/sda2
[ $? != 0 ] && print "error" "swapon sda2 is failed" && exit 0
mkfs.reiserfs -q /dev/sda3
[ $? != 0 ] && print "error" "mkfs sda3 is failed" && exit 0
print "===================make filesystem is OK===================="
return 0
}
#分区类型为reiserfs
function main()
{
format_disk;
MKFS
}
main

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读