1837140 Members
2237 Online
110112 Solutions
New Discussion

identify free disk

 
SOLVED
Go to solution
lawrenzo_1
Super Advisor

identify free disk

Hello,

I want to create a new filesystem - I know the procedure for this however I want to discopver how much free disk is assigned to the server.

When I run ioscan I get lots of disk so is there a script or something I can use to identify what is free.

thanks
hello
8 REPLIES 8
Mel Burslan
Honored Contributor

Re: identify free disk

Lawrenzo,

There are many scripts floating around doing what you are trying to accomplish, unfortunately, I can not remember the locations of any of them myself. But I have a BIG warning. If you are in a serviceguard environment and some of those disk you see in ioscan output were used by the clustered packages, what may seem to be a free disk on one node may actually beused on the other. This is a big CAUTION.

Otherwise, I am sure someone will let you know where you can find the garden variety of these scripts.
________________________________
UNIX because I majored in cryptology...
Rick Garland
Honored Contributor

Re: identify free disk

I will second the warning. MC/SG environment be very sure of the disk you are choosing.

If no MC/SG, what you can do is correlate the /dev/dsk values from the vgdisplay -v output with the ioscan -fnCdisk output.

Those disks not in vgdisplay output but in the ioscan output as CLAIMED will be unassigned disks to a system.

Again, no MC/SG (or any kind of clustering) in the environment!
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: identify free disk

I'm not good enough to write a script that would do this and I wouldn't trust anyone else's script either. I can tell you what to look for but it's not a fully inclusive disk.

Is it used by LVM?
Is it used by VxVM?
Is it used as swap?
It is used as a raw device by Oracle, Informix, etc?
It is used as a raw device by some other application?
As mentioned, if this is part of a ServiceGuard cluster you have to be extra careful.

You start with an ioscan to see what is visible but by far the most difficult to determine are those disks used as raw devices.

This really comes down to system documentation and then not trusting it either, you follow up with careful tests of your own (vgdisplay's, swapinfo, bdf's + looking at Oracle/Informix/etc.).
If it ain't broke, I can fix that.
Juan M Leon
Trusted Contributor

Re: identify free disk

Lawrenzo: I believe your co-workers in US (I assume that you are in MBNA UK) have a script to identify free disk. I believe they also have a NFS filesystem that is accessible for your corporation. You can find variety of scripts for different needs. Hope it helps.

Basheer_2
Trusted Contributor

Re: identify free disk

1) run ioscan - list all avail
ioscan -funC disk| grep -E -v "disk|Class|==="|awk '{print $1}'|sort

2) list used ones
vgdisplay -v |grep "PV Name" |awk '{print $3}'|sort

compare the output of each, u will know which one is not used

hope it helps
Basheer
Mel Burslan
Honored Contributor

Re: identify free disk

if your disk structure is fully LVM type, i.e., you do not have any HFS disks in the mix, this following set of commands will do the trick for you:

# works only for LVM disk structures
strings /etc/lvmtab >/tmp/disks.lst
for hwp in `ioscan -fknC disk | grep ^disk |awk {'print $3'}`
do
devdrv=`ioscan -fknH ${hwp} | tail -1`
blockdevice=`echo ${devdrv}|awk {'print $1'}`
rawdevice=`echo ${devdrv}|awk {'print $2'}`
diskid=`echo ${blockdevice}|cut -d/ -f4`
grep -q ${diskid} /tmp/disks.lst
r=${?}
if [ ${r} -eq 0 ]
then
echo "DISK "${diskid}" is already in use"
else
echo "DISK "${diskid}" is available"
fi
done


hope this helps
________________________________
UNIX because I majored in cryptology...
A. Clay Stephenson
Acclaimed Contributor

Re: identify free disk

I will repeat my warning. All of these scripts will tell you some of the disks that might be available but it's the raw disks in use that will get you in trouble everytime.
If it ain't broke, I can fix that.
lawrenzo_1
Super Advisor

Re: identify free disk

Thank you all for your feedback,

The system is clustered so I will go to our capacity team who will have the free disk info.

Lawrenzo
hello