I have a system with symlinks EVERYWHERE, so given a particular directory, is there a simple way to find out what mountpoint this directory is on? Particularly interested in solaris.

2 Answers 2


You can try:

df dirname

It should give the filesystem and mount point of the target of the symlink.

If you want to know the mount point and filesystem of the symlink itself:

df $(dirname /path/to/dirname)

(That's the command dirname and a dummy directory named "dirname", confusingly enough.)

  • yeah, that doesn't help much, the symlinks go forwards and backwards and there are often many ways to get to the same place.
    – Stu
    Feb 5, 2010 at 20:08
  • Did you actually try this? Because it does what you're asking in your question. Seems to work on my OpenSolaris box...but it's running everything on ZFS but I don't think that matters. Feb 5, 2010 at 20:13
  • I just tested with symlinks 3 hops deep between two different zfs pools and multiple filesystems on OpenSolaris and df was properly reporting where the actual directory is. Feb 5, 2010 at 20:19
  • ahhh. I tried the first bit, missed the second bit. What I didn't realize was that df does this itself. My bad. I thought you had to give it a real filesystem only.
    – Stu
    Feb 5, 2010 at 20:51

I know this provides a little more information than you requested. But you could make a simple C program using the realpath() library call. I have done this before to find out exactly where a specific file was. From there it should be a simple matter of determining the filesystem. A sample program would look like:

 * realpath - a program to find the real path

 #include <limits.h>
 #include <stdlib.h>
 #include        <stdio.h>

 main(int argc, char **argv, char **envp)
    void exit();
    char realx[10000];

    printf("\nORIGINAL PATH:\t%s\n",argv[1]);

    printf("Real PATH:\t%s\n",realpath(argv[1],realx));


  • 1
    Or you could use readlink -f
    – user1686
    Feb 7, 2010 at 16:27
  • BTW- readlink is not present on solaris systems
    – mdpc
    Feb 8, 2010 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.