Solved

Physical device of file

Posted on 2004-03-24
5
390 Views
Last Modified: 2013-12-06
Hi Everyone,

Could anyone tell me which command will tell me which physical device a file resides on?

In particular, I have a database sitting on a SAN, and I want to see which disks different database files reside.

Thanks!
0
Comment
Question by:marcus78
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:Alf666
ID: 10670893
df <filename>

This will give you the Filesystem in the first column.
This is not df's main use, but it works pretty well.
0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 10671566
df will tell you the filesystem, but not the physical device.

Once you've got the filesystem from df, you can get the /dev device the filesystem is mounted on using the mount command.

Sometimes this will tell you the phyical device (/dev/sda3).

Sometimes this will tell you a logical device and you'll have to keep digging (/dev/vx/dsk/rootdg/lv_home). How you get the physical device from the logical device varies widely from one Unix flavor to another, from one version to another of the same flavor, etc.
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10671634
chris, I don't know which system you're using, but, yes, df will give you the filesystem on most UNIXes :

> df .bashrc

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda2             19036436   3672780  15363656  20% /
0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 10671688
Oops, you're right, most df's will give you the device these days.
Still need to deal with logical volumes, though.
0
 
LVL 21

Accepted Solution

by:
tfewster earned 125 total points
ID: 10671692
Which Unix?  Alf666 has given you the first part; The next step is to work out what LUNs/ disks the filesystem uses.  Assuming you're using journalled filesystems based on Veritas volume manager, work out what logical volume the filesystem is on, then what logical disks the logical volume uses.  Under HP-UX you'd use "lvdisplay -v /dev/vg_name/lv_name" - See http://bhami.com/rosetta.html#files  for hints as to the commands for other Unixen.

Finally, you need use your SAN management tools to work out what physical disks those logical disks are made up of, e.g. slices of a RAID 5 set. Then you're in a position to be able to predict hotspots and move data around on the disk array to improve performance.  Bearing in mind that the cache on a disk array and buffer caching on the Unix server will mask and ease the load on a particular spindle...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FTP on FreeBSD server 2 152
Sed question 2 122
unable to put logic for reading multiple repo in a single file 4 66
remove one line from a file in solaris 8 57
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question