Operating System - HP-UX
1826753 Members
2469 Online
109702 Solutions
New Discussion

How to tell if a disk is being utlised as a raw device or not.

 
SOLVED
Go to solution
Mark Treen_1
Advisor

How to tell if a disk is being utlised as a raw device or not.

Hi All

Question I guess is self explanitory as per the title.

What I am looking for is lets say somebody gives me a device file of a disk. In that moment how can I see if that disk is being used as a raw device or not?

Many thanks as always

Mark
Mark Treen
9 REPLIES 9
MarkSyder
Honored Contributor

Re: How to tell if a disk is being utlised as a raw device or not.

SAM -> Disks and filesystems -> disk devices. If the disc is used for filesystems you will see LVM in the "use" column.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: How to tell if a disk is being utlised as a raw device or not.

You can't. I suppose that you want a little more explanation. You can do the standard vgdisplays, bdf's, swapinfo's, etc. to see if it is being used by the common things. Also check for use by utilities like databases. It's easy to determine if the display is being used by a logical manager (LVM or VxVM) but the real difficultly is if the disk is being used as a raw device by an application and since it is raw, there is really no way to tell.

The answer to your question is to document, document, document and to know the applications that run on your box. It's also a good idea to do something like write a very recognizable bit-pattern to the 1st MB or so of the disk. If you later examine that same disk and the data are unchanged then it's a good bet that the disk is not used.
If it ain't broke, I can fix that.
ricky2
Frequent Advisor

Re: How to tell if a disk is being utlised as a raw device or not.

I cant say its possible but there is some probability you can check by doing the

strings /etc/lvmtab
and in the display u will get the list of volume groups and the associated device..

ricky
James R. Ferguson
Acclaimed Contributor

Re: How to tell if a disk is being utlised as a raw device or not.

Hi:

*Only* physical disks used by LVM are recorded in '/etc/lvmtab'. Then too, if the volume group built from the physical disk has *not* been 'vgimport'ed (or conversely, has been 'vgexport'ed) then no record will exist in '/etc/lvmtab'.

There are ways to read the LVM header (if any) and thus ascertain that the physical disk is an LVM disk, but as Clay noted, the only way to truly know that you have a raw device in use is to *document* it!

Regards!

...JRF...
Jeff Schussele
Honored Contributor

Re: How to tell if a disk is being utlised as a raw device or not.

Hi Mark,

Well we've never used raw disks but I wonder if

lsof /dev/rdsk/cXtYdZ
or
lsof /dev/dsk/cXtYdZ

would yield any results?
Seems to me if a process had the device file open then lsof ought to see that.
EVERYTHING in UNIX is a file & that includes devices, pipes & sockets.

My $0.02,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
A. Clay Stephenson
Acclaimed Contributor

Re: How to tell if a disk is being utlised as a raw device or not.

lsof is another tool but all it can really tell you is the device is not being used at that moment --- multiple lsof's would give you greater confidence but that is still not definitive.

The least evil method that I have been able to come up with over the years is to write a known pattern of data to a disk when I first get it and then to look for that same pattern before I use it. I do this with EVERY disk/LUN I get when it is first installed or initialized --- even if I know that I am going to use it immediately. I prefer code (even that inside my head) that does not branch.
If it ain't broke, I can fix that.
Jaime Bolanos Rojas.
Honored Contributor

Re: How to tell if a disk is being utlised as a raw device or not.

Hi!

Basically there is not good way to know what drives is use as a raw device, the best way is to ask your DBA to see what devices he is using.
The other way aroung might be using the fstyp command to see if the devices show an HFS file system or vxfs file system, if it shows something else like unknown, chances are it's a raw device.
Work hard when the need comes out.
Josiah Henline
Valued Contributor

Re: How to tell if a disk is being utlised as a raw device or not.

If you have HP support, they have a tool for viewing the metadata on the drive. It is a good practice to use LVM rlvol instead of rdsk in most instances.
If at first you don't succeed, read the man page.
Volker Borowski
Honored Contributor

Re: How to tell if a disk is being utlised as a raw device or not.

Hello,

first I would check the write permissions of the devicefile. If only root can write to it, it most likely does not belong to a database, because usually a database is running under a diffrent user (but no 100% guarantee).

Run a find for all symlinks on the entire system doing a "ls -l" for these and spool the result to a file. grep for the devicefile afterwards. Usually it is good practise to use a symlink instead of the direct raw-device name, so you can reconfigure without bothering reconfiguration inside the DB.
If you have symlinks pointing to this device this is a potential indication that someone is using it.

In addition you should check for unaccounted lvols on that disk. pvdisplay would be a starter for this to check if there are lvm-structures on it.

Volker