1833875 Members
3302 Online
110063 Solutions
New Discussion

Re: lvcreate script

 
SOLVED
Go to solution
Donald C Nelson
Frequent Advisor

lvcreate script

Does anyone have a script that can recreate logical volumes from a bdf output or vgdisplay output. I will be particpating in a DR excercise and trying to expedite the lvcreate process
5 REPLIES 5
Sanjay_6
Honored Contributor

Re: lvcreate script

Hi Donald,

Have not tried this, but try the script attched by Nick,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=11150

Also get many more scripts for other purposes over here,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=178514

Hope this helps.

Regds
Steven E. Protter
Exalted Contributor

Re: lvcreate script

I love the idea of running lvcreate from bdf output to recreate logical volumes.

Overall concept though.

When I'm doing a DR excercise it involves getting a make_tape_recovery tape from secure off site storage, sticking it in a server tape drive and booting the system off the tape.

That lets be get the entire server setup running correctly in a few hours. Oracle apps, legacy apps, the whole nine yards.

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
A. Clay Stephenson
Acclaimed Contributor

Re: lvcreate script

Bdf alone will not do the job. It knows nothing about swap and raw volumes.
If it ain't broke, I can fix that.
Sundar_7
Honored Contributor
Solution

Re: lvcreate script

I can suggest a quick and dirty script - take it from there :-)

# vgdisplay 2>/dev/null | grep "VG Name" | awk '{print $3}' | xargs -n1 | while read VG
do
VGNAME=$(echo "$VG" | sed 's/\/dev\///')
vgdisplay -v $VG | egrep "LV Name|Current LE" > /root/$VGNAME-LV.list
done

Now once you are done restoring the ignite in the DR server

# for VGS in $(ls /root/*LV.list)
do
cat VGS | xargs -n2 | while read LV SIZE
do
VGNAME=$(echo "$VGS" | sed 's/\-LV\.list//')
LVNAME=$(echo "$LV" | sed 's/\/dev\/vg.*\///')
lvcreate -l $SIZE -n $LVNAME /dev/$VGNAME
done
done

Remember, the above excerpt will not take care of striping or extend allocation policies or mirroring. But one would assume that is not critical for the DR tests.

I am not sure the above script is not going to work either :-).
Learn What to do ,How to do and more importantly When to do ?
Donald C Nelson
Frequent Advisor

Re: lvcreate script

Sunar's scripts with a some modifications gave me exactly what I was looking for.