Certification Objective 4.02-Managing Filesystems

There are as many, if not more, filesystem types as there are operating systems. While RHEL can work with many of these formats, the default is ext3. While many users enable other filesystems such as ReiserFS, Red Hat may not support them.

Linux supports a rich variety of filesystems. Linux filesystems can be somewhat inaccurately divided into two categories: "standard" formatting and journaling. While this is an oversimplification, it suffices to describe the filesystems important to Linux. To me, a standard filesystem is an older Linux filesystem which does not log changes.

On the Job 

There are a large number of filesystem types well described in the Filesystems HOWTO at www.tldp.org. Strictly speaking, there is no "standard" filesystem.

The filesystems I describe in this book are just a small list of those available for RHEL. If you have the kernel source RPMs loaded on your system, you can find a list of the filesystems supported by your kernel. For x86 systems, navigate to the /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386 directory. Run the make menuconfig command and use your arrow keys to navigate to the filesystems section.

Standard Formatting Filesystems

Linux is a clone of Unix. The Linux filesystems were developed from the Unix filesystems available at the time. The first Linux operating systems used the Extended Filesystem (ext). Until the past few years, Red Hat Linux operating systems formatted their partitions by default to the Second Extended Filesystem (ext2).

There are other filesystems available for RHEL, a sample of which are included in Table 4-1. These "standard" filesystems don't include journaling features.

Table 4-1: Some Linux Standard Filesystem Types

Filesystem Type



The first Linux filesystem, used only on early versions of that operating system.

ext2 (Second Extended)

The foundation for ext3, the default RHEL filesystem. The ext3 filesystem is essentially ext2 with journaling.


The Linux swap filesystem is associated with dedicated swap partitions. You've probably created at least one swap partition when you installed RHEL.


These filesystems allow you to read MS-DOS-formatted filesystems. MS-DOS lets you read pre-Windows 95 partitions, or regular Windows partitions within the limits of short file names. VFAT lets you read Windows 9x/NT/2000/XP/Vista partitions formatted to the FAT16 or FAT32 filesystems.

ISO 9660

The standard filesystem for CD-ROMs. It is also known as the High Sierra File System, or HSFS, on other Unix systems.


The Microsoft Windows NT/2000/XP/2003 filesystem designed for username/password security. Currently supported as a read-only system.


A Linux virtual filesystem. Virtual means that it doesn't occupy real disk space. Instead, files are created as needed. Used to provide information on kernel configuration and device status.


The Linux implementation of the Open Group's Unix98 PTY support.


The Network File System, the system most commonly used to share files and printers between Linux and Unix computers.


The Common Internet File System (CIFS) is the successor to the Samba/Server Message Block (SMB) system based on Microsoft and IBM network protocols. Linux can use CIFS and SMB to share files and printers with Microsoft Windows operating systems.

Understanding Journaling Filesystems

As hard disks and partitions grow in size, Linux users are moving toward filesystems with journaling features. Journaling filesystems have two main advantages. First, it's faster for Linux to check during the boot process. Second, if a crash occurs, a journaling filesystem has a log (also known as a journal) that can be used to restore the metadata for the files on the relevant partition.

The default RHEL filesystem is the Third Extended Filesystem, also known as ext3. However, it isn't the only journaling filesystem option available. I list a few of the options commonly used for RHEL in Table 4-2. From this list, Red Hat officially supports only ext3.

Table 4-2: Journaling Filesystems

Filesystem Type



The default filesystem for RHEL.


IBM's journaled filesystem, commonly used on IBM enterprise servers.


The Reiser File System is resizable and supports fast journaling. It's more efficient when most of the files are very small and very large. It's based on the concept of "balanced trees." It is no longer supported by RHEL, or even by its main proponent, SUSE. For more information, see www.namesys.com.


Developed by Silicon Graphics as a journaling filesystem, it supports very large files; as of this writing, xfs files are limited to 9 × 1018 bytes. Do not confuse this filesystem with the X Font Server; both use the same acronym.

Creating Filesystems with mkfs

There are several commands that can help you create a Linux filesystem. They're all based on the mkfs command. As described in Chapter 1, the mkfs command works as a front-end to filesystem-specific commands such as mkfs.ext2 and mkfs.ext3.

If you want to reformat an existing partition, take the following precautions:

  • Back up any existing data on the partition.

  • Unmount the partition.

There are two ways to apply formatting on a partition. For example, if you've just created a partition on /dev/sdb5, you can format it to the ext3 filesystem using one of the following commands:

 # mkfs -t ext3 /dev/sdb5 # mkfs.ext3 /dev/sdb5 

Alternatively, you can use the mke2fs command; the first of the following two commands formats the noted partition to the ext2 filesystem, and the second adds a journal that formats the partition to the ext3 filesystem:

 # mke2fs /dev/sdb5 # mke2fs -j /dev/sdb5 

You can format partitions to other filesystems. The options available in RHEL 5 include:

  • mkfs.cramfs creates a compressed ROM filesystem.

  • mkfs.ext2 formats a partition to the ext2 filesystem.

  • mkfs.ext3 formats a partition to the Red Hat default ext3 filesystem.

  • mkfs.msdos (or mkfs.vfat or mkdosfs) formats a partition to the Microsoft-compatible VFAT filesystem; it does not create bootable filesystems. (The inode numbers for all three files are the same; in other words, they are three different names for the same command.)

  • mkswap formats a partition to the Linux swap filesystem.

These commands assume that you've created an appropriate partition in the first place; for example, if you've used fdisk to create a swap partition, you'll need to change the filesystem type before you can save it and format it appropriately with the mkswap command.

Managing ext2/ext3 Filesystem Attributes

Filesystem attributes can help you control what anyone can do with different files. The key commands in this area are lsattr and chattr. The use I'm most familiar with protects a file from deletion, even by the root user. For example, you could protect /etc/inittab from tinkering by other administrators with the following command:

 # chattr +i /etc/inittab 

Then when I try to delete the file, I get the following result:

 # rm /etc/inittab rm: remove write-protected regular file '/etc/inittab'? y rm: cannot remove '/etc/inittab': Operation not permitted 

As you can see, this adds the immutable attribute to /etc/inittab:

 # lsattr /etc/inittab ----i-------- /etc/inittab 

To me, the man pages for these commands are somewhat confusing, so I summarize three key attributes that you can change in Table 4-3. The c (compressed), s (secure deletion), and u (undeletable) attributes don't work for files in the ext2 and ext3 filesystems.

Table 4-3: File Attributes



append only (a)

Prevents deletion, but allows appending to a file-for example, if you've run chatter +a tester, cat /etc/fstab >> tester would add the contents of /etc/fstab to the end of the tester file.

no dump (d)

Does not allow backups of the configured file with the dump command.

immutable (i)

Prevents deletion or any other kind of change to a file.

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

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