-->

Checking And Repairing a Filesystem On Linux

Even with modern filesystems, things can go wrong if power is unexpectedly lost, or if a wayward application locks up the system while file access is in progress. Fortunately, some command line tools are available to help you make an attempt to restore the filesystem back to order.

Checking And Repairing a Filesystem On Linux
Checking And Repairing a Filesystem On Linux

Each filesystem has its own recovery command for interacting with the filesystem. That has the potential of getting ugly, because more and more filesystems are available in the Linux environment, making for lots of individual commands you have to know.

Fortunately, a common front-end program available can determine the filesystem on the storage device and use the appropriate filesystem recovery command based on the filesystem being recovered.

The fsck command is used to check and repair most Linux filesystem types, including ones discussed earlier in this chapter — ext, ext2, ext3, ext4, Reiser4, JFS, and XFS. The format of the command is:
fsck options filesystem
You can list multiple filesystem entries on the command line to check. Filesystems can be referenced using either the device name, the mount point in the virtual directory, or a special Linux UUID value assigned to the filesystem.

Tip

Although journaling filesystems users do need the fsck command, it is arguable as to whether COW filesystems users do. In fact, the ZFS filesystem does not even have an interface to the fsck utility

The fsck command uses the /etc/fstab file to automatically determine the filesystem on a storage device that’s normally mounted on the system. If the storage device isn’t normally mounted (such as if you just created a filesystem on a new storage device), you need to use the -t command line option to specify the filesystem type. Table 8.4 lists the other command line options available.

The fsck Command Line Options
The fsck Command Line Options
You may notice that some of the command line options are redundant. That’s part of the problem of trying to implement a common front-end for multiple commands. Some of the individual filesystem repair commands have additional options that can be used. If you need to do more advanced error checking, you’ll need to check the man pages for the individual filesystem repair tool to see if there are extended options specific to that filesystem.

Tip

You can run the fsck command on unmounted filesystems only. For most filesystems, you can just unmount the filesystem to check it and then remount it when you’re finished. However, because the root filesystem contains all the core Linux commands and log files, you can’t unmount it on a running system.
This is a time where having a Linux LiveCD comes in handy! Just boot your system with the LiveCD, and then run the fsck command on the root filesystem!

This chapter has showed how to handle filesystems contained in physical storage devices. Linux also provides a couple of different ways to create logical storage devices for filesystems. The next section examines how you can use a logical storage device for your filesystems.


0 Response to "Checking And Repairing a Filesystem On Linux"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel