Operating System - HP-UX
1754372 Members
3369 Online
108813 Solutions
New Discussion юеВ

Re: identifying files on a specific disk

 
SOLVED
Go to solution
steven Burgess_2
Honored Contributor

identifying files on a specific disk

hello

I understand that I can use 2 tools to get the location of a file on a disk within an lvol that contains multiple disks

fsdb - allows you to pass the inode number of the file to retrieve the first direct extent (1k blocksize) of the file into the logical volume

ncheck - similar to the above, gives you the sectors in KB, translating to offsets etc

If I have a filesystem that is 143gb, that is currently 40% full.

A disk 17gb disk that has 4339 LE's of which reside between LE numbers 16725 and 21064, starting at 67gb ending at 84gb within the lvol

From this, if I prealloc a 20gb file I know that the space occupied by this file will reside on my 17gb disk, sorted.

However,

Without picking random files and using either fsdb or ncheck how can I check the list of files that reside on a particular disk ?

Thanks in advance

Steve
take your time and think things through
5 REPLIES 5
G. Vrijhoeven
Honored Contributor

Re: identifying files on a specific disk

Steve,

I do not now of a tool or a command that could provide you the info, but may be a
dd if=20gbfile of=/dev/null bs=1024k
sar -d
when the server is idle could give you an idea.

Regards,

Gideon
steven Burgess_2
Honored Contributor

Re: identifying files on a specific disk

thanks for the reply

I have covered that with my description in the original post

steve
take your time and think things through
Hein van den Heuvel
Honored Contributor
Solution

Re: identifying files on a specific disk


Hey Steve,

I'm not entirely sure I get what you want, but perhaps the following (and attached) perl script will to the job. Here is a sample run:

$ perl pv_to_file.p /dev/vg_infa/infa > x
$ more x
dsk/c4t6d0 /infa.ipf.7.1.tar.gz
dsk/c7t6d0 /infa.ipf.7.1.tar.gz
dsk/c4t6d0 /infa.ipf.tgz
dsk/c4t6d0 /informatica/pc/.
:

You can then grep or grep -c for a particular disk or file.
In this first example all files lived on one pv, except for one large one, which had extends on both disks in the volume group.

In the next example I had extent based striping, so just about every other file was on alternating disks:

dsk/c73t0d2 /hein/.
dsk/c73t0d1 /sar/.
dsk/c73t0d2 /ora92/.
dsk/c73t0d1 /project_changes.txt
dsk/c73t0d1 /depot/ssh_3_61_11.11.depot
dsk/c73t0d1 /depot/ssh_3_71_11.23.depot
dsk/c73t0d2 /depot/QPK1123_11.23.depot

Close?

The script first examines lvdisplay -v output to create an extent to pv table.
It then uses ncheck to get blocks to filename data. It divides the blocks by PE size to lookup in the le table which pv it is mapped to.

hth,
Hein.


$lv = shift @ARGV;
die "Please provide an lv name" unless $lv;

### cerate an array mapping LE numbers to disks

#LV Size (Mbytes) 130000
#Current LE 8125
#Allocated PE 8125
# LE PV1 PE1 Status 1
# 00000 /dev/dsk/c4t6d0 00000 current

foreach $_ (`/usr/sbin/lvdisplay -v $lv`) {

$size = int($1) if (/^LV Size \(Mbytes\)\s+(\w+)/);
$PE = 1024 * $size/int($1) if (/Allo.* PE\s+(\w+)/);
if (/(\d+) \/dev\/(\S+)\s+(\d+)/){
$disk = $disk_name_to_num{$2};
if (!$disk) {
$disk = keys %disk_name_to_num;
$disk_name_to_num{$2} = ++$disk;
$disk_num_to_name[$disk] = $2;
}
$le[$1]=$disk;
}
}

#name indx inode indx inode blocks name
#UNNAMED 999 42 - - 988864-989327 /informatica/repositoryserver/pm_r_EN.cat

foreach $_ (`ncheck -F vxfs -oblock=- $lv`) {
if (/(\d+)\s+-\s+- (\d+)-(\d+) (\/.*$)/){
$inode=$1;
$beg= int( $2 / $PE);
$end= int( $3 / $PE);
$name=$4;
for ($i = $beg; $i <= $end; $i++ ){
$disk = $le[$i];
#debug print "PE=$PE, beg=$beg, end=$end, i=$i, disk=$disk, name=$name\n";
print "$disk_num_to_name[$disk] $name\n" unless ($seen{$name." ".$disk}++);
}
}
}

steven Burgess_2
Honored Contributor

Re: identifying files on a specific disk

thats pretty nifty, will give it a whirl, but I reckon thats exactly what i was after

deserves 50 points I reckon

Thanks Heine
take your time and think things through
Hein van den Heuvel
Honored Contributor

Re: identifying files on a specific disk

Enjoy. Hope it works for you also.

Some notes:

- Be patient.. the ncheck may take minutes before getting to file entries.

- I haven't thought through what the metadata records (the inodes themselve) mean in the context of you proble.

- I report the disk/file combo's only once, and as seen as I see them. It would be only a minor twea to just maintain this 'seen' array and then report later sorted by disk or array, and including the number of fragments seen.

- It is also a straightforward change to just report a selected disk, or to augment the script with an outer vgdisplay loop to process all the LV's a given PV might be part of.

Cheers,
Hein (no i, z, e, or enken in the end of my name :-).