linux创建2g文件,linux创建磁盘分区的脚本文件(创建两个512M和2G的主分区)

#!/bin/bash

# author: suxinghe

# date: 2015.6.9

# version: 0.0.1

# description: create partions for disk

read -p "please input a disk name:" disk

while :

do

if [[ $disk =~ /dev/* ]]

then

if [ -b $disk ]

then

read -p "your choice are $disk, are you sure?(yes/no):" ans1

if [ $ans1 == yes ]

then

while :

do

read -p "are you create partions for this disk, are you sure?(yes/no):" ans2

if [ $ans2 == yes ]

then

echo "n

p

1

+512M

n

p

2

+2G

w" | fdisk $disk &> /dev/null

echo -e "\n"

fdisk -l $disk | grep  "^$disk[1-9]\{1,\}";echo -e "create partions \033[32msuccessful\033[0m";echo "exit..." && exit 0

elif [ $ans2 == no ]

then

echo "exit..."

exit 6

else

echo "Usage:(yes/no)"

continue

fi

done

elif [ $ans1 == no ]

then

echo "exit...."

exit 8

else

echo "Usage:(yes/no)"

read -p "please input a disk name:" disk

continue

fi

else

echo "$disk is not exist,please input a exist device file!"

read -p "please input a disk name:" disk

continue

fi

else

echo "$disk is a not device file!"

read -p "please input a disk name:" disk

continue

fi

done

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值