#!/bin/bash
##extend /
#swapoff -a
#lvchange -a n /dev/VolGroup00/LogVol01
#lvremove /dev/VolGroup00/LogVol01
#lvresize -L +3G /dev/VolGroup00/LogVol00
#resize2fs -f /dev/VolGroup00/LogVol00
#lvcreate -L 800M -n /dev/VolGroup00/LogVol01
#mkswap /dev/VolGroup00/LogVol01
#swapon -a
##change disk gpt to mbr
function CHANGE_MODE(){
for i in {b..n}
do
parted -i <<EOF
select /dev/vd$i
mktable
Yes
msdos
q
EOF
done
}
##mkfs vdb
function mk_vdb(){
if [ ! -b /dev/vdb1 ]
then
fdisk /dev/vdb <<EOF
n
p
1
w
EOF
fi
/sbin/partprobe /dev/vdb
mkdir -p /data/proclog/
result=`grep "/dev/vd$i" /etc/fstab`
if [ ! $? -eq 0 ]
then
echo "/dev/vdb1 /data/proclog/ ext3 defaults 0 0" >> /tmp/fstab
fi
}
num=1
##make partion
function fdisk_other(){
for i in {c..n}
do
{
if [ ! -b /dev/vd${i}1 ]
then
fdisk /dev/vd$i <<EOF
n
p
1
w
EOF
/sbin/partprobe /dev/vd$i
else
echo "/dev/vd$i ok"
fi
result=`grep "/dev/vd$i" /etc/fstab`
if [ ! $? -eq 0 ]
then
if [ -b /dev/vd${i}1 ]
then
echo "/dev/vd$i ok"
fi
mkdir -p /data/cache$num
echo "/dev/vd${i}1 /data/cache$num ext3 defaults 0 0" >> /tmp/fstab
fi
}&
num=$(($num+1))
done
wait
}
##mkfs
function mk_disk(){
i=$1
for i in {b..n}
do
tmp=`mount|grep /dev/vd${i}1`
if [ ! $? -eq 0 ]
then
echo "mkfs /dev/vd${i}1 ......"
mkfs.ext3 -q /dev/vd${i}1 &
fi
done
}
###running
CHANGE_MODE
mk_vdb
fdisk_other
mk_disk
##check done or not
num_tmp=`ps aux|grep mkfs|wc -l`
while [ ! $num -eq 1 ]
do
echo -n "."
sleep 5
done
echo "mkfs is done"
###sort fstab
sort -n /tmp/fstab >> /etc/fstab
###mount
mount -a