Operating System - HP-UX
1827245 Members
2119 Online
109716 Solutions
New Discussion

Re: Some help on lvol creation

 
SOLVED
Go to solution
Prashant Zanwar_4
Respected Contributor

Some help on lvol creation

Hi,

I have a VG of 200GB, I want to create 50lvols and do a newfs on it.

What method would be best to do it. What type of script shall I use noting that I have naming convention as lvol_000, lvol_001...

Please let me know your suggestions.

Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
11 REPLIES 11
Pete Randall
Outstanding Contributor

Re: Some help on lvol creation

Something like

for i in "lvol_000 lvol_001 . . ."
do
lvcreate
newfs
done

would be the simplest


Pete

Pete
Steven E. Protter
Exalted Contributor

Re: Some help on lvol creation

You should first check your volume group can accomodate that much space. If not, you may need to run vgcreate again and specify a larger pe size

Answer:

lvcreate -C n -n lvol_000 /dev/vg01

I chose the volume group at random.

You just need to put the lvol_000 in a variable and increment your script as you go.

while read -r lvolname
do
# increment variable here
# lvcreate statement here
lvcreate -C n -n $lvolname /dev/vg01
done < file_list_of_lvol


file_list_of_lvol
flat file list 1 lvol per line.

Or you can built the variable name by incrementing a numberic variable in your control loop.

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
Fred Ruffet
Honored Contributor

Re: Some help on lvol creation

Are all LVs gonna have the same size ?
Is there something particular (mirroring ? stripping ?)

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Prashant Zanwar_4
Respected Contributor

Re: Some help on lvol creation

I want to increament the number using counter or some technique. How would i acheive it. I shall not doing anything manually.

Please reply
Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Prashant Zanwar_4
Respected Contributor

Re: Some help on lvol creation

yes they are of the same size.

Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Patrick Wallek
Honored Contributor
Solution

Re: Some help on lvol creation

Here is how I would do it:

#!/usr/bin/sh

i=0

while [[ ${i} -lt 50 ]]
do
## Set LV name
if [[ ${i} -lt 10 ]] ; then
LV=lvol_00${i}
else
LV=lvol_0${i}
fi
## Create LV (specify your VG name here)
lvcreate -L 4 -n ${LV} vg02
## newfs with the rlvol name
newfs -F vxfs -o largefiles /dev/vg02/r${LV}
((i=$i+1))
done

Hopefully everything in the script makes sense.
Sanjay_6
Honored Contributor

Re: Some help on lvol creation

Hi,

you can try this,

#!/usr/bin/sh

typeset -Z3 COUNT=0

while [[ ${COUNT} -lt 050 ]]
do
echo "$COUNT"
lvcreate -n lvol_$COUNT /dev/vg_name
lvextend -L size_in_mb /dev/vg_name/lvol_$COUNT
newfs -F vxfs -o largefiles /dev/vg_name/rlvol_$COUNT
(( COUNT +=1 ))
done


This will create lv's lvol_000 to lvol_049 (50 lvs)
Use your own command between echo "$COUNT" and (( COUNT +=1 ))


Hope this helps.

Regds

A. Clay Stephenson
Acclaimed Contributor

Re: Some help on lvol creation

The other have given you the methods but I'm going to ask why are you doing this. It's rare that 50 equally size LVOL's ever make sense and tend to be a waste of space on the one hand and a constraint on the other when additional space is needed.

You would be much better served by leaving as much space in the VG unallocated so that LVOL's and filesystems can be expanded as needed. If this is a test then perhaps your allocation makes sense; if you are trying to limit resources to users or groups then quotas make more sense.
If it ain't broke, I can fix that.
Prashant Zanwar_4
Respected Contributor

Re: Some help on lvol creation

Hi,

This is not a test. I am in a environment where in a group i need to allocate different FS for development purpose.

Sanjay typeset -Z3 count=0, this is not working, it throws errors. And moreover it increaments till 39 only. I have tried changing it to 50 instead of 050, which works fine.

Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
A. Clay Stephenson
Acclaimed Contributor

Re: Some help on lvol creation

In that case, I'll stick with my original suggestion. Unless you are doing clever things to distribute i/o (which you could also do with multiple PV's and striping within the LVOL) or need raw/io (but you mentioned filesystems so that's out), I would instead use 1 or 2 filesystems, multiple directories with appropriate permissions, and quotas. You have all the separation of multiple filesystems (since to the applications, the filesystem is invisible) and much more flexibility.
If it ain't broke, I can fix that.
Steven E. Protter
Exalted Contributor

Re: Some help on lvol creation

It probably would be helpful at this point if a few questions were answered:

1) What is the setup of this 200 GB disk presented to your machine?

Most disk arrays default to Raid 5 and its probaly striped over a lot of disks. This won't provide awesome performance but it will work for most applications other than intense database oltp.

2) Do you need raw disk space or cooked with a filesystem? That doesn't affect the lvcreate commands.

If you as is recommended now have the striping handled at the hardware level, then Patrick's script is all you need to quickly create 50 logical volumes.

If you need to handle performance on a software level then its back to the drawing board.

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