Operating System - HP-UX
1834020 Members
3102 Online
110063 Solutions
New Discussion

Script for VG and LV create

 
SOLVED
Go to solution
Mike_305
Super Advisor

Script for VG and LV create

Hello,

I know how to do this from command line but does anyone has the scrip that I can modify and save time to create my VG's and LV's.

I have lots of file systems that I need to create.

Appreciate your help and thanks in advance.

THX
If there is problem then don't think as problem, think as opportunity.
11 REPLIES 11
Johnson Punniyalingam
Honored Contributor

Re: Script for VG and LV create

this script extends file systems at boot time. (pls edit as per your requirements)

Rgds,
Johnson
Problems are common to all, but attitude makes the difference
Ivan Krastev
Honored Contributor

Re: Script for VG and LV create

Make some tests and make one, suitable for your needs. You should consider with:
- maxvg kernel parameter;
- fing higher /dev/*/group number;
- check for duplicate VG name;
- create VG;
- create LV;
- mounpoints if necessary ...


regards,
ivan
Torsten.
Acclaimed Contributor

Re: Script for VG and LV create

It's a bitz hard to suggest, because there are so many choices:

- LVM ver 1.0, 2.0, 2.1
- OS version
- multipathing
- striping
- mirroring
- ...

It always depends on your needs ...

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!   
sreekanthtm
Trusted Contributor

Re: Script for VG and LV create

Hi,

I think you are new to HPUX. VG creation is not a regular OR day to day activity. And the parameters used to create VG and LV keeps on change depending on your DB, Apps etc..... as mentioned by Torsten. If you want to create lots LV and VG's with same parameters, please come up with details of your server and get more specific answer.

Rgds
Sreekanth
Jannik
Honored Contributor

Re: Script for VG and LV create

A script like that would be big, if it needed to take all the possibilities into consideration.

You need to think about the needs that you have and what variables you would like to specify.

The script is not tested, i don't have a HPUX machine at hand :-), so it is from memory, but it is something to build on.

#!/usr/bin/ksh

if [ $# -ne 1 ]
then
echo "USAGES: $0 "
fi

# c1d1t1
DISK=$1
print -n "type new vgname: "; read VGNAME
print -n "type new lvname: "; read LVNAME
print -n "type new lvsize: "; read LVSIZE

# standard names
# VGNUM=$(echo $VGNAME | awk -Fg '{print $2}'
# else
print -n "type the vgnumber (01 for vg01) : "; read VGNUM

pvcreate /dev/rdsk/${DISK}
mkdir /dev/${VGNAME}
mknod /dev/${VGNAME}/group -c 64 0x${VGNUM}000
vgcreate ${VGNAME} /dev/dsk/${DISK}
lvcreate -L ${LVSIZE} -n ${LVNAME} /dev/${VGNAME}

fsadm -F vxfs -o largefiles /dev/${VGNAME}/${LVNAME}

echo "rember to put this volume into fstab"
jaton
Mike_305
Super Advisor

Re: Script for VG and LV create

Hello All,

Thanks for the reply; I am looking for suggestion related to Volume group creation and File system related steps to be put in scripts.

Appreciate your help.

Thanks in advance.
If there is problem then don't think as problem, think as opportunity.
Torsten.
Acclaimed Contributor

Re: Script for VG and LV create

I know you want to have a script, but how should we know what you need in detail?

Do you need mirrored and/or striped LVOLs? How many disks per VG, how many alternate pathes. Do you have more alternates than supported? This would require additional checks! Do you run 11.31? In this case you don't need to check and create the group files. What maximum disk size you will have in future? How large do you want to have the PE size? Do you want to do any manual load balancing over several pathes? Do you have add. multipathing software?



Only a few questions out of many questions ...

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!   
Mike_305
Super Advisor

Re: Script for VG and LV create

Hello All,

Running 11.23

Thanks for your help. I did not want get too complicated on this. I have script like this and it is bunch of â for loopsâ .
What I wanted is few idea on how can prompt the script so that I can enter VG name and minor numbers mknod command. If I can prompt then I don't have put that in script.

Also want to find out how prompt with "question" if you want to continue ot not, and if the answer is "NO" then exit 0, with running any commands.

I am doing mkdir and mknods manually.

Thanks in advance for your time and help.

===============================
set -A disk $(cat /tmp/disk)

sleep 2

for disk in ${disk[*]}
do
pvcreate /dev/rdsk/${disk##*/}
sleep 2
vgcreate -e 9600 -p 32 -s 32 /dev/$VG_NAME /dev/dsk/${disk##*/}
sleep 2
sleep 2
done
==============================
for X in 1 2 3
do
lvcreate -L $LV_SZ_lvol${X}_a -n lvol${X} /dev/$VG_NAME
sleep 5
done
===============================
for X in 1 2 3
do
newfs -F vxfs -o largefile /dev/$VG_NAME/rlvol${X}
sleep 10
done
If there is problem then don't think as problem, think as opportunity.
James R. Ferguson
Acclaimed Contributor
Solution

Re: Script for VG and LV create

Hi:

> What I wanted is few idea on how can prompt the script so that I can enter VG name and minor numbers mknod command...

You could use something like this:

#!/usr/bin/sh
typeset VGNAME
typeset MINORNBR
typeset -l REPLY
while true
do
echo "Enter VG Name: \c"
read VGNAME
echo "Enter minor #: \c"
read MINORNBR
echo "The VG NAME will be '${VGNAME}'"
echo "The minor # will be '${MINORNBR}'"
echo "Continue y|n: \c"
read REPLY
[ "${REPLY}" = "y" ] && break || exit 0
done
echo "now continuing..."

Regards!

...JRF...
Mike_305
Super Advisor

Re: Script for VG and LV create

Hello James,

After your suggestion, it was good but still trying to fix 2 things. I have worked around for the issue but since I am putting all these pieces in place, might as well do this one to.

Thanks for your help in advance

If anyone else has any suggestion please let me know.

Appreciate your help and time.

============================
Q-1 What is the best way to grad the next available MINOR NUMBER out of my mknod listing? I am running following.

ls -l /dev/*/group | awk '{printf "%s\n", $6}' | sort â n
==============================
Q-2 For my LVOL creations I have lvol sizes are in the scrips and that is working fine when I have following.

lvcreate -L $LVSZ_1 -n lvol1 /dev/$VG_NAME â (Manual Command works fine)

lvcreate -L $LVSZ_2 -n lvol2 /dev/$VG_NAME

LOOP is not grabbing my LVOL size that was set in variables.

for X in 1 2 3
do
lvcreate -L $LVSZ_${X} -n lvol${X} /dev/$VG_NAME
done
=================================
If there is problem then don't think as problem, think as opportunity.
Mike_305
Super Advisor

Re: Script for VG and LV create

THX 4 all your help.
If there is problem then don't think as problem, think as opportunity.