home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Linux in a NutshellLinux in a NutshellSearch this book

Chapter 2. System and Network Administration Overview

2.1. Common Commands

Following are lists of commonly used system administration commands.

2.1.7. Managing Filesystems

To Unix systems, a filesystem is a device (such as a partition) that is formatted to store files. Filesystems can be found on hard drives, floppies, CD-ROMs, or other storage media that permit random access.

The exact format and means by which the files are stored are not important; the system provides a common interface for all filesystem types that it recognizes. Under Linux, filesystem types include the Second Extended (ext2) Filesystem, which you probably use to store Linux files. This filesystem was developed primarily for Linux and supports 256-character filenames and 4-terabyte maximum filesystem size. (It is "second" because it is the successor to the extended filesystem type.) Other common filesystem types include the MS-DOS filesystem, which allows files on MS-DOS partitions and floppies to be accessed under Linux, and the ISO 9660 filesystem used by CD-ROMs.

The 2.4 kernel adds optional support for an enhanced version of the ext2 filesystem, the Third Extended (ext3) Filesystem. Many Linux distributions ship kernels with this support preconfigured. The ext3 filesystem is essentially an ext2 filesystem with an added journal. Since it is in all other ways identical to the ext2 system, it is both forward and backward compatible with ext2—all ext2 utilities work with ext3 filesystems. When the kernel interacts with an ext3 filesystem, writes to disk are first written to a log or journal before they are written to disk. This slows down writes to the filesystem, but reduces the risk of data corruption in the event of a power outage. It also speeds up reboots after a system unexpectedly loses power. When rebooting with an ext2 filesystem, the fsck utility scans the entire disk to ensure that all data blocks are listed as either used or free, that each data block is claimed by only one file or directory, and that all files are available in the directory tree. When rebooting an ext3 filesystem using a supported kernel, it need only check the journal and complete any tasks that were left uncompleted.

To change an ext2 filesystem into an ext3 filesystem, simply add a journal using the tune2fs utility with the -j option on the unmounted device. If the filesystem is listed in /etc/fstab, change its specified filesystem from ext2 to ext3, or auto (mountd will automatically detect the right system).

You can specify the level of journaling the kernel should use in the mount options field (or using mount -o). There are three data options:

data=journal
Log all filesystem data and metadata changes. All changes to the filesystem are written twice, once to the journal and once to the filesystem itself. This is the slowest but safest mode.

data=ordered
Log filesystem metadata. Flush data updates to disk before changing metadata. This is the default mode. This slows writes a small amount, but ensures the filesystem is always in sync with changes to its metadata.

data=writeback
Log filesystem metadata. Use the ext2 write process to write data changes. This is the fastest journaling mode. While it maintains filestructure integrity, the contents of files may contain old, stale data when the filesystem is restarted from an unexpected shutdown.

The last field in the /etc/fstab entry specifies at what point in the boot process the filesystem should be verified with fsck. It should never need to be checked because journaling ensures filesystem integrity. You can set this field to 0. You can also turn off the automatic check of the filesystem that normally occurs every 20th time the system is mounted using tune2fs -i 0 -c 0.

Although not covered in this edition of Linux in a Nutshell, Linux supports three other open source journaling filesystems: IBM's Journaled Filesystem (JFS), SGI's Extensible Filesystem (XFS), and the Naming System Venture's Reiser Filesystem (ReiserFS). In some situations these can be faster than ext3. Some Linux distributions use these alternative filesystems by default.

debugfs

Debug ext2 filesystem.

dosfsck

Check and repair a DOS or VFAT filesystem.

dumpe2fs

Print information about superblock and blocks group.

e2fsck

Check and repair an ext2 filesystem.

e2image

Store disaster recovery data for an ext2 filesystem.

fdformat

Format floppy disk.

fsck

Another name for e2fsck.

fsck.ext2

Check and repair an ext2 filesystem.

fsck.minix

Check and repair a MINIX filesystem.

fuser

List processes using a filesystem.

mke2fs

Make a new ext2 filesystem.

mkfs

Make new filesystem.

mkfs.ext2

Another name for mke2fs.

mkfs.ext3

Yet another name for mke2fs.

mkfs.minix

Make new MINIX filesystem.

mklost+found

Make lost+found directory.

mkraid

Set up a RAID device.

mkswap

Designate swap space.

mount

Mount a filesystem.

raidstart

Activate a RAID device.

raidstop

Turn off a RAID device.

rdev

Describe or change values for root filesystem.

resize2fs

Enlarge or shrink an ext2 filesystem.

rootflags

List or set flags to use in mounting root filesystem.

showmount

List exported directories.

swapoff

Cease using device for swapping.

swapon

Begin using device for swapping.

sync

Write filesystem buffers to disk.

tune2fs

Manage an ext2 filesystem.

umount

Unmount a filesystem.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.