Certification Objective 1.03-Linux Filesystem Hierarchy and Structure

Everything in Linux can be reduced to a file. Partitions are associated with filesystem device nodes such as /dev/hda1. Hardware components are associated with node files such as /dev/dvd. Detected devices are documented as files in the /proc directory. The Filesystem Hierarchy Standard (FHS) is the official way to organize files in Unix and Linux directories. As with the other sections, this introduction provides only the most basic overview of the FHS. More information is available from the official FHS homepage at www.pathname.com/fhs.

Linux Filesystems and Directories

Several major directories are associated with all modern Unix/Linux operating systems. These directories organize user files, drivers, kernels, logs, programs, utilities, and more into different categories. The standardization of the FHS makes it easier for users of other Unix-based operating systems to understand the basics of Linux.

Every FHS starts with the root directory, also known by its symbol, the single forward slash (/). All of the other directories shown in Table 1-1 are subdirectories of the root directory. Unless they are mounted separately, you can also find their files on the same partition as the root directory. You may not see some of the directories shown in the table if you have not installed associated packages. Not all directories shown are officially part of the FHS.

Table 1-1: Basic Filesystem Hierarchy Standard Directories




The root directory, the top-level directory in the FHS. All other directories are subdirectories of root, which is always mounted on some partition.


Essential command line utilities. Should not be mounted separately; otherwise, it could be difficult to get to these utilities when using a rescue disk.


Includes Linux startup files, including the Linux kernel. The default, 100MB, is usually sufficient for a typical modular kernel and additional kernels that you might install during the RHCE or RHCT exam.


Hardware and software device drivers for everything from floppy drives to terminals. Do not mount this directory on a separate partition.


Most basic configuration files.


Home directories for almost every user.


Program libraries for the kernel and various command line utilities. Do not mount this directory on a separate partition.


The mount point for removable media, including floppy drives, DVDs, and Zip disks.


The standard mount point for local directories mounted via the automounter.


A legacy mount point; formerly used for removable media.


The standard mount point for network directories mounted via the automounter.


Common location for third-party application files.


Currently running kernel-related processes, including device assignments such as IRQ ports, I/O addresses, and DMA channels, as well as kernel configuration settings such as IP forwarding.


The home directory of the root user.


System administration commands. Don't mount this directory separately.


Currently configured settings associated with Security Enhanced Linux.


The standard mount point for remote shared Microsoft network directories mounted via the automounter.


Commonly used by various network servers on non-Red Hat distributions.


Included if the TFTP server is installed.


Temporary files. By default, Red Hat Enterprise Linux deletes all files in this directory periodically.


Small programs accessible to all users. Includes many system administration commands and utilities.


Variable data, including log files and printer spools.

Mounted directories are often known as volumes, which can span multiple partitions. However, while the root directory (/) is the top-level directory in the FHS, the root user's home directory (/root) is just a subdirectory.

On the Job 

In Linux, the word filesystem has several different meanings. For example, a filesystem can refer to the FHS, an individual partition, or a format such as ext3. A filesystem device node such as /dev/sdal represents the partition on which you can mount a directory.

A Variety of Media Devices

Several basic types of media are accessible to most PCs, including PATA, SATA, and SCSI hard disks; floppy drives; DVD/CD drives; and more. Other media are accessible through other PC ports, including serial, parallel, USB, and IEEE 1394 systems. You can use Linux to manage all of these types of media.

Most media devices are detected automatically. Linux may require a bit of help for some devices described in Chapter 2. But in the context of the Linux FHS, media devices, like all others, are part of the /dev directory. Typical media devices are described in Table 1-2.

Table 1-2: Media Devices

Media Device

Device File

Floppy drive

First floppy (Microsoft A: drive) = /dev/fd0

Second floppy (Microsoft B: drive) = /dev/fd1

PATA (IDE) hard drive


First drive = /dev/hda

Second drive = /dev/hdb

Third drive = /dev/hdc

Fourth drive = /dev/hdd

SATA or SCSI hard drive


First drive = /dev/sda

Second drive = /dev/sdb

Twenty-seventh drive = /dev/sdaa and so on

Parallel port drives

First drive = /dev/pd1

First tape drive: /dev/pt1

USB drives

Varies widely

IEEE 1394 drives

IEEE 1394 (a.k.a. FireWire, iLink) is actually a SCSI standard, so these are controlled in Linux as SCSI devices.

Making Reference to Devices in /dev

Take a look at the files in the /dev directory. Use the ls -l /dev | more command. Scroll through the list for a while. The list actually used to be longer. Well, there's a method to this madness. Some devices are linked to others, and that actually makes it easier to understand what is connected to what. For example, the virtual device files /dev/cdrom and /dev/dvd are easier to identify than the true device files. Generally, these devices are automatically linked to the actual device files during Linux installation. For example, if you have a printer and DVD writer installed, the following commands illustrate possible links between these components and the actual device files:

 # ls -l /dev/par0 lrwxrwxrwx  1 root  root  3 Mar 29 09:37 /dev/par0 -> lp0 # ls -l /dev/dvd lrwxrwxrwx  1 root  root  3 Mar 29 09:37 /dev/dvd -> hdd 

These commands show that /dev/par0 is linked directly to the first printer port, and that /dev/dvd is linked directly to the fourth PATA drive.

Filesystem Formatting and Checking

Three basic tools are available to manage the filesystem on various partitions: fdisk, mkfs, and fsck. They can help you configure partitions as well as create, check, and repair different filesystems.

Yes, there are more options, such as parted. But this chapter covers only the very basics as described in the Red Hat prerequisites; for more information, see the man page associated with each respective command tool.

image from book
Inside the Exam

Running as Root

Throughout the book, I'm assuming that you're running commands after having logged in as the root user. While it may not be the best practice on the job, it can save you a little bit of time on the RHCT and RHCE exams. For example, if you've logged in as a regular user, you'd start fdisk with the /sbin/fdisk command. This applies even if you've taken administrative privileges with the su command. (I know, you could take administrative privileges with the root user PATH with the su - root command, but time is of the essence on these exams.) On the other hand, if you log in as the root user, you can take advantage of a different $PATH, which means all you need to type is fdisk.

image from book


The Linux fdisk utility is a lot more versatile than its Microsoft counterpart. But to open it, you need to know the device file associated with the hard drive that you want to change. Identifying the hard disk device file is covered in Chapter 2. Assuming you want to manage the partitions on the first SCSI hard disk, enter the following command:

 # fdisk /dev/sda 

As you can see in Figure 1-3, the fdisk utility is flexible. Some key fdisk commands are described in Table 1-3.

Table 1-3: Important fdisk Options

fdisk Command



Allows you to specify the bootable Linux partition (with /boot).


Lists known partition types; fdisk can create partitions that conform to any of these filesystems.


Adds a new partition; works only if there is free space on the disk that hasn't already been allocated to an existing partition.


Quits without saving any changes.


Changes the partition filesystem; you'll still need to format appropriately.

image from book
Figure 1-3: Linux fdisk commands; p returns the partition table


To format a Linux partition, apply the mkfs command. It allows you to format a partition to a number of different filesystems. To format a typical partition such as /dev/hda2 to the current Red Hat standard, the third extended filesystem, run the following command:

 # mkfs -t ext3 /dev/hda2 

The mkfs command also serves as a "front end," depending on the filesystem format. For example, if you're formatting a Red Hat standard ext3 filesystem, mkfs automatically calls the mkfs.ext3 command. Therefore, if you're reformatting an ext3 filesystem, the following command is sufficient:

 # mkfs /dev/hda2 

On the Job 

Be careful with the mkfs command. Back up any data on the subject partition and computer, as this command erases all data on the specified partition.


The fsck command is functionally similar to the Microsoft chkdsk command. It analyzes the specified filesystem and performs repairs as required. Assume, for example, you're having problems with files in the /var directory, which happens to be mounted on /dev/hda7. If you want to run fsck, unmount that filesystem first. In some cases, you may need to go into single-user mode with the init 1 command before you can unmount a filesystem. To unmount, analyze, and then remount the filesystem noted in this section, run the following commands:

 # umount /var # fsck -t ext3 /dev/hda7 # mount /dev/hda7 /var 

The fsck command also serves as a "front end," depending on the filesystem format. For example, if you're formatting an ext2 or ext3 filesystem, fsck by itself automatically calls the e2fsck command (which works for both filesystems). Therefore, if you're checking an ext3 filesystem, once you unmount it with the umount command, the following command is sufficient:

 # fsck /dev/hda7 

Configuring One Filesystem on Multiple Partitions

The Logical Volume Manager (LVM) enables you to set up one filesystem on multiple partitions. For example, assume you're adding more users and are running out of room in your /home directory. You don't have any unpartitioned space available on your current hard disk.

With the LVM, all you need to do is add another hard disk, configure some partitions, back up /home, and use the LVM tools to combine the new partition and the one used by /home into a volume set. You may need to install the LVM RPM package. Once it is installed, the steps are fairly straightforward, as described in the following exercise.

Exercise 1-2: Creating a New LVM Partition

image from book

LVM is more important than the prerequisite skills covered in most of this chapter. The latest available Red Hat Exam Prep guide includes LVM requirements on both parts of the RHCE exam. For more information on LVM, see Chapters 2 and 8.

  1. Add a new hard disk.

  2. Create new partitions. Assign the Linux LVM filesystem to one or more of these partitions. This can be easily done with the Linux fdisk utility.

  3. Back up /home. Assign the LVM filesystem to that partition.

  4. Scan for Linux LVM filesystems with the vgscan utility to create a database for other LVM commands.

  5. Create volumes for the set with the pvcreate /dev/partition command.

  6. Add the desired volumes to a specific volume group with the vgcreate groupname /dev/partition1 /dev/partition2 command.

  7. Now you can create a logical volume. Use the lvcreate -L xyM -n volname groupname command, where xy is the size of the volume and groupname is the volume group name from the previous step.

  8. Finally, you can format the logical volume with the mkfs command for the desired filesystem (usually ext2 or ext3), using the device name returned by the lvcreate command.

I describe this process in more detail in Chapter 8.

image from book

Mounting Other Partitions

The mount command can be used to attach local and network partitions to specified directories. Mount points are not fixed; you can mount a CD drive or even a Samba share to any empty directory where you have appropriate permissions.

There are standard mount points based on the FHS. The following commands mount a floppy with the VFAT filesystem, a CD formatted to the ISO 9660 filesystem, and a Zip drive. The devices may be different on your system; if in doubt, look though the startup messages with dmesg | less.

 # mount -t vfat /dev/fd0 /mnt/floppy # mount -t iso9660 /dev/cdrom /mnt/cdrom # mount /dev/sdc 

Other mount points are available through the automounter. Once configured, other systems and even shared network directories can be mounted as needed. For more information, see Chapter 4.

RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302)
Linux Patch Management: Keeping Linux Systems Up To Date
ISBN: 0132366754
EAN: 2147483647
Year: 2004
Pages: 227
Authors: Michael Jang

Similar book on Amazon
Linux Quick Fix Notebook
Linux Quick Fix Notebook
Self-Service Linux: Mastering the Art of Problem Determination
Self-Service Linux: Mastering the Art of Problem Determination
RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 & EX300), 6th Edition (Certification Press)
RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 & EX300), 6th Edition (Certification Press)
Security Strategies in Linux Platforms and Applications (Information Systems Security & Assurance)
Security Strategies in Linux Platforms and Applications (Information Systems Security & Assurance)

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