Operating System - HP-UX
1833875 Members
3155 Online
110063 Solutions
New Discussion

Re: Script to identify local disks

 
Brian Mulcahy
New Member

Script to identify local disks

Hi sysadmins,

I own several servers with two internal disks, and I want to automatically mirror my root disk onto another internal disk thanks to a script I wrote which takes a disk device as argument.

The problem is that I do not know how I can determine locally attached disks, as ioscan displays also FC LUNs (when FC paths are scanned). Besides, lssf only displays a HW path, and I don't know how to convert I/O paths into /dev/dsk/cXtYdZ, which is the expected argument to my mirroring script.

Any ideas?

Thank you.

Brian
14 REPLIES 14
Rodney Hills
Honored Contributor

Re: Script to identify local disks

I guess you are talking about LVM mirroring. This would mean any lvm's to mirror will be part of the VG already. Do a "vgdisplay -v vg00" to get a list of physical devices associated with vg00.

HTH

-- Rod Hills
There be dragons...
Todd McDaniel_1
Honored Contributor

Re: Script to identify local disks

I think he wants to find disks not in a VG to use as a mirror for root...

If you have emc and local disks. you can see the diff in the h/w path...and it will say something like SYMMETRIX for the frame disks.


disk 4 1/4/0/0.4.0 sdisk CLAIMED DEVICE SEAGATE ST39236LC
/dev/dsk/c4t4d0 /dev/rdsk/c4t4d0

disk 5 1/4/0/0.5.0 sdisk CLAIMED DEVICE SEAGATE ST39175LC
/dev/dsk/c4t5d0 /dev/rdsk/c4t5d0

disk 6 1/4/0/0.6.0 sdisk CLAIMED DEVICE SEAGATE ST39236LC
/dev/dsk/c4t6d0 /dev/rdsk/c4t6d0

disk 686 1/10/0/0.27.19.0.0.0.0 sdisk CLAIMED DEVICE EMC
SYMMETRIX
/dev/dsk/c58t0d0 /dev/rdsk/c58t0d0

disk 687 1/10/0/0.27.19.0.0.0.1 sdisk CLAIMED DEVICE EMC
SYMMETRIX
/dev/dsk/c58t0d1 /dev/rdsk/c58t0d1

disk 688 1/10/0/0.27.19.0.0.0.4 sdisk CLAIMED DEVICE EMC
SYMMETRIX
/dev/dsk/c58t0d4 /dev/rdsk/c58t0d4

Unix, the other white meat.
Brian Mulcahy
New Member

Re: Script to identify local disks

Yes, Todd, you're right.
I tried something like this:

* ioscan -funC disk
Class I H/W Path Driver S/W State H/W Type Description
=============================================================================
disk 0 0/0/3/0.0.0.0 sdisk CLAIMED DEVICE TEAC DV-28E-B
/dev/dsk/c0t0d0 /dev/rdsk/c0t0d0
disk 1 0/1/1/0.0.0 sdisk CLAIMED DEVICE HP 36.4GMAS3367NC
/dev/dsk/c2t0d0 /dev/rdsk/c2t0d0
disk 2 0/1/1/0.1.0 sdisk CLAIMED DEVICE HP 36.4GMAS3367NC
/dev/dsk/c2t1d0 /dev/dsk/c2t1d0s3 /dev/rdsk/c2t1d0s2
/dev/dsk/c2t1d0s1 /dev/rdsk/c2t1d0 /dev/rdsk/c2t1d0s3
/dev/dsk/c2t1d0s2 /dev/rdsk/c2t1d0s1
disk 183 0/4/1/0.1.16.0.0.0.0 sdisk CLAIMED DEVICE HP OPEN-E
/dev/dsk/c13t0d0 /dev/rdsk/c13t0d0
disk 184 0/4/1/0.1.16.0.0.0.1 sdisk CLAIMED DEVICE HP OPEN-E*3
/dev/dsk/c13t0d1 /dev/rdsk/c13t0d1
disk 185 0/4/1/0.1.16.0.0.0.2 sdisk CLAIMED DEVICE HP OPEN-E*2
/dev/dsk/c13t0d2 /dev/rdsk/c13t0d2
disk 186 0/4/1/0.1.16.0.0.0.3 sdisk CLAIMED DEVICE HP OPEN-E*2
/dev/dsk/c13t0d3 /dev/rdsk/c13t0d3
disk 187 0/4/1/0.1.16.0.0.0.4 sdisk CLAIMED DEVICE HP OPEN-E*2
/dev/dsk/c13t0d4 /dev/rdsk/c13t0d4
disk 188 0/4/1/0.1.16.0.0.0.5 sdisk CLAIMED DEVICE HP OPEN-E*2
/dev/dsk/c13t0d5 /dev/rdsk/c13t0d5
disk 189 0/4/1/0.1.16.0.0.0.6 sdisk CLAIMED DEVICE HP OPEN-E*2
/dev/dsk/c13t0d6 /dev/rdsk/c13t0d6
disk 190 0/4/1/0.1.16.0.0.0.7 sdisk CLAIMED DEVICE HP OPEN-E*2
/dev/dsk/c13t0d7 /dev/rdsk/c13t0d7
(and so on)

I can visually identify local disks /dev/dsk/c2t1d0 and /dev/dsk/c2t2d0, but how can I determine them non interactively? Can I be sure that disks with HW path starting with 0/1/1 are only local disks? Or do I have to deal with ext_bus to make sure that I am browsing a local bus, like in the following example:

* ioscan -funC ext_bus
Class I H/W Path Driver S/W State H/W Type Description
=============================================================================
ext_bus 0 0/0/3/0.0 side CLAIMED INTERFACE IDE Primary Channel
ext_bus 1 0/0/3/0.1 side CLAIMED INTERFACE IDE Secondary Channel
ext_bus 2 0/1/1/0 c8xx CLAIMED INTERFACE SCSI C1010 Ultra160 Wide LVD A6829-60101
ext_bus 3 0/1/1/1 c8xx CLAIMED INTERFACE SCSI C1010 Ultra160 Wide LVD A6829-60101
ext_bus 13 0/4/1/0.1.16.0.0 fcparray CLAIMED INTERFACE FCP Array Interface
ext_bus 14 0/4/1/0.1.16.0.1 fcparray CLAIMED INTERFACE FCP Array Interface
ext_bus 15 0/4/1/0.1.16.255.0 fcpdev CLAIMED INTERFACE FCP Device Interface
ext_bus 16 0/4/1/0.1.24.255.0 fcpdev CLAIMED INTERFACE FCP Device Interface
ext_bus 17 0/4/1/0.1.29.255.0 fcpdev CLAIMED INTERFACE FCP Device Interface
ext_bus 18 0/4/1/0.2.16.0.0 fcparray CLAIMED INTERFACE FCP Array Interface
ext_bus 19 0/4/1/0.2.16.0.1 fcparray CLAIMED INTERFACE FCP Array Interface
ext_bus 20 0/4/1/0.2.16.255.0 fcpdev CLAIMED INTERFACE FCP Device Interface
ext_bus 21 0/4/1/0.2.19.255.0 fcpdev CLAIMED INTERFACE FCP Device Interface
ext_bus 8 0/4/2/0.1.16.0.0 fcparray CLAIMED INTERFACE FCP Array Interface
ext_bus 9 0/4/2/0.1.16.0.1 fcparray CLAIMED INTERFACE FCP Array Interface
ext_bus 10 0/4/2/0.1.16.255.0 fcpdev CLAIMED INTERFACE FCP Device Interface
ext_bus 11 0/4/2/0.1.24.255.0 fcpdev CLAIMED INTERFACE FCP Device Interface
ext_bus 12 0/4/2/0.1.29.255.0 fcpdev CLAIMED INTERFACE FCP Device Interface
ext_bus 4 0/4/2/0.2.16.0.0 fcparray CLAIMED INTERFACE FCP Array Interface
ext_bus 5 0/4/2/0.2.16.0.1 fcparray CLAIMED INTERFACE FCP Array Interface
ext_bus 6 0/4/2/0.2.16.255.0 fcpdev CLAIMED INTERFACE FCP Device Interface
ext_bus 7 0/4/2/0.2.19.255.0 fcpdev CLAIMED INTERFACE FCP Device Interface

And ioscan -Fund c8xx:
pci:wsio:F:F:F:0:0:131072:ext_bus:c8xx:0/1/1/0:16 0 0 33 0 0 0 0 :2:root.sba.lba.c8xx:c8xx:CLAIMED:INTERFACE:SCSI C1010 Ultra160 Wide LVD A6829-60101:2
pci:wsio:F:F:F:0:0:196608:ext_bus:c8xx:0/1/1/1:16 0 0 33 0 87 110 144 :3:root.sba.lba.c8xx:c8xx:CLAIMED:INTERFACE:SCSI C1010 Ultra160 Wide LVD A6829-60101:3

(considering that c8xx is always present within Itanium boxes)?

Or there is maybe a rule that says HW path starting with 0/1, with a "disk" class, is always local?

Thank you for your help.

/Brian.
Marco Santerre
Honored Contributor

Re: Script to identify local disks

Basically, my guess (cause I've never built a script to do this) is that you will have to look into the documentation provided with the hardware to find out which path are always local. This info can be found on these manuals.

The thing is, even though most of them are very similar and most of the time the same, they sometimes also differ. Especially, if you have some newer boxes where you have cells.

So, you'll probably have to built some intelligence in your script to determine which server the script is running on, and then depending on the server, what are its local paths.
Cooperation is doing with a smile what you have to do anyhow.
Jeff_Traigle
Honored Contributor

Re: Script to identify local disks

I was thinking something along the lines of what Marco suggested. Based on output from the model command and knowing what your standard configuration for each is, you should be able to have the script assume predetermined values for the device files. (You can always have it confirm before committing to attempting the mirroring commands.) Perhaps not the most general purpose solution and requires a little bit of script maintenance as new models are implemented in the environment, but it should work.
--
Jeff Traigle
Geoff Wild
Honored Contributor

Re: Script to identify local disks

A work around is to employ disk standards like we have - san attached disks are in vg10 or higher. Local disks vg00 to vg05.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Mohanasundaram_1
Honored Contributor

Re: Script to identify local disks

Hi Brian,

It is not a good Idea to make the script decide on the disk automatically. I have a tried and tested script, which will prompt you to input the original disk device and the mirror disk device.

This script works well for HP-UX 11.00 and 11.11 (PA-RISC platforms only). I can forward that script to you if you need it.

Let me know your interest.

Cheers,
Mohan.
Attitude, Not aptitude, determines your altitude
Mark Grant
Honored Contributor

Re: Script to identify local disks

Maybe I'm missing something here but can't you just do "ioscan -fnkC fc" and then extract the hardware path. Presumabaly all disks that don't start with the same path are not SAN disks. They are probably local if you don't have any other external disk storage.
Never preceed any demonstration with anything more predictive than "watch this"
twang
Honored Contributor

Re: Script to identify local disks

# /usr/bin/strings /etc/lvmtab | grep dsk
Brian Mulcahy
New Member

Re: Script to identify local disks

Hi again:

Thank you for your replies. In fact, I always wondered how Ignite could set internal variable _hp_primary_path to the first internal disk found, as I would have liked to issue the same behaviour to my script.

Mohan, I'd like to have a look at your script. Could you please attach it to a post linked to this thread?

Thank you!

/Brian
Ceesjan van Hattum
Esteemed Contributor

Re: Script to identify local disks

Hi,
Does an output like this help you?:
Disk layout

LVM disk Device file HW Addr size vol. grp
HP 36.4GMAM3367MC /dev/dsk/c1t2d0 0/0/1/1.2.0 34732 /dev/vg00
HP 36.4GMAM3367MC /dev/dsk/c2t2d0 0/0/2/0.2.0 34732 /dev/vg00

It is generated by running "print_manifest" on your machine.
Regards,
Ceesjan
Mohanasundaram_1
Honored Contributor

Re: Script to identify local disks

Hi Brian,


Please find the script attached. It takes the user input for the mirroring.

It may not exactly match your requirement, but it does the mirroring properly.

Cheers,
Mohan.
Attitude, Not aptitude, determines your altitude
Brian Mulcahy
New Member

Re: Script to identify local disks

Hi again Mohan,

Sorry, there is no attachments with your post!
Mohanasundaram_1
Honored Contributor

Re: Script to identify local disks

sorry, here it is. No points for this.
Attitude, Not aptitude, determines your altitude