Operating System - HP-UX
1834512 Members
2052 Online
110068 Solutions
New Discussion

How to find the physical drive for a directory

 
Randy Hagedorn
Regular Advisor

How to find the physical drive for a directory

Hi,
Somehow I have misconfigured one of my systems.

I have a directory /f01 that is listed under the root directory and is functional for creating files, etc. When I do a bdf command it is not listed and is not listed in my /etc/fstab nor /etc/mnttab files.

Since this directory is not where it think it is, how can I tell which volume group it belongs to and which physical disk the data is sitting on?

Thanks,
Randy
8 REPLIES 8
Pete Randall
Outstanding Contributor

Re: How to find the physical drive for a directory

Randy,

As you describe it, it's not a mounted file system and therefore must reside in your root directory: /. That's not good. I would remove it and re-create it elsewhere before you start loading anything there, other wise you risk filling your root filesystem and crashing the machine.


Pete

Pete
Patrick Wallek
Honored Contributor

Re: How to find the physical drive for a directory

Do an:

# ll -d /f01

and see if it is a link to another directory. If it is you will see something like:

/f01 -> /some_other_directory

Something else to try:

# cd /f01
# bdf .

See what filesystem comes up from the bdf command.
Gregory Fruth
Esteemed Contributor

Re: How to find the physical drive for a directory

"bdf filename" and "df filename" will print
the filesystem that "filename" resides on.
You will have to parse the filesystem name
to see if it's NFS or local, and if local,
to get the name of the volume group.

If you want to do this from C then I believe
you will have to use stat(), statvfs() or
somesuch.

Determining the physical disk a file resides
on does not make sense because a logical
volume can span more than one disk, can be
mirrored on multiple disks, etc.
Bill Hassell
Honored Contributor

Re: How to find the physical drive for a directory

It is VERY likely the directory and file are in the / directory. The command:

bdf /f01

will show you the mountpoint (probably /). For a directory to be listed in bdf and fstab, it must be a mountpoint, that is, a separate logical volume. If /f01 is going to have more than a few Kbytes in it, consider moving it to a different directory such as /var (like /var/f01). If you can't change your applications that refer to this directory, you can move the directory:

mv /f01 /var

Then create a symbolic link so it look the same:

ln -s /var/f01 /f01

Now, /f01 will look the same but physically reside on /var (bdf /f01)


Bill Hassell, sysadmin
Devender Khatana
Honored Contributor

Re: How to find the physical drive for a directory

Hi Randy,

If you have allocated this for some application and do not want to assign it to some other file system. Then you can do this also.
Find out or create logical volume on which you actually wanted to put it. If file system is not there then you may create it freshly using some free disk space. Then mount that file system on some other mount point say /f02, copy all files from /f01 to /f02 using cpio or any other convient method and now umount file system from /f02 and mount it on /f01. Also make entry in /etc/fstab for auto mounting.

After successful completion and checking applications, having stop applications umount /f01 then move /f01 to some other directory say /f03(For removing safely) and recreate a directory /f01 and remount file system /f01 and start application. When everything is fine then you can remove the directory where you moved original (here /f03). This will surely make sense if your /f01 is taking a lot of space in your root.

HTH,
Devender

HTH,
Impossible itself mentions "I m possible"
Ashish Jain
Advisor

Re: How to find the physical drive for a directory

cd /f01
bdf .

This will show the information for the filesystem of which /f01 is a part of.

Ashish
KapilRaj
Honored Contributor

Re: How to find the physical drive for a directory

i would

cd /etc; ls -l fstab*

to see if any of my sysadmin collegues removed the filesystem and were kind enough to leave a copy there

Regds,

Kaps
Nothing is impossible
Randy Hagedorn
Regular Advisor

Re: How to find the physical drive for a directory

Thanks for all the help with this problem.

It looks like when I wanted to create a new logical volume, I created what I wanted for a mount-point, but did not actually mount it to where it should have been, so it stayed 'mounted' to root.


Randy