Physical Devices  «Prev  Next»
Lesson 4The UNIX filesystem
ObjectiveCreate a new filesystem on a floppy disk.

UNIX filesystem using floppy disk

Unix filesystem

The UNIX filesystem (or directory hierarchy) is organized as a single tree of directories and subdirectories, rooted at the directory named "/" (the root directory). Thus, UNIX organizes files differently from, for example, Windows NT, where the filesystem has multiple roots corresponding to the different drive letters. Although the filesystem appears to the user as a single tree, the files and directories on the system are distributed among different physical devices. For example, the files may physically reside on several different physical disk drives, each of which is made up of several partitions. It is perfectly possible for some of the files to reside on completely different types of physical devices, such as CD-ROM drives, floppy drives, or other random access storage devices. Further, some of the directories in the hierarchy may be located on physical disks attached to a remote machine, with access to these directories requiring requests over the network. Regardless of the physical location of files and directories, UNIX creates the illusion of a single, seamless directory hierarchy.
The organization of the UNIX filesystem seems to become less and less standard as time goes by. However, some rules about what is put where may help you get started.

Typical filesystem organization

Here is a list of typical filesystem directory names and descriptions.
Name Description
/ The root directory
/sbin Administrative commands
/bin User commands; often a symbolic link to /usr/bin
/usr The bulk of the operating system
/usr/bin Most of the system commands
/usr/local Locally installed software packages
/usr/include Include files (used for software development)
/usr/src Source code
/usr/local/src Source code for locally installed packages
/usr/sbin Another place for administrative commands
/var Data (log files, spool files)
/var/log Log files
/export Filesystems to be shared
/home User home directories
/opt Optional software
/tmp Used for temporary files; sometimes a RAM disk
/proc A "fake filesystem" used to access kernel variables

"A" filesystem

The term filesystem is used in two contexts. When we speak of "the" filesystem, we mean the entire directory hierarchy rooted at /. However, this larger filesystem is composed of individual filesystems. In the past, this sense of the word filesystem meant a particular organization of data on a disk partition.
For Linux, Solaris, and HP-UX systems, this association between a filesystem and a disk partition remains valid. AIX, however, has adopted a more flexible approach, based on the notion of Logical Volumes. We will discuss filesystems from the traditional point of view first, and look briefly at the Logical Volume approach at the end of this module.

System Variation

The details of the organization of data on a UNIX disk partition vary from system to system and from disk to disk. For example, Linux uses a filesystem architecture called ext2 to organize data on its disks. Solaris uses ufs (UNIX filesystem). Although these filesystems differ at a low level in important ways, these differences are not important for the day-to-day operation of the UNIX system.

Creating a new Filesystem

As a systems administrator, you must often create new filesystems. Sometimes, you must place a filesystem onto a floppy disk to create a boot disk. At other times, you must create a filesystem on actual hard drives.

Create Linux filesystem

Creating a filesystem using Linux (Simulation transcript)

Here are the steps you followed to create a filesystem on a Linux machine:
  1. Assume that you have already entered a floppy disk into the drive bay. Before you can create a new filesystem, you must first as .sert root privileges. Type the su command to do this.
  2. Change to the /sbin directory.
  3. Before you can use the mkfs command, you must set the path for the /sbin directory. Enter PATH=$PATH:. to accomplish this.
  4. Export this path to a system-wide variable. Solution: export PATH
  5. Now, use the mkfs command to create an ext2 filesystem for your floppy disk (fd0). Use the –t option to specify the type of filesystem. Type
    mkfs –t ext2 /dev/fd0 
    

  6. Verify that the filesystem is internally consistent. Use the fsck command.
    Solution: fsck -t ext2 /dev/fd0
  7. Notice that the disk has 1440 blocks. This equals 1.440 MB of space.

Creating a filesystem using Solaris

Here are the steps you followed to create a filesystem on a Solaris machine:
  1. Assume that you have already entered a floppy disk into the drive bay. Before you can create a new filesystem, you must first assert root privileges. Type the su command and superuser password to do this.
  2. Now, type fdformat rdiskette0 to format the raw device. You need to do this before creating the filesystem.
  3. Create the filesystem by typing newfs /dev/rdiskette0.
  4. Notice that the disk has 1.440 MB of space.
In these simulations, you will create a new filesystem onto a floppy disk. Choose which UNIX version you’d like to simulate by clicking either the Linux or the Solaris button. The system you create will be the foundation for several other simulations later in this module that concern filesystems. Note: Some types of filesystems are not intended to hold a directory hierarchy. For example, UNIX systems use a specially structured disk partition for virtual memory (swap) space. Such partitions have a swap filesystem installed on them; they are not usually directly accessed by humans.