Operating System - HP-UX
1752701 Members
6729 Online
108789 Solutions
New Discussion юеВ

volume group creation script

 
Manju Kampli
Trusted Contributor

volume group creation script

Hi,

I am looking for a script which creates the volume group. Did anyone have such script like this.
I am running out of ideas for creating group file for a new volume group where it has to select next available minor number..

thanks in advance
Never stop "LEARNING"
6 REPLIES 6
Andreas Voss
Honored Contributor

Re: volume group creation script

Hi,

at the attachment a quick and dirty script for determining the next free minor number for creating a vg.
You have to modify it for your purposes.

Regards

Andrew
Vincente Fernandes
Valued Contributor

Re: volume group creation script

First you need to find how many volume groups are there on ur server. do a ls on /dev
It is pretty straight forward can be done from command line also. for help do a man 1M mknod.
1. mkdir /dev/vgname (e.x vg02)
2. mknod /dev/vgname c 64 0x010000

minor number starts with 0x000000 for vg01, 0x010000 for vg01, 0x020000 for vg02 and so on....

Vincente.
Vincente Fernandes
Valued Contributor

Re: volume group creation script

Correction: step 2 of my previous reply should read as
2. mknod /dev/vgname/group c 64 0x010000

also do a "man lvm" for lvm advance options

Re: volume group creation script

Hi,

U can use the following little command to find out the next available vg-id , provided you have used a sequential allocation .i.e., u have not missed any numbers in between.

Try this out...

ll -R | grep group | awk '{print $6}' | sed 's/....$//' | cut -c3- | sort -nr |
head -1

Run this command while in /dev directory to find out the last used vg-id. Increment one and then use it for the group file.

Hope this helps.
Regards,
Sundar






Life is to LEARN , not to LIVE
curt larson
Frequent Advisor

Re: volume group creation script

give this a try:

#!/usr/bin/ksh

ll $(find /dev -name group ) |awk ' { if ( $5 == 64 ) {
printf("%s\n",toupper(substr($6,3,2)));
}
}' | while read num junk
do
echo "ibase=16;$num/1" | bc
done | sort -n | awk ' BEGIN { x=-1; }
{ x++;
if ( x != $1 ) {
x--;
exit;
}
} END {
printf("%x\n",++x);}'

hope all the slashs and such come out ok.
you might want to do a more defined search
then files named group in the //dev directory
with a major number of 64, but that is up to you
nobody else has this problem
curt larson
Frequent Advisor

Re: volume group creation script

with the possibility of several vgs, the ll $(find) might get a "too long line" error
so a little better might be:

minor_num=$( find /dev -name group |while read line junk
do
ll -d $line
done |awk ' { if ( $5 == 64 ) {
printf("%s\n",toupper(substr($6,3,2)));
}
}' | while read num junk
do
echo "ibase=16;$num/1" | bc
done | sort -n | awk ' BEGIN { x=-1; }
{ x++;
if ( x != $1 ) {
x--;
exit;
}
} END {
printf("0x%02x0000n",++x);}' )

print $minor_num
nobody else has this problem