#!/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
时间: 2024-10-13 03:02:16