sections in this module City College of San Francisco - CS260A
Unix/Linux System Administration

Module: Filesystems I
module list

Overview of Filesystems

At the user level, the term filesystem refers to the Unix filesystem. This is the hierarchy of files and directories that begins at the root directory (/) and comprises every piece of data on the system. It is organized in an inverted tree structure. To the user, this hierarchy appears as one tree. However, the Administrator knows that this is an illusion. The hierarchy actually is put together in pieces with hard boundaries between them, rather than existing as one seamless tree. The Unix filesystem is a logical filesystem comprised of one or more physical filesystems. In this module we will be learning about these physical filesystems.

Note: as elsewhere in these notes, all references to kB, MB, GB, etc refer to the power-of-two counterpart, whose names have been changed by some idiots at a standards organization with nothing better to do than make life difficult. You can pronounce them with the 'i' syntax or not.

A physical filesystem is a collection of files' data and the information about them stored on a device. This device may be a separate device, such as a USB pen device, or, more commonly, a partition of a larger device, such as a hard disk. Each physical filesystem is internally consistent. Its filesystem begins at its root, with the hierarchical organization that we are familiar with.

Below is an abbreviated representation of two physical filesystems, on device0 and device1, drawing their structure as if they existed in isolation.

device0 device1

Relative to device0, the path to the file vmunix is /boot/vmunix. Relative to device1, the path to cat.c is /src/cat.c. This is just what we would expect of two Unix filesystems.

The piecemeal nature of the Unix filesystem may come as a surprise to you. To verify this, attempt the following experiment on most any Unix system you choose. (This experiment will produce the result below on our classroom linux systems as well as on hills.)

touch /tmp/myfile
cd
ln /tmp/myfile myfile
rm -i /tmp/myfile    # clean up

Creation of the link fails since your home directory and the directory /tmp are on different physical filesystems.

The Unix filesystem is created by piecing these physical filesystems together. We begin with an empty directory, /. Next, we decide which physical filesystem will be the base piece of the [logical] Unix filesystem, i.e., the root of the filesystem. This piece will be placed at /. From the examples above, we choose the filesystem on device0. This attachment of a physical filesystem to a location in the logical filesystem is referred to as mounting the [physical] filesystem. The attachment point, or mount point can be any directory that already exists. If the physical filesystem is one already known to the system (which we will talk about later), we can use the abbreviated version of the mount command,
mount device directory. Here the command is

mount device0 /

device0 mounted at /
device0 mounted at /

Of course, this first mount, of the root device is special, as everything else relies on it. However, once the root filesystem is mounted, the rest of the filesystem can be pieced together in a straightforward manner. Suppose we wanted to mount our second device like this:

mount device1 /usr

The result is to overlay the structure of the filesystem on device1 onto the existing Unix filesystem so that the root of device1 is attached at the indicated directory:

device1 mounted at /usr
device1 mounted at /usr

Remember that the path to cat.c when device1 was viewed alone was /src/cat.c. After mounting the device at /usr, the path to cat.c  is /usr/src/cat.c

Usually, an empty directory is chosen as the mount point. This is not necessary, however. A second filesystem can be mounted at any directory. If the directory is not empty, its contents is overlaid by the newly-mounted filesystem. As long as the second filesystem is mounted, the original contents of the mount-point are hidden. To access the original contents, you must first unmount the second filesystem:

umount device1
mount device1 /boot

device1 mounted at /boot
device1 mounted at /boot

In the example above, the file vmunix, which is in the /boot directory of the root filesystem, is overlaid by the contents of device1. It will not be accessible until device1 is unmounted.

Normally, filesystems are mounted at system boot, and the entire [logical] Unix filesystem is assembled early in the startup sequence. However, removable devices are accessed in the same way: by attaching them into the Unix filesystem by mounting them. To facilitate this, several empty directories are created in the root filesystem to serve as standard mount points for removable devices. Common locations for these 'temporary mount points' are beneath /mnt, and beneath /media.

Obviously, the management of these filesystems is central to the functioning of any Unix system, and the Administrator must be well-versed in it. This includes:

Although the management of physical filesystems underlies every functioning Unix system, many systems rely on an additional layer of software to abstract the filesystem behavior from the physical limitations. These logical volume managers have become increasingly stable, fast, and common on modern systems. After we understand the physical filesystem environment, we will be equipped to understand how LVMs work.

Preview question: Historically, the Unix filesystem was assembled from multiple physical filesystems simply because a single disk was not large enough to hold the entire filesystem. Today, of course, that is not the case. However, most Unix systems still use multiple physical (or, in the case of an LVM, logical) filesystems. Before proceeding to the next section, write down three reasons why this may be advantageous.

Prev This page was made entirely with free software on linux:  
Kompozer
and Openoffice.org  
Next

Copyright 2011 Greg Boyd - All Rights Reserved.

   Document made with Kompozer