Viewing File Systems with df


Viewing File Systems with df

If you're used to Windows or Macintosh (prior to OS X) operating systems, you're probably accustomed to having separate hard drives (C:, D:, E: for Windows users, or real names for Macs), which are just different storage spaces. In Unix systems, different storage spaces are grafted onto the overall tree structure tacked onto what already exists without any clear distinction indicating where actual disk drives are located. For example, if you have a folder on a Windows computer, you know that all of the subfolders and files within it are located on the same hard drive. In Unix, everything resides within the root directory, but any different directory could be located on a different physical hard drive. You might think of it as tacking a new branch onto your artificial Christmas tree.

These tacked-on storage spaces are called file systems. Particularly if you're running a Unix system (as opposed to just using one), you might need to find out what file systems are in use (or mounted in the system, in technical terms), how much space they have, and where they attach to the Unix system (or where their mountpoints are). You can find out this information using df, as shown in Code Listings 7.3 and 7.4.

Code Listing 7.3. This small Linux system has relatively simple file systems.

[ejr@hobbes ejr]$ df Filesystem    1024-blocks  Used Available Capacity Mounted on /dev/hda1     515161       316297       172255      65%      / /dev/hdb4     66365        4916         58022       8%       /home /dev/hdb1     416656       324633       70504       82%      /usr/local /dev/sbpcd    596704       596704       0           100%     /mnt/cdrom [ejr@hobbes ejr]$ 

To find out about file systems with df:

  • df

    At the shell prompt, type df. You'll usually get output showing you

    • The name of the device, which refers to the physical part that stores the data, such as a hard drive, CD-ROM, or whatever. In Code Listing 7.3 the first one is /dev/hda1, indicating the first hard drive in the system.

    • The number of blocks, which are 1 Kbyte-sized storage units. (1 Kbyte-sized in this case, although some systems report them as 512 bytes.)

    • The number of used and available blocks on the device.

    • The percentage of the space on the device that is being used.

    • The name of the file system, which is the full path name from the Unix system. This is also known as the mountpoint.

Code Listing 7.4. This large ISP's file systems are considerably more complex.

xmission> df /                  (/dev/dsk/c0t3d0s0):  154632 blocks  71721 files /usr               (/dev/dsk/c0t3d0s6):  225886 blocks  144820 files /proc              (/proc          ):    0 blocks       7830 files /dev/fd            (fd             ):    0 blocks       0 files /var               (/dev/dsk/c0t1d0s0):  1001142 blocks 962598 files /tmp               (swap           ):    1236032 blocks 95277 files /usr/local         (/dev/dsk/c0t1d0s5):  630636 blocks  457211 files /archive           (/dev/dsk/c0t1d0s3):  1180362 blocks 1789487 files /var/mail          (mail.xmission.com:/var/mail):       2776576 blocks   1438385 files /home              (krunk1.xmission.com:/home):         20091072 blocks  13066932 files /var/spool/newslib (news.xmission.com:/var/spool/newslib):  19327664 blocks 1248s /.web              (krunk1.xmission.com:/.web):         1019408 blocks   470095 files /var/maillists     (lists.xmission.com:/var/maillists): 293744 blocks    89732s xmission> 

Code Listings 7.3 and 7.4 show the output of df on two different systems.

If you're a system administrator, you can use this information to help diagnose problems occurring in the system. If you're an average user (of above-average curiosity), you can use this information to satisfy your inquisitive inclinations or to tip off a system administrator to problems. For example, if you're getting odd errors or unpredictable results with a specific program, using df might reveal that the /home file system is full or maybe that you don't have the /dev/cdrom file system that you thought was installed and mounted. Hmmm!

Tips

  • You can use df with a specific directory to get a report on the status of the file system containing that directory. For example, you might use df /usr/local/ src to find out where that directory is mounted and how much space is available on it.

  • Use df -k to make sure that the usage is reported in 1 Kbyte blocks, not in 512 byte blocks. Adding the -k flag will also ensure that you get output like that shown in Code Listing 7.3.

  • Use df -h to get "human readable" output. This works with most commands (like ls, for example) that output marginally comprehensible file information.





Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net