1825768 Members
2032 Online
109687 Solutions
New Discussion

pvcreate help

 
SOLVED
Go to solution
Chris Fadrowski
Super Advisor

pvcreate help

I am planning on recovering a system at a hot site. they have smaller luns than i have here on setup. i would like to know if there is a way to PVCREATE all 55 devices at one time with a wildcard command. i just don't know the proper command. I want to avoid doing a pvcreate -f /dev/rdsk/cxtxdx individually for each disk.
20 REPLIES 20
Ross Zubritski
Trusted Contributor

Re: pvcreate help

Make yourself a quick for loop as follows:

/dev/dsk/c#t#d#
/dev/dsk/c#t#d#

Put all the disks in a file called x in this example and execute the following

for i in `cat x`
do
pvcreate -f $i
done

enjoy.

RZ
James R. Ferguson
Acclaimed Contributor

Re: pvcreate help

Hi Chris:

How about:

# for DISK in `ls /dev/rdsk`
> do
> pvcreate -f /dev/rdsk/${DISK}
> done

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: pvcreate help

Hi Chris:

How about:

# for DISK in `ls /dev/rdsk`
> do
> pvcreate -f /dev/rdsk/${DISK}
> done

Regards!

...JRF...
Ross Zubritski
Trusted Contributor

Re: pvcreate help

Dang JRF, always a step ahead.... ;)

RZ
Chris Fadrowski
Super Advisor

Re: pvcreate help

but will this trash my disks on vg00 that were created after the make_tape_recovery is complete? I will be doing this most likely after vg00 has been make_recovered.
Chris Fadrowski
Super Advisor

Re: pvcreate help

but will this trash my disks on vg00 that were created after the make_tape_recovery is complete? I will be doing this most likely after vg00 has been make_recovered.
Ian Dennison_1
Honored Contributor

Re: pvcreate help

How about,

for i in $(cat /tmp/diskfile)
do
export j=`echo $i |sed 's/rdsk/dsk/g'`
export LNCOUNT=`strings /etc/lvmtab |grep $j |wc -l`
if (( $LNCOUNT < 1 ))
then
pvcreate -f $i
fi
done

This way, you do not trash your boot disk or any other existing disk (Just a thought)

NOTE: Will not work on system that can view disks from other systems (SAN, FC10, etc)

Share and Enjoy! Ian
Building a dumber user
Ian Dennison_1
Honored Contributor

Re: pvcreate help

First line of loop should be

for i in $(ls /dev/rdsk)

Sorry, rehashed the thing halfway through. Ian
Building a dumber user
Ian Dennison_1
Honored Contributor

Re: pvcreate help

First line of loop should be

for i in $(ls /dev/rdsk)

Sorry, rehashed the thing halfway through. Ian
Building a dumber user
James R. Ferguson
Acclaimed Contributor

Re: pvcreate help

Hi (again) Chris:

Ooops, you want to exclude your boot disk! Therefore, once you know its disk (e.g. c0t6d0) do:

#!/usr/bin/sh
for DISK in `ls dev/rdsk`
do
[ "${DISK}" != c0t6d0 ] && pvcreate -f /dev/rdsk/${DISK}
done

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor
Solution

Re: pvcreate help

Hi (again) Chris:

Ooops, you want to exclude your boot disk! Therefore, once you know its disk (e.g. c0t6d0) do:

#!/usr/bin/sh
for DISK in `ls dev/rdsk`
do
[ "${DISK}" != c0t6d0 ] && pvcreate -f /dev/rdsk/${DISK}
done

Regards!

...JRF...
Ross Zubritski
Trusted Contributor

Re: pvcreate help

Just exclude your root disk from your config file.

Regards.

RZ
Ross Zubritski
Trusted Contributor

Re: pvcreate help

Just a side note, pvcreate -f will not trash a disk with boot info on it. Confirmed with HP.

Regards,

RZ
Chris Fadrowski
Super Advisor

Re: pvcreate help

[ "${DISK}" != c0t6d0 ] && pvcreate -f /dev/rdsk/${DISK}

not good at scripting but does this statement mean, "do NOT include disk c0t6d0" ???? Just need to verify.


All these disks will be on an EMC Sym with only one internal used for vg00.
S.K. Chan
Honored Contributor

Re: pvcreate help

Do a multiple loop .. for example say you want to pvcreate c[1-3]t[0-4]d[0-2] you can run ..
# for i in 1 2 3
> do
> for j in 0 1 2 3 4
> do
> for k in 0 1 2
> do
> pvcreate -f /dev/rdsk/c${i}t${j}d${k}
> done
> done
> done
Any devices not found in the range will just come back with any error "couldn;t open physical volume", no harm done.
Just any idea ..
Ross Zubritski
Trusted Contributor

Re: pvcreate help

!= will exclude that string.

James R. Ferguson
Acclaimed Contributor

Re: pvcreate help

Hi (again) Chris:

[ "${DISK}" != c0t6d0 ] && ppvcreate -f "/dev/rdsk/${DISK}"

...is shorthand for test the variable ${DISK} to be not equal c0t6d0. If that is true then execute the next statement, which in this case is 'pvcreate'.

See the man pages for 'test' for more information.

Regards!

...JRF...
Chris Fadrowski
Super Advisor

Re: pvcreate help

thanks for all the great answers. I tested JRF's answer and it worked well.

I am trying to assign points but the ITRC isn't working real well for me today. I will keep trying the rest of the day to get the points out to you guys. thanks again.
John Meissner
Esteemed Contributor

Re: pvcreate help

inq -f_emc | grep ^/dev | awk '{print $1}' > emc.out
cat emc.out | awk '{print "pvcreate -f " $1}' > pvemc.sh
chmod +x pvemc.sh
./pvemc.sh
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: pvcreate help

my prior post is assuming that you have "inq" (an EMC utility) installed.
All paths lead to destiny