Last active
August 29, 2015 14:06
-
-
Save Buttonwood/5d21ac8580ce68072890 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| PATH=/bin:/sbin:/usr/bin:/usr/sbin | |
| export PATH | |
| if [ ! -f "/etc/fstab.bak" ]; then | |
| # 备份分区表 | |
| echo "cp /etc/fstab /etc/fstab.bak" | |
| fi | |
| echo "echo Start finding disk drives ...... !" | |
| # TODO: 参数列表化,分区数及挂盘名字 | |
| i=1 | |
| # 大于50G的磁盘挂载到/home/disk{1,2,3,...} | |
| for disk in `fdisk -l |grep Disk |grep dev |perl -e '{while(<>){ my @a=split(/[\s+\:\,]/,$_); print $a[1]."\n" if($a[4] eq "GB" && $a[3] > 50);}}'`; do | |
| # fdisk 分盘 | |
| echo "fdisk $disk <<End | |
| n | |
| p | |
| 1 | |
| w | |
| End" | |
| # 格式化 | |
| echo "mkfs.ext4 -T largefile ${disk}1" | |
| # 创建挂载目录 | |
| if [ ! -d "/home/disk${i}" ]; then | |
| echo "mkdir /home/disk${i}" | |
| fi | |
| # 写入盘符 | |
| echo "e2label ${disk}1 /home/disk${i}" | |
| mount="\"LABEL=${disk}1 /home/disk${i} ext4 defaults 0 0\"" | |
| echo "rm -rf /home/disk${i}/*" | |
| echo "echo $mount >>/etc/fstab" | |
| echo "" | |
| i=$(($i+1)) | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment