标签:example exit error err ext awk dos mes led
#!/bin/bash if [ $# -le 1 ]; then echo -e "usage : \n\t$0 sdx mount_point" echo -e "example: \n\t$0 sdb /data1" exit 1 fi disk=/dev/$1 homedisk_num=$(df -h | awk ‘{print $NF}‘ | grep -c "$2") if [[ $homedisk_num -gt 0 ]]; then echo "$2 has mounted on single-disk ." touch /tmp/home_init.tag2 exit 0 fi disk_num=$(df -h | awk ‘{print $1}‘ | grep -c "$1") if [[ $vdb1_num -gt 0 ]]; then echo "$1 has mounted on single-disk ." touch /tmp/home_init.tag2 exit 0 fi parted -s "$disk" mklabel msdos parted -s "$disk" mkpart primary 0% 100% #label=‘home‘ echo "__CMD: time mkfs.ext4 -L $label ${disk}1 > ‘/tmp/mkfs.${label}.txt‘ 2>&1 &" time mkfs.ext4 -L "$label" "${disk}1" UUID=$(blkid -o value -s UUID "${disk}1") echo "UUID=${UUID} $2 ext4 defaults,noatime 0 0" >> /etc/fstab #mount ${disk}1 /mnt || { echo "__ERROR: ‘mount ${disk}1 /mnt‘ FAILED, exit 2"; exit 2; } #rsync -avP /home/ /mnt --exclude=‘/home/work/mesos/log/*‘ --exclude=‘/home/work/mesos/slave/*‘ #umount /mnt cat /etc/fstab mount -a
标签:example exit error err ext awk dos mes led
原文地址:http://www.cnblogs.com/tengfei520/p/7843411.html