Linux disk Bulk partition formatting and mounting scripts

Source: Internet
Author: User

Yesterday received a task, 10 machines, need to partition and mount, each machine has 6 drive letters, if one of the manual operation, not high efficiency, I finished one, try to write a script, to achieve batch deployment! Here's how the script uses

 [[email protected] ~]# vim parted.sh #!/bin/bash# #yum  install -y  partedsleep 1syum install -y vimsleep 1s####################################### ############################# #touch  /root/test1i=0b=1for  disk in  ' fdisk -l  | grep  "/dev/vd*"  | awk  ' {if ($2~/vd/ && $2!= "/dev/vda:"   && $2!= "/DEV/VDB:")  print substr ($2,0,8)} ' do          parted  $disk   << EXIT          mklabel gpt         mkpart primary 0 -1          ignore          quitEXIT       mkfs.ext4  $disk $becho  "/n/n****************$ disk_was fdisked! Waithing for 10 second****/n/n "Sleep 1s        uuid=" blkid  $disk $b | awk  ' {print $2} ' |awk -f "\" "  ' {print $2} '          mkdir /data${i}        cat  << exit > /root/test1uuid= $uuid       /data${i}        ext4    defaults                 1 2 EXIT         cat /root/test1 >> /etc/fstabi=$ (($i  + 1)) done ### ################################################################## #mount  -a
[[email protected] ~]# dffilesystem                1K-blocks    Used  Available Use%  mounted on/dev/mapper/vg0-lv_root   12179756 2680964    8880092   24% /tmpfs                      16439788       0    16439788   0% /dev/shm/dev/vda1                    198337   28603      159494  16% /boot/dev/vdc1                4227572676  198680 4012625684    1% /data0/dev/vdd1               4227572676  198680  4012625684   1% /data1/dev/vde1                4227572676  198680 4012625684   1% / data2/dev/vdf1                4227572676  198680 4012625684   1% /data3/dev/vdg1                4227572676  198680 4012625684    1% /data4/dev/vdh1                4227572676  198680 4012625684   1% /data5
[[email protected] ~]# vim /etc/fstab## /etc/fstab# created by  Anaconda on wed mar  5 14:32:01 2014## accessible filesystems,  by reference, are maintained under  '/dev/disk ' # see man pages  fstab (5),  findfs (8),  mount (8)  and/or blkid (8)  for more info#/dev/ mapper/vg0-lv_root /                        ext4    defaults         1 1UUID=0a17f48d-f99b-4498-82a5-a0874f25f1e7 /boot                    ext4     defaults        1 2/dev/vdb1        swap    swap    defaults        0  0tmpfs                    /dev/shm                 tmpfs   defaults        0 0devpts                   /dev/pts                 devpts   gid=5,mode=620  0 0sysfs                    /sys                     sysfs   defaults         0 0proc                     /proc                    proc    defaults         0 0uuid=9ff86747-384f-4a37-adab-1ac5abd98dff      / data0       ext4    defaults                 1 2 uuid= bd6103cf-9774-4e31-87bb-33df4fbea47e      /data1        ext4    defaults                 1 2 UUID=81a1b153-279f-454c-b23c-07744203b65a       /data2       ext4    defaults                 1 2 UUID=ae66663e-0879-4622-bb68-94bb045f9719       /data3       ext4    defaults                 1 2  uuid=aab4c3f0-344a-4309-8ec0-c87017b5179d      /data4        ext4    defaults                 1 2 UUID=0d4a6b2f-99dd-4a87-9d48-6090c3863ba3       /data5       ext4    defaults                 1 2  ~

This article is from the "Scattered People" blog, please be sure to keep this source http://zouqingyun.blog.51cto.com/782246/1689231

Linux disk Bulk partition formatting and mounting scripts

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.