The day after tomorrow to reply, today only brush a question, have not written out, but want to update the blog, so only to write the previous things posted out.
A shell script for partitioning
1 #!/bin/Bash #指定脚本解释器路径 2 echo "Initial a disk ..." 3 Echo-e "\033[31mwarning!:\ 033[0m "#提醒用户危险操作 4 5 fdisk-l 2>/dev/null | grep-o" Disk/dev/[sh]d[a-z] "#显示所有分区 6 7 read-p" Your choice :"Partdisk #读入要操作的分区 8 9 If [$partdisk = = "Quit"];then10 echo "quit" Exit 7 #错误退出, non-012 fi13 Until Fdisk-l 2>/dev/null | Grep-o "Disk/dev/[sh]d[a-z]" | grep "Disk $partdisk $" &>/dev/null;do15 read-p "wrong option,your choice:"partdisk16 done17 read-p "is you sure?" choice19 until [$choice = = ' y '-o $choice = = ' n '];d o21 read Choice22 done if [$choice = n];then25 Exit 026 else27 DD If=/dev/zero of= $pa partdisk bs=512 count =1 #从设备/dev/zero output 0 Overwrite the first sector of the disk where all partitions are removed. nc29 # #删除所有分区30 echo "partion" # # #31 Sleep 3 #32 echo ' n #32-45 lines of ECHO, as in the command line, p #34 1 #35 #36 +20M #37 n #38 p #39 3 #40 +128m42 T 344 8245 w ' |fdisk $partition &>/dev/null #返回消息送入/dev/null device sync47 partprobe $partdisk #写入硬盘48 sync49 sleep 3 #同步内容花费时间较长, hibernate 3s otherwise the following formatting command is not able to execute the mke2fs-j ${ Partdisk}1 &>/dev/null mke2fs-j ${partdisk}2 &>/dev/null #格式化分区, message sent to/dev/null52 Mkswap ${partdisk}3& Amp;>/dev/null #格式化交换分区
Partition script in "Shell" Linux