1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/bin/bash
fdisk
-l |
grep
-o
"/dev/[a-z].*d[a-z]"
|
uniq
read
-p
" qing xuanze yao geshihuade disk q is exit : "
disk
if
[ $disk == q ]
then
echo
"exit#######################33"
exit
1
fi
until
fdisk
-l |
grep
-o
"/dev/[a-z].*d[a-z]"
|
uniq
|
grep
-o $disk
do
echo
"error..............exit###################"
exit
2
done
a=`
fdisk
-l |
grep
-o
"/dev/[a-z].*d[a-z]"
|
uniq
|
grep
-o $disk |
awk
-F
"/"
'{print $3}'
`
b=`
fdisk
-l |
grep
-o
"/dev/[a-z].*d[a-z]"
|
uniq
|
awk
-F
"/"
'{print $3}'
>
/tmp/xx
`
for
n
in
`
cat
/tmp/xx
`
do
if
[
"$n"
==
"$a"
]
then
>
read
-p
"niquedinggeshihua $disk y/n : "
yn
if
[ $yn == n -o $yn != y ]
then
echo
"exit........"
exit
3
else
fdisk
-l |
grep
-oE
"$disk[1-9].*"
|
awk
'{print $1}'
|
xargs
umount
>
/dev/null
2>&1
dd
if
=
/dev/zero
of=$disk count=512 bs=1 >
/dev/null
2>&1
echo
-e
"n\np\n1\n\n+10M\nw\n"
|
fdisk
$disk >
/dev/null
2>&1
echo
-e
"n\np\n2\n\n+10M\nw\n"
|
fdisk
$disk >
/dev/null
2>&1
echo
-e
"n\np\n3\n\n+10M\nw\n"
|
fdisk
$disk >
/dev/null
2>&1
printf
"%-20s %-12s %-8s %-7s %-2s %-1s \n"
Boot Start End Blocks Id System
fdisk
-l |
grep
-oE
"$disk[1-9].*"
exit
0
fi
fi
done
|
本文转自 295631788 51CTO博客,原文链接:http://blog.51cto.com/hequan/1834578,如需转载请自行联系原作者