Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I check if some folder in Linux is on a shared disk or a local disk?

share|improve this question

migrated from Sep 21 '11 at 4:29

This question came from our site for professional and enthusiast programmers.

What kind of shared disk is it? (Samba, NFS etc.) Can you give an example of the folder's path and also include the output of df if it's mounted. – ed. Sep 20 '11 at 18:05
I don't know. Only some disks are shared, some are physical, presented local – user710818 Sep 20 '11 at 19:27
are shared network disk – user710818 Sep 20 '11 at 19:27
Can you post the output of "df" here? – ed. Sep 20 '11 at 19:28
If you are asking a programming question this should stay on StackOverflow. If this is a question about how to do it from the GUI, command-line or other, then it should be moved to SuperUser or ServerFault – Zan Lynx Sep 20 '11 at 20:54
up vote 2 down vote accepted

You can tell whether a folder is on a local disk by looking up the filesystem type. The first part of the answer is to find what filesystem contains the folder. To do that you need to find the filesystem using the st_dev field of the stat information for the folder. (You can also do this by checking the folder path, but you then have to check every path element for symbolic links).

You can then cross-reference the st_dev field with the mount table in /proc/mounts using getmntent_r(). There's an example of that in a previous answer. The mnt_type field will give you the text of the filesystem type, and you can compare the string with a list of network filesystems.

You can tell more information about FUSE filesystems by looking at the mnt_fsname field, but there are a lot of FUSE filesystems. You may want to treat them all as network storage. You'll have to make your own call about cluster filesystems such as GFS.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .