Operating System - HP-UX
1833871 Members
1690 Online
110063 Solutions
New Discussion

map a unix file to physical device which this file rsides on

 
SOLVED
Go to solution
shai kedem
Occasional Advisor

map a unix file to physical device which this file rsides on

anyone encountered a method of using sys calls or shell commands to get the unix device file name (i.e. /dev/rdsk/c1t10d0) of a unix file.
7 REPLIES 7
MARTINACHE
Respected Contributor

Re: map a unix file to physical device which this file rsides on

Hi

Try this :

ioscan -fnkCdisk

disk 7 10/8.10.0 sdisk CLAIMED DEVICE SEAGATE ST39173WC
/dev/dsk/c1t10d0 /dev/rdsk/c1t10d0


Class is disk and driver is sdisk



Or try this :

ll /dev/rdsk/c1t10d0
crw-r----- 1 bin sys 188 0x01a000 Aug 21 1998 /dev/rdsk/c1t10d0

then

lsdev -C disk

Character Block Driver Class
177 28 disc3 disk
188 31 sdisk disk

188 means sdisk driver.

Regards,

Patrice.
Patrice MARTINACHE
shai kedem
Occasional Advisor

Re: map a unix file to physical device which this file rsides on

apparently i did not explained myself well -

if I have a unix file name (i.e. /users/shai/test.txt) how do I map it to physical device, considering LVM maybe present or not
John Palmer
Honored Contributor
Solution

Re: map a unix file to physical device which this file rsides on

Hi,

If it's not LVM then /etc/mnttab will contain the disk device name associated with the relevant mount point.

If it's LVM then /etc/mnttab will contain the logical volume name as above. lvdisplay -v will tell you what disk(s) the volume is made up of and what physical extent is on what disk. If there's more than one disk in the volume then the file could be on any, a subset of or all disks.

You'd have to analyse the filesystem itself to determine which blocks make up the file then work out the disks from the volume extent map.
All in all not an easy task!

Regards,
John
Patrick Wessel
Honored Contributor

Re: map a unix file to physical device which this file rsides on

try df -n
it returns the name of the filesystem. The rest is just a bit awk and lvdisplay....
There is no good troubleshooting with bad data
Eddie Warren
Valued Contributor

Re: map a unix file to physical device which this file rsides on

Hi Shai,

You could use " bdf . " on your home path:
example:

bdf .

filesystem kbytes used avail
/dev/vg00/lvol4 32768 31992 776
%used Mounted
98% /home

lvdisplay -v /dev/vg00/lvol4 | more

this will show you the physical device from your path of /users/shai

Best Regards,

Eddie
Steve Post
Trusted Contributor

Re: map a unix file to physical device which this file rsides on

If using lvm, the bdf (or db with options) command tells you the filesystems the files are on, NOT the actual disk. Filesystems are logical volumes. A logical volume could be spread out over a number of physical disks (aka physical volumes).

Run man on vgdisplay, pvdisplay, and lvdisplay.

The physical volumes are space that is sliced up into logical volumes. The logical volumes get converted into filesystems. You mount the filesystems to directories. And your file sits in a directory.

I'm sure there's a document that discusses logical volume management somewhere on this site.
Steve ^_^
Carol Garrett
Trusted Contributor

Re: map a unix file to physical device which this file rsides on


If you are using LVM there there is no concept of a file on a particular disk. It could be on one disk, or more than one disk. Thats the whole idea behing 'logical' volume manager.

If you dont use LVM then its a little easier, as least you know all of your file must be on 1 disk, not across multiple disks. However, this doesnt help you because I dont know of any command to show you which disk a file is on.

There is one possibility. Use a little script which dd's your file and use sar (which lists i/o by disk - not lvm) and see which disk is being hit hard over time, thats almost certainly the one your file is on. Run it at a quiet time though, or else you may not get good results or impact the performance on other processes.

Something like this;

while true
do
dd if= of=/dev/null bs=64k >/dev/null 2>&1
done &

This then runs in the background until you do the fg command then CTRL-C to stop it, or kill it. While its running use;
sar -d 1 10000
and watch the disk i/o traffic. The disk your file is on should be listed almost every time interval. Run it for 30 secs or so and you should have identified the disk your file is on. Not perfect but the only way I know of possibly doing it.