cancel
Showing results for 
Search instead for 
Did you mean: 

VG Script

David Willams
Super Advisor

VG Script

How do I use the above script please



#!/usr/bin/ksh
#
# 7/5/2007 JML
#
#This script reads the filesystem.txt file and collects all the
#required paramters to create volumegroup and filesystems
#
# VG label to indicate Volume group settings
# FS Lable to indicate Filesystem settings
TABLE=filesystem.txt
LOGS=/tmp/create-vg-lv.$$.log

if [ ! -r $TABLE ]
then

echo "File table does not exist, please check and re-run the script .... "
exit 9
fi

READ_VG()
{
ALLVG=`awk -F: '/^VG/ {print $2}' $TABLE`
echo "The following Volume groups will be created : \n${ALLVG} \n "

}
READ_FS()
{
ALLVG=`awk -F: '/^VG/ {print $2}' $TABLE`
for VGP in `echo $ALLVG`
do
echo "Checking $VGP filesystem requirements"
FSP=`awk -F: -v volgrp=$VGP '/^FS/ && $2 ~ volgrp {printf "%-4s %-21s %8dMB \n", $2,$3,($4/1024)}' $TABLE`
echo "$FSP"
done

}

READ_VG
READ_FS
read go?"Proceed to create the filesystmes (y/n): "
case $go in
Y|y|YES|yes )
echo "----------------------------------------------------" | tee -a $LOGS
echo "Creating directory and file for volume groups " | tee -a $LOGS
for vgc in `awk -F: '/^VG/ {print $2}' $TABLE`
do
#### Check if the VG directory exist ####
if [ ! -d /dev/${vgc} ] ; then
echo "$vgc does not exist, creating directory now "
minornum=`grep "VG:${vgc} | awk -F: '{print $NF}'`
set -x
mkdir /dev/${vgc}
mknod /dev/${vgc}/group c 64 0x0${minornum}0000
set +x
PRIDSK=`awk -F: -v volgrp=$vgc '/^VG/ && $2 ~ volgrp {print $3}' $TABLE`
ALTDSK=`awk -F: -v volgrp=$vgc '/^VG/ && $2 ~ volgrp {print $4}' $TABLE`
NUMPRIDK=`echo $PRIDSK | awk -F"," '{print NF}'`
#### Collecting disk information per VG ####
if [ $NUMPRIDK -gt 1 ] ; then
ADDPDSK=`awk -F: -v volgrp=$vgc '/^VG/ && $2 ~ volgrp {print $3}' $TABLE | \
awk -F"," '{print substr($0,index($0,$2))}'`
ALLDISKS=`echo "$ADDPDSK,$ALTDSK"`
FIRSRDSK=`awk -F: -v volgrp=$vgc '/^VG/ && $2 ~ volgrp {print $3}' $TABLE | \
awk -F"," '{print $1}'`
else
FIRSRDSK=$PRIDSK
ALLDISKS=$ALTDSK
fi
FIRSRDSK=`echo $FIRSRDSK | sed -e 's/,/ /g' | sed -e "s/c/\/dev\/dsk\/c/g"`
ALLDISKS=`echo $ALLDISKS | sed -e 's/,/ /g' | sed -e "s/c/\/dev\/dsk\/c/g"`
echo "$FIRSRDSK ----> $ALLDISKS"
##### Creating and Extending Volume Group ######
set -x
vgcreate -l 255 -e 7000 -p 32 -s 4 /dev/${vgc} $FIRSRDSK
vgextend /dev/${vgc} $ALLDISKS
set +x
###### Creating Logical Volumes using table file configuration #####
echo "Now we will create the Logical Volumes for $vgc .... \n"
# set -x
for lvolc in `awk -F: -v volgrp=$vgc '/^FS/ && $2 ~ volgrp {print $5}' $TABLE`
do
echo $lvolc
lv_mount=`awk -F: -v volgrp=$vgc -v lv=${lvolc} '/^FS/ && $2 ~ volgrp && $5 ~ lv {print $3}' $TABLE | head -1`
lv_size=`awk -F: -v volgrp=$vgc -v lv=${lvolc} '/^FS/ && $2 ~ volgrp && $5 ~ lv {print ($4/1024)}' $TABLE | head -1`
set -x
lvcreate -L $lv_size -n $lvolc $vgc "
mkfs -F vxfs -o ninode=unlimited,bsize=1024,version=5,inosize=256,logsize=16384,largefiles /dev/${vgc}/${lvolc}
mkdir -p $lv_mount
mount /dev/${vgc}/${lvolc} $lv_mount
set +x
echo "----------------------------------------------------"
done
set +x
else
echo "$vgc directory exist, please check and re-run $vgc only"
fi
done | tee -a $LOGS
;;
N|n|NO|no )
echo " Exiting script....... good bye..... "
exit 1
;;
* ) echo " Wrong option re-run the script and choose the right option... "
;;
esac

9 REPLIES
David Willams
Super Advisor

Re: VG Script

What is filesystem.txt ???

and how does it look like

If this is not the correct one... can someone give me a script to create multiple VG's and LV's
Torsten.
Acclaimed Contributor

Re: VG Script

Ask the author!

I would be very careful with a script found on the net, especially if I don't know what it does and expects in detail.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
David Willams
Super Advisor

Re: VG Script

thanks Torsten,

COuld you give me a script to create multiple VG's

also my other hpvm issue is going hard... I have reinstalled the OS and everything but still the same

Torsten.
Acclaimed Contributor

Re: VG Script

Sorry, I don't have something to publish.


Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
David Willams
Super Advisor

Re: VG Script

Can I install hpvm 4.1 on below

# uname -a
HP-UX rx26-161 B.11.31 U ia64 3206393905 unlimited-user license
[rx26-161]/
#

David Willams
Super Advisor

Re: VG Script

Opps sorry wrong thread
Torsten.
Acclaimed Contributor

Re: VG Script

Too many open threads?

;-)

But yes, you can.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Ralph Grothe
Honored Contributor

Re: VG Script

> What is filesystem.txt ???
> and how does it look like

I guess, this everyone is asking who is confronted with this script.
It really would have been nice by the script's author if he had dropped a comment line what the contents of the filesystem.txt file is supposed to be and what format it should have.
As he didn't, the user will have to "reverse engineer" by looking at the various awk statements that refer to $TABLE spread over several functions.

> If this is not the correct one...
> can someone give me a script to create multiple VG's and LV's

What would be the "correct" script for your task?
I think it would be easier to write you own script or disclose your requirements to the forum's community and hope to get a few hints how to tackle the task.

I think it is no great loss if you dismiss this script.
It doesn't look that convincing to me.
(e.g. many useless uses of echo etc.)
Madness, thy name is system administration
David Willams
Super Advisor

Re: VG Script

.