Scripting features: Display all disks and select, partition all selected disks, repartition partitions and format file system
#!/bin/bash
# Display all disks and select, format partition of selected disk, repartition partition and format file system
Echo-e "\e[1;34myou has this disks:\e[0m"
Fdisk-l 2>/dev/null | Grep-o "^disk/dev/[sv]d[a-z]"
Echo-e "\e[1;31myour Choice Is:\nthis may destroy your data,you also can choose
<quit>.\e[0m "
Read DISK
if [$DISK = = ' Quit '];then
Echo
echo "quit."
Exit 2
Else
Until Fdisk-l 2>/dev/null | Grep-o "^disk/dev/[sv]d[a-z]" | grep "^d
ISK $DISK $ "&>/dev/null;do
Read-p "Wrong option,please Choose again:" DISK
Done
Read-p "dangeous! Is you sure continue: (yes/no) "CON
if [$CON = = ' No '];then
echo "quit."
Exit 3
Else
DD If=/dev/zero of= $DISK bs=512 count=1 &>/dev/null
Sync
Echo '
N
P
1
+50m
N
P
2
+50m
N
P
3
+50m
W ' | Fdisk $DISK &>/dev/null
Fi
Fi
Mke2fs-j ${disk}1 &>/dev/null
V1=$?
If [$v 1-eq 0];then
echo "Make ${disk}1 succeed."
Fi
Sleep 1
Mke2fs-j ${disk}2 &>/dev/null
V2=$?
If [$v 2-eq 0];then
echo "Make ${disk}2 succeed."
Fi
Sleep 1
Mke2fs-j ${disk}3 &>/dev/null
V3=$?
If [$v 3-eq 0];then
echo "Make ${disk}3 succeed."
Fi
This article is from the "11944248" blog, please be sure to keep this source http://11954248.blog.51cto.com/11944248/1964440
Shell Script Management Disk