Shell Script Management Disk

Source: Internet
Author: User

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

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.