Main index

Introducing UNIX and Linux


Files

Overview
The UNIX directory hierarchy
Filesystems
Manipulating files
      Creating directories
      Creating files
      links
      'Dot' files
Protecting files
      Groups
      File access control
      Changing privileges
File contents
      Text files
      Comparing files
      Filtering files
      Non-text files
Printing files
File archives and file compression
Other relevant commands
Summary
Exercises

Filesystems

UNIX does not have the notion of 'a disk' that the programmer is allowed to work with. Not only is this concept somewhat vague, but developments in hardware and in storage devices may well mean that thinking in terms of disks might be inappropriate in the future. Instead, it uses the concept of a filesystem, within which inodes are unique, and which is named and known by the machine, and associated with a specific directory in the file hierarchy. Each filesystem is set up with an allocated amount of storage space which the user cannot change.

When manipulating files, you will occasionally get error messages telling you that a filesystem is 'full'. In order to discover the amount of free disk space we can use the command df ('disk free'), which will also give information on which filesystems are set up for the system:

df
Filesystem   1k-blocks    Used Available Use% Mounted on
/dev/id000a      10637   10103      -529 106% /
/dev/id001b     186723  155666     12385  93% /usr
/dev/id000f      93033   42924     40806  51% /export
/dev/id000d      46508   15384     26474  37% /var
/dev/id001a     373463  266931     69186  79% /usr
/dev/id001h     124263   93306     18531  83% /usr/local
/dev/id001e      57802   39182     12840  75% /var/tmp
/dev/id000g     747582  600260     72564  89% /home/staff
/dev/id001f      61803   50714      4909  91% /home/ugrad
/dev/sd8e       863422  700676     76404  90% /home/seng
/dev/id002h     560203  456846     47337  91% /home/res
/dev/sd8d       878162  562567    227779  71% /home/acad
/dev/id001d     186723  184473      2250  99% /ex/swap2
/dev/id002f     524542  393609    130933  75% /ex/swap
/dev/id000e      93033   80079      3651  96% /ex/root

We see the storage for the machine divided into the filesystems, and their sizes are listed together with how much of each is in use, and where within the directory hierarchy it is placed. Notice that, in this example, /dev/id000a is more than 100% full - this is not a printer's error! For each filesystem, normally only 90% of the physical space on that device is available. This gives UNIX leeway to warn a user if they attempt to use more of a filesystem than actually exists. Without this extra space, the kernel might find itself without enough workspace to continue, and the system might crash. However, the super-user is allowed to use the final 10% of a filesystem, and the capacity is measured relative to the normally allowed 90% of the filesystem. Although most UNIX systems are set up in this way, the 90% is not cast in stone, and the super-user may change it as local circumstances dictate.


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck