Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Disk partitioning script for shell

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Disk partition script

Request

1. List all disks on the current system, let the user choose, and support Q to exit the script. If the user chooses incorrectly, let the user select again. 2. After the user selects it, the mount directory is automatically created. Auto mount #! / bin/bashecho "the disks exist list:" fdisk-l | grep 'disk / dev/sd [a murz]' / / list all disks echo "= =" PS3= "chose which disk you want to create:" / / Please select the disk select VAR in `disk / dev/sd* that you want to create | grep-o'sd [bMuz]'| Uniq` quit do case $VAR in/ / circular sda) Fdisk-l / dev/sda break Sd [bmerz]) # create partitions echo "n p w" | fdisk / dev/$VAR # make filesystem mkfs.xfs-I size=512 / dev/$ {VAR} "1" & > / dev/null / / format # mount the system mkdir-p / data/$ {VAR} "1" & > / dev/null / / Creative Mount point to / dev/null directory / / automatically mount echo-e "/ dev/$ {VAR}" 1 "/ data/$ {VAR}" 1 "xfs defaults 0\ n" > > / etc/fstab mount-a & > / dev/null break ; quit) break;; *) echo "wrong disk,please check again";; esacdone

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report