bash-3.2$ cat >my_LVM
# VG FS Size
vg01 FS_WWW 20G
vg01 FS_WWW2 30G
vg02 FS_WWW 20G
vg02 FS_WWW2 30G
---------------------------------------------
bash-3.2$ more mylvm.sh
#!/bin/sh
# Sam
# Automate FS creation task
# Mon Feb 24 12:30:18 EST 2010
#
cat my_LVM | grep -v "^#" | while read myvg myfs mysize
do
#
echo " "
echo For LVM
echo lvcreate -L ${mysize} -n ${myfs} ${myvg}
echo mkfs /dev/${myvg}/${myfs}
#
echo " "
echo For Veritas Volume Manager
echo vxassist -g ${myvg} -b make ${myfs} ${mysize} layout=nostripe
echo " "
#
echo For vxfs
#
echo /usr/lib/fs/vxfs/mkfs -F vxfs -o largefiles /dev/vx/rdsk/${myvg}/${myfs}
echo " "
#
echo For UFS
#
echo newfs -v /dev/vx/rdsk/${myvg}/${myfs}
echo fsck -y /dev/vx/rdsk/${myvg}/${myfs}
echo "-----------------------------------"
# echo " "
done
#
echo
echo "Task completed !!!"
echo
bash-3.2$
---------------------------------------------
bash-3.2$ sh mylvm.sh
For LVM
lvcreate -L 20G -n FS_WWW vg01
mkfs /dev/vg01/FS_WWW
For Veritas Volume Manager
vxassist -g vg01 -b make FS_WWW 20G layout=nostripe
For vxfs
/usr/lib/fs/vxfs/mkfs -F vxfs -o largefiles /dev/vx/rdsk/vg01/FS_WWW
For UFS
newfs -v /dev/vx/rdsk/vg01/FS_WWW
fsck -y /dev/vx/rdsk/vg01/FS_WWW
-----------------------------------
For LVM
lvcreate -L 30G -n FS_WWW2 vg01
mkfs /dev/vg01/FS_WWW2
For Veritas Volume Manager
vxassist -g vg01 -b make FS_WWW2 30G layout=nostripe
For vxfs
/usr/lib/fs/vxfs/mkfs -F vxfs -o largefiles /dev/vx/rdsk/vg01/FS_WWW2
For UFS
newfs -v /dev/vx/rdsk/vg01/FS_WWW2
fsck -y /dev/vx/rdsk/vg01/FS_WWW2
-----------------------------------
For LVM
lvcreate -L 20G -n FS_WWW vg02
mkfs /dev/vg02/FS_WWW
For Veritas Volume Manager
vxassist -g vg02 -b make FS_WWW 20G layout=nostripe
For vxfs
/usr/lib/fs/vxfs/mkfs -F vxfs -o largefiles /dev/vx/rdsk/vg02/FS_WWW
For UFS
newfs -v /dev/vx/rdsk/vg02/FS_WWW
fsck -y /dev/vx/rdsk/vg02/FS_WWW
-----------------------------------
For LVM
lvcreate -L 30G -n FS_WWW2 vg02
mkfs /dev/vg02/FS_WWW2
For Veritas Volume Manager
vxassist -g vg02 -b make FS_WWW2 30G layout=nostripe
For vxfs
/usr/lib/fs/vxfs/mkfs -F vxfs -o largefiles /dev/vx/rdsk/vg02/FS_WWW2
For UFS
newfs -v /dev/vx/rdsk/vg02/FS_WWW2
fsck -y /dev/vx/rdsk/vg02/FS_WWW2
-----------------------------------
Task completed !!!
bash-3.2$
==============================================================
# cat lvm_create.sh
#!/bin/sh
# SAM Bhusal
# Automate FS creation task. This script tested and verified on Redhat Enterprise 6.x version.
# Config file entry eg.
# # file_name: LVM_WEBLOGIC
# # For Weblogic
# # vg FS Size(GB) Mnt point
# --------------------------------
# datavg WEB 10 /web
# datavg WEBDATA 15 /webdata
#
# Mon Feb 24 12:13:24 EST 2014
# Update: Thu Aug 14 09:55:12 EDT 2014
# Added the entry for mount point on config file.
# Added entry to the fstab.
#
if [ `/usr/bin/whoami` != "root" ]
then
echo "You must be root to run this script"
exit 1
fi
# Creating LVM.
/bin/cat LVM_WEBLOGIC | grep -v "^#" | while read myvg myfs mysize mymt
do
echo " "
# Check if mount point already exists.
#/bin/df -h ${mymt}
/bin/ls -ld ${mymt}
if [ $? -eq 0 ]; then
echo "Mount Point exists."
echo "Please review the config file."
exit 1
fi
/sbin/lvcreate -L ${mysize}G -n ${myfs} ${myvg}
/sbin/mkfs.ext4 /dev/${myvg}/${myfs}
# Create mount point
/bin/mkdir -p ${mymt}
# Add Entry to fstab
echo "###########################################################################" >>/etc/fstab
echo "/dev/${myvg}/${myfs} ${mymt} ext4 defaults 1 2" >>/etc/fstab
# Mount the filesystem.
/bin/mount -a
# Verify if the filesystems were created.
/bin/df -h ${mymt}
# Check the condition if the process is successful.
if [ $? -eq 0 ]; then
echo "Successfully Created fileystem."
continue
else
echo "Failed, please review the error"
# exit
fi
echo " ----------------end----------------"
done
# EOF
# cat LVM_WEBLOGIC
# file_name: LVM_WEBLOGIC
# SAM Bhusal
# For Weblogic
# vg FS Size(GB) mPoint
#---------------------------------------
datavg PKGS 20 /pkgs
datavg WWW 10 /www
datavg WWW_DOCROOT 10 /www/docroot
datavg WWW_SERVERS 10 /www/servers
datavg FMAC_TEST 10 /fmac/test
datavg FMACDATA 10 /fmacdata
# VG FS Size
vg01 FS_WWW 20G
vg01 FS_WWW2 30G
vg02 FS_WWW 20G
vg02 FS_WWW2 30G
---------------------------------------------
bash-3.2$ more mylvm.sh
#!/bin/sh
# Sam
# Automate FS creation task
# Mon Feb 24 12:30:18 EST 2010
#
cat my_LVM | grep -v "^#" | while read myvg myfs mysize
do
#
echo " "
echo For LVM
echo lvcreate -L ${mysize} -n ${myfs} ${myvg}
echo mkfs /dev/${myvg}/${myfs}
#
echo " "
echo For Veritas Volume Manager
echo vxassist -g ${myvg} -b make ${myfs} ${mysize} layout=nostripe
echo " "
#
echo For vxfs
#
echo /usr/lib/fs/vxfs/mkfs -F vxfs -o largefiles /dev/vx/rdsk/${myvg}/${myfs}
echo " "
#
echo For UFS
#
echo newfs -v /dev/vx/rdsk/${myvg}/${myfs}
echo fsck -y /dev/vx/rdsk/${myvg}/${myfs}
echo "-----------------------------------"
# echo " "
done
#
echo
echo "Task completed !!!"
echo
bash-3.2$
---------------------------------------------
bash-3.2$ sh mylvm.sh
For LVM
lvcreate -L 20G -n FS_WWW vg01
mkfs /dev/vg01/FS_WWW
For Veritas Volume Manager
vxassist -g vg01 -b make FS_WWW 20G layout=nostripe
For vxfs
/usr/lib/fs/vxfs/mkfs -F vxfs -o largefiles /dev/vx/rdsk/vg01/FS_WWW
For UFS
newfs -v /dev/vx/rdsk/vg01/FS_WWW
fsck -y /dev/vx/rdsk/vg01/FS_WWW
-----------------------------------
For LVM
lvcreate -L 30G -n FS_WWW2 vg01
mkfs /dev/vg01/FS_WWW2
For Veritas Volume Manager
vxassist -g vg01 -b make FS_WWW2 30G layout=nostripe
For vxfs
/usr/lib/fs/vxfs/mkfs -F vxfs -o largefiles /dev/vx/rdsk/vg01/FS_WWW2
For UFS
newfs -v /dev/vx/rdsk/vg01/FS_WWW2
fsck -y /dev/vx/rdsk/vg01/FS_WWW2
-----------------------------------
For LVM
lvcreate -L 20G -n FS_WWW vg02
mkfs /dev/vg02/FS_WWW
For Veritas Volume Manager
vxassist -g vg02 -b make FS_WWW 20G layout=nostripe
For vxfs
/usr/lib/fs/vxfs/mkfs -F vxfs -o largefiles /dev/vx/rdsk/vg02/FS_WWW
For UFS
newfs -v /dev/vx/rdsk/vg02/FS_WWW
fsck -y /dev/vx/rdsk/vg02/FS_WWW
-----------------------------------
For LVM
lvcreate -L 30G -n FS_WWW2 vg02
mkfs /dev/vg02/FS_WWW2
For Veritas Volume Manager
vxassist -g vg02 -b make FS_WWW2 30G layout=nostripe
For vxfs
/usr/lib/fs/vxfs/mkfs -F vxfs -o largefiles /dev/vx/rdsk/vg02/FS_WWW2
For UFS
newfs -v /dev/vx/rdsk/vg02/FS_WWW2
fsck -y /dev/vx/rdsk/vg02/FS_WWW2
-----------------------------------
Task completed !!!
bash-3.2$
==============================================================
# cat lvm_create.sh
#!/bin/sh
# SAM Bhusal
# Automate FS creation task. This script tested and verified on Redhat Enterprise 6.x version.
# Config file entry eg.
# # file_name: LVM_WEBLOGIC
# # For Weblogic
# # vg FS Size(GB) Mnt point
# --------------------------------
# datavg WEB 10 /web
# datavg WEBDATA 15 /webdata
#
# Mon Feb 24 12:13:24 EST 2014
# Update: Thu Aug 14 09:55:12 EDT 2014
# Added the entry for mount point on config file.
# Added entry to the fstab.
#
if [ `/usr/bin/whoami` != "root" ]
then
echo "You must be root to run this script"
exit 1
fi
# Creating LVM.
/bin/cat LVM_WEBLOGIC | grep -v "^#" | while read myvg myfs mysize mymt
do
echo " "
# Check if mount point already exists.
#/bin/df -h ${mymt}
/bin/ls -ld ${mymt}
if [ $? -eq 0 ]; then
echo "Mount Point exists."
echo "Please review the config file."
exit 1
fi
/sbin/lvcreate -L ${mysize}G -n ${myfs} ${myvg}
/sbin/mkfs.ext4 /dev/${myvg}/${myfs}
# Create mount point
/bin/mkdir -p ${mymt}
# Add Entry to fstab
echo "###########################################################################" >>/etc/fstab
echo "/dev/${myvg}/${myfs} ${mymt} ext4 defaults 1 2" >>/etc/fstab
# Mount the filesystem.
/bin/mount -a
# Verify if the filesystems were created.
/bin/df -h ${mymt}
# Check the condition if the process is successful.
if [ $? -eq 0 ]; then
echo "Successfully Created fileystem."
continue
else
echo "Failed, please review the error"
# exit
fi
echo " ----------------end----------------"
done
# EOF
# cat LVM_WEBLOGIC
# file_name: LVM_WEBLOGIC
# SAM Bhusal
# For Weblogic
# vg FS Size(GB) mPoint
#---------------------------------------
datavg PKGS 20 /pkgs
datavg WWW 10 /www
datavg WWW_DOCROOT 10 /www/docroot
datavg WWW_SERVERS 10 /www/servers
datavg FMAC_TEST 10 /fmac/test
datavg FMACDATA 10 /fmacdata
No comments:
Post a Comment