Operating System - HP-UX
1753797 Members
7828 Online
108805 Solutions
New Discussion юеВ

Re: Script for LV creation from old vg to new VG

 
SOLVED
Go to solution
kumar_unix
Occasional Contributor

Script for LV creation from old vg to new VG

Hi ,
Please let me know if we have any script for creating LVs

I am doing the migration from one VG to another . I have stuck @ lvcreation . I need the same LV's to be created with same name and size on the new VG's.

while creating the new LV the script should take the info/parameter from the old VG's like size and name of the LV and create the same in the new VG.

I have tried some scripts but no luck. BTW, its huge migrations like we have around 50 VG with 5000 Vols of 20TB storage .

Really it will be helpful if somebody can help me out in this situation .

please let me know if you need more info .

Thank you
Kumar


9 REPLIES 9
Raj D.
Honored Contributor

Re: Script for LV creation from old vg to new VG

Kumar,
> I have tried some scripts but no luck.

- could you tell us what you tried that didnot work.
- 50 VG with 5000 Lvol is good enough to keep you busy.
- Basically you have to capture the LV size , and names with awk to prepare the script for same vg_name , lv_name and size for new storage.

Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Script for LV creation from old vg to new VG

Also remember to capture the number of current "stripes" from lvdisplay command. And to be included in the script.
" If u think u can , If u think u cannot , - You are always Right . "
Richard_243
New Member

Re: Script for LV creation from old vg to new VG

KumarK,

You can try for i in loop too with awk .

Steven E. Protter
Exalted Contributor

Re: Script for LV creation from old vg to new VG

Shalom Kumar,

It would help to see the command you are using and the error message.

You should be able to pull vgdisplay and lvdipslay info from the old volume group and feed it into an vgcreate and lvcreate statement to build the volume groups on the new VG.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
kumar_unix
Occasional Contributor

Re: Script for LV creation from old vg to new VG

Old VG = vgprod
New VG = vg_new_prod


for ((i=1;i<=48;i++))
do
echo " lvcreate -L 'vgdisplay -v /dev/vgprod$i |egrep -i "LV Size" |awk '{print $4}'' -I 64 -i 4 -r N -A n -n ' vgdisplay -v /dev/vgprod$i |egrep -i "LV Name" |awk '{print $3}' |tr '/' ' ' |awk '{print $3}'' /dev/vg_new_prod$i "
done
Chandrahasa s
Valued Contributor

Re: Script for LV creation from old vg to new VG

HI,

Vg migration.....
is it like from old storage to new one??
if yes
if you have 11.31 with march 2010 patch

You can do #vgmove

#vgmove is the good method tested and working fine.

chandra
Raj D.
Honored Contributor

Re: Script for LV creation from old vg to new VG

Kumar,

Here you go,
You can check with a small example , and can implement this script to generate the lvcreate commands:




#########################################
#gen_lvcreate :v1.0:


for ((i=1;i<=48;i++))
do
echo "Processing for VG= vgprod$i ..."

vgdisplay -v vgprod$i | grep -i -e "LV Name" -e "LV Size" | cut -c 32- | awk 'ORS=NR%2?FS:RS' | tr "/" " " | awk '{print "lvcreate -L "$4 " -I 64 -i 4 -r N -A n -n " $3 " /dev/vgprod$i" }' >> lvcreate_cmds_vgprod$i

echo "$i :: lvcreate command generation done: for Vg=vgprod$i :------------------------------------ \n\n"
done

#Checking generated files:
ls -l lvcreate_cmds*

echo "Done"
#########################################








One Example:
#---------------
$
vgdisplay -v vg08 | grep -i -e "LV Name" -e "LV Size" | cut -c 32- | awk 'ORS=NR%2?FS:RS' | tr "/" " " | awk '{print "lvcreate -L "$4 " -I 64 -i 4 -r N -A n -n " $3 " /dev/vg08" }'

lvcreate -L 139968 -I 64 -i 4 -r N -A n -n lvol1 /dev/vg08
lvcreate -L 139968 -I 64 -i 4 -r N -A n -n lvol2 /dev/vg08
lvcreate -L 139968 -I 64 -i 4 -r N -A n -n lvol3 /dev/vg08
lvcreate -L 139968 -I 64 -i 4 -r N -A n -n lvol4 /dev/vg08
lvcreate -L 139968 -I 64 -i 4 -r N -A n -n lvol5 /dev/vg08
lvcreate -L 139968 -I 64 -i 4 -r N -A n -n lvol6 /dev/vg08
lvcreate -L 139968 -I 64 -i 4 -r N -A n -n lvol7 /dev/vg08
lvcreate -L 0 -I 64 -i 4 -r N -A n -n lvol8 /dev/vg08
$
#######################################################################


Cheers,
Enjoy, Have Fun!,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor
Solution

Re: Script for LV creation from old vg to new VG

Kumar,

Correction:
-(new vgname missed in the earlier post):
- variable inserted inside awk.




#########################################
#gen_lvcreate :v1.1:


for ((i=1;i<=48;i++))
do
echo "Processing for VG= vgprod$i ..."


NEW_VG_NAME=vg_new_prod$i


vgdisplay -v vgprod$i | grep -i -e "LV Name" -e "LV Size" | cut -c 32- | awk 'ORS=NR%2?FS:RS' | tr "/" " " | awk -v VG=$NEW_VG_NAME '{print "lvcreate -L "$4 " -I 64 -i 4 -r N -A n -n " $3 " /dev/" VG }' > lvcreate_cmds_vg_new_prod$i

echo "$i :: lvcreate command generation done: for Vg=vg_new_prod$i :------------------------------------ \n\n"
done

#Checking generated files:
ls -l lvcreate_cmds*

echo "Done"
#########################################



cheers,
Raj.






** Remember to assign points to all the posts, once resolved.


" If u think u can , If u think u cannot , - You are always Right . "
kumar_unix
Occasional Contributor

Re: Script for LV creation from old vg to new VG

Thank's a lot Raj !!! it worked .. really this script helped a lot for me ..

thank u
Kumar