LVM and VxVM

Re: Script to discover unused disks?

 
SOLVED
Go to solution
dictum9
Super Advisor

Script to discover unused disks?


I need a script which will correlate disks to VGs and also list unused disks.

I know I can do some commands like ls /dev/dsk/* but I need a script which will understand alternate links.
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor
Solution

Re: Script to discover unused disks?

Hi:

First, define "unused". If we are talking about LVM disks, then if you do a 'vgexport' the LVM headers are still on the physical disk and can be read, but that doesn't define "unused".

If you have any raw disk devices then the only sure way to identify them is to _document_ the devices somewhere.

As for alternate links, these are only paths that lead to the _same_ physical volume. Hence interrogating the LVM PVID and/or LVM VGID in the case of LVM disks, yields the same ID.

Regards!

...JRF...
Shailendran V Naidu
Frequent Advisor

Re: Script to discover unused disks?

Hi,
If you have Base VxVM installed on your machine, You can also use the following command:

# vxdisk list
DEVICE TYPE DISK GROUP STATUS

c3t3d0 auto:cdsdisk - - online <-- Initialized by VXVM but unused
c3t8d0 auto:LVM - - LVM <----- Initialized and in use by LVM
c5t0d0 auto:none - - online invalid <--- Free disk
Bernhard Mueller
Honored Contributor

Re: Script to discover unused disks?

Hello,

maybe you find this one useful.

Regards,
Bernhard
Suraj K Sankari
Honored Contributor

Re: Script to discover unused disks?

Hi,

Please assign some points who give there valuable time for your problem.

http://forums13.itrc.hp.com/service/forums/helptips.do?#33

Suraj
Rita C Workman
Honored Contributor

Re: Script to discover unused disks?

"unused" is really such an open term. You don't mention alot about your storage environment.

What you can see from a server perspective may very likely not tell you about unused disk if you have SAN attached storage. There could be disk on your array that has not been mapped and/or masked. So sitting at the command line running a script that is geared to LVM or VxVM commands will only reflect the disk that the server has masked.

You may need to check both views. What the server(s) can see using LVM/VxVM scripts - and - if there is any disk available on an array.

Rgrds,
Rita
Darren Etheridge_2
Super Advisor

Re: Script to discover unused disks?

I use a few scripts attached. Tar these files into a directory and run the check_devs.sh file. It will run xpinfo (if you are using a SAN) on the local system and output a couple files to the /tmp directory.

in /tmp you will see a

_notused_devices.out - list of drives mapped to the system but not used

and

_used_devices.out - list of disks used and mounted to the server

the only thing you have to watch out for is the command devices. Though they show in the unused file, they XP uses them.

Hope this helps!

Darren
saber_lahlib
Occasional Advisor

Re: Script to discover unused disks?

Hi,

If you have a HA Tools instaled in your serveur,
You can use this:

for i in `ioscan -kfnCdisk|grep dev|awk '{print $2}'`
do
Jrdvgid $i
done

If the disk is not used you have this message in the output

/dev/rdsk/c15t0d0 VGID= No LVM information

Best Regards
Florian Heigl (new acc)
Honored Contributor

Re: Script to discover unused disks?

Hi,

If you want I can attach two little scripts for this task.
The first one is my stake at what you needed, but I never got around to make it work flawless, it actually has little bugs :(
- It understands about alternate paths for disks that are used in a VG, but wont figure out alternates for unused disks.
For me it doesnt matter too much.
- to deal with exported VG's it also scans over /etc/lvmconf/ backup files, but this will override previously detected active VG membership. With a level head you'll probably fix that in seconds. :)

The second one is able to scan VGID and PVID of a disk, I at times use it to make 100% sure a given disk is not in use by any system in our landscape.

If someone feels like it I'd happily discuss rewriting parts of these scripts, by myself I just never got it right :)

Of course, these come without any promises, merely something for you to start from.

#1 http://rabf.net/p/vgsl9b76.html
#2 http://rafb.net/p/9ZBCwI59.html

Best wishes,
Florian
yesterday I stood at the edge. Today I'm one step ahead.