Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Specifically: I did sudo mkdir /work, and would like to verify it indeed sits on my harddrive and not mapped to some other drive.

How do I check where this folder is physically located?

share|improve this question
add comment

1 Answer

The df(1) command will tell you the device that a file or directory is on:

df /work

The first field has the device that the file or directory is on.

e.g.

$ df /root
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              1043289    194300    795977  20% /

If the device is a logical volume, you will need to determine which block device(s) the logical volume is on. For this, you can use the lvs(8) command:

# df /usr
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/orthanc-usr
                       8256952   4578000   3259524  59% /usr
# lvs -o +devices /dev/mapper/orthanc-usr
  LV   VG      Attr   LSize Origin Snap%  Move Log Copy%  Convert Devices     
  usr  orthanc -wi-ao 8.00g                                       /dev/sda3(0)

The last column tells you that the logical volume usr in the volume group orthanc (/dev/mapper/orthanc-usr) is on the device /dev/sda3. Since a volume group can span multiple physical volumes, you may find that you have multiple devices listed.

Another type of logical block device is a md (Multiple Devices, and used to be called meta-disk I think) device, such as /dev/md2. To look at the components of a md device, you can use mdadm --detail or look in /proc/mdstat

# df /srv
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/md2             956626436 199340344 757286092  21% /srv
# mdadm --detail /dev/md2
...details elided...
    Number   Major   Minor   RaidDevice State
       0       8        3        0      active sync   /dev/sda3
       1       8       19        1      active sync   /dev/sdb3

You can see that /dev/md2 is on the /dev/sda3 and /dev/sdb3 devices.

There are other methods that block devices can be nested (fuse, loopback filesystems) that will have their own methods for determining the underlying block device, and you can even nest multiple layers so you have to work your way down. You'll have to take each case as it comes.

share|improve this answer
1  
+1. Interesting. I didn't know df was so accomodating. –  Faheem Mitha Apr 14 '11 at 10:34
    
OK, I did that and got /dev/mapper/fun-root as my Filesystem. Now what? (My computer's name is 'fun') –  ripper234 Apr 14 '11 at 11:37
1  
Then perhaps you are using LVM? lvdisplay or lvs will be your friend. –  phunehehe Apr 14 '11 at 13:38
    
Very helpful, thanks camh! –  Brian Lacy Nov 29 '12 at 18:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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