Linux Create a disk partition script file (create two 512M and 2G primary partitions)

Source: Internet
Author: User

#!/bin/bash# author: suxinghe# date: 2015.6.9# version: 0.0.1# description:  create partions for diskread -p  "Please input a disk name:"  diskwhile :d oif [[  $disk  =~ /dev/* ]]thenif [ -b  $disk  ]thenread -p  "your choice are  $disk,  are you sure?" (yes/no): " ans1 if [  $ans 1 == yes ]thenwhile :d oread -p " is  you create partions for this disk, are you sure? (yes/no): " ans2if [  $ans 2 == yes ]thenecho " NP1+512MNP2+2GW " |  fdisk  $disk  &> /dev/nullecho -e  "\ n" fdisk -l  $disk  | grep    "^ $disk [1-9]\{1,\}";echo -e  "create partions \033[32msuccessful\033[0m"; Echo   "Exit ..."  && exit 0  elif [  $ans 2 == no ]thenecho  "Exit ..." exit 6elseecho  "Usage :(yes/no) "continuefidoneelif [  $ans 1 == no ]thenecho " Exit ... "exit  8elseecho  "Usage: (yes/no)" read -p  "Please input a disk name:"   diskcontinuefielseecho  "$disk  is not exist,please input a exist device  file! " read -p  "Please input a disk name:"  diskcontinuefielseecho  "$disk  is a not device file! " read -p  "Please input a disk name:"  diskcontinuefidone


This article is from "Chalet Technology" blog, please make sure to keep this source http://starli.blog.51cto.com/8813574/1659960

Linux Create a disk partition script file (create two 512M and 2G primary partitions)

Related Article

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.