Math 300: File Systems (back to Math 300 notes)

Most operating systems are designed to store collections of data. Such collections are usually called files. These files may come in a variety of sizes, formats, and compositions. Typically these files are stored on magnetic media - disks - organized into file systems. It is beyond the scope of our course to discuss file systems in detail, but there are several aspects of which any sophisticated computer user must be aware.

The most obvious aspect of disk storage for the user is the presence of several different disks on any given computer. Most computers possess one or more hard disks, floppy drives, zip drives, CD drives, and/or DVD drives. These might be formatted differently, and might even be incompatible. For example, the computers you use today have both Linux and Windows operating systems on them, with CD drives and floppy drives. They also use some network storage.

Another critical issue for a computer user is the organization of the file system into disk partitions and directories. A partition is a physical separation of one group of data from another on a disk or disks. Partitions might be two different areas of the same disk, they might be two separate disks, or they might represent disks on entirely separate machines.

A third aspect of filesystems that the user has no choice but to understand is the directory structure of the filesystem. Every filesystem organizes the files into directories, or folders. Directories are a purely logical structure. Indeed, files from separate directories might be stored physically on the disk in an interlacing pattern. The directory structure is purely to help the user and the operating system be organized and rational.

The different disks and partitions on a computer might be formatted differently. For example, the dual-boot computers you use have one hard disk, a floppy disk drive, and a CD drive. These are (or are typically) formatted as follows.

Floppy disk FAT16 - File allocation table filesystem, using 16 bit addressing
Compact Disk ISO966 file system - almost universal for CDs
Windows partitions of hard disk NTFS - the NT file system. This uses longer addresses to handle larger disks.
Linux partitions Ext3 - the extended Unix file system.

In Windows, separate devices, such as the floppy drive, and partitions of disks are represented to the user through the drive letter. Everyone is familiar with the C: drive, which is usually the only partition on the hard drive of the computer. On the other hand, it is possible for the hard drive to have several partitions, in which case more than one drive letter appears in the the explorer.exe display. For example, the server Walt for this laboratory has two disks divided into five partitions, labeled the C:, D:, I:, P:, and U: drives. When you look at your computer, you should find that there is a C: partition as well as a U: partition. Likewise the floppy drive is usually labeled A:, while the CD drive is labeled D:.

Within any one of these drives lies a heierarchical directory structure. In Windows, directories are commonly called folders. Each folder provides an organizational space that may contain files or other folders. The top level directory for a given partition or device is labeled "\" (pronounced "backslash"), and directories contained in that top level folder have their names preceded by the backslash. The drive letter is sometimes understood, but if greater clarity is required, it may be prepended. Thus you should find directories on your Windows filesystem at C:\netscape and C:\winnt. Subfolders of these can be refered to simply by appending more backslashes and names. For example, the winnt folder contains another folder called system32. We can refer to the latter folder uniquely using its specification relative to the partition: C:\winnt\system32. Likewise, the netscape folder contains a subfolder called program, which contains a file called netscape.exe, which we may speficy uniquely using the notation C:\netscape\program\netscape.exe. This unique expansion describing the position of a folder or file in the directory structure is called the path to the folder or file.

By contrast, in Unix partitions and devices do not appear separated to the user. Indeed, your Unix storage should appear to be one big directory structure, with no distinction among files, directories, and devices. This is part of the genius of the design of Unix: devices, partitions, and directories are all represented simply as files. The top level directory is labeled "/" (slash) and is always in the main partition of the hard drive. This is called the root directory of the filesystem. Your machines have many subdirectories of the root directory, labeled analogously to the way Windows does: /usr, /var, /mnt, and so on. These directories have more subdirectories in turn. For example, /mnt/cdrom is where you would find a CD if you put it in the drive. Likewise, /mnt/floppy is where you would find the floppy disk. It turns out that your Unix filesystem uses three separate partitions: though /var looks like just another subdirectory of the root directory, it is also a separate disk partition, as is /usr.

In a command-line environment in either Windows or Unix, the command to look in any given directory is called "cd". To move to the drive letter containing that directory in Windows, you must precede the cd command by a command giving the drive letter alone. Thus, to look into a folder called myfiles on the floppy drive on a Windows machine, you would type

a:

cd myfiles

while to look in the same folder in Unix, you would type

cd /mnt/floppy/myfiles.

Since directories etc. are represented as files, we need special names to refer to the files that represent those directories. The current directory you are looking in is always called ".", while its parent is called "..". For example, if there is a subdirectory of the top level folder called "sub", and if there is a directory in that folder called "mine", you may change to that directory in any of the following ways:

Windows Unix
cd \sub\mine cd /sub/mine
cd \sub\.\mine cd /sub/./mine
cd \sub\..\sub\mine cd /sub/../sub/mine

You get the idea.

The directory you are looking at is called the current directory. You may always specify the path to an object as an absolute path (with the leading "\" or "/") or as a relative path. The relative path tells how to get to the object from the current directory. Thus in the previous example, if your current directory were /bin, then you could get to the mine directory using any of the following commands.

Windows   Unix
cd \sub\mine Absolute Path cd /sub/mine
cd ..\sub\mine Go from /bin to /, then down to mine cd ../sub/mine
cd .\..\sub\mine Extra typing cd ./../sub/mine

Storage may be accessible through a computer network. In that way, one may store files on one computer that are accessible through a large group of computers. For example, your computer has a "U:" drive that actually resides on the server. Likewise, your Unix system mounts several filesystems on the network, which appear at /usr1, /usr2, and /users.