Linux simple format hard disk script

Source: Internet
Author: User

#!/bin/bashfdisk -l | grep -o  "/dev/[a-z].*d[a-z]"  | uniq  read    -p   " qing xuanze  yao  geshihuade  disk    q is exit :  "  diskif [  $disk  == q ] then        echo  "exit###################### #33"          exit 1fiuntil  fdisk -l | grep -o  "/dev/[a-z].*d[a-z]"  | uniq  | grep -o   $disk  do  echo   "error..............exit###################"   exit  2done 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   fidone

This article is from the "what-all" blog, please be sure to keep this source http://hequan.blog.51cto.com/5701886/1834578

Linux simple format hard disk script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.