Filesystem Maintenance


To get optimum performance out of the filesystem, and to guard against data corruption, you need to ensure proper maintenance of the system in general, and the filesystem in particular, as it manages the persistent part of the operating system.

Precautions

When it comes to filesystem maintenance, there are a number of simple precautions that help in preventing costly mishaps. It is extremely important that the system be properly shutdown before restarting the machine. On a typical Linux system, a significant part of the filesystem is always being worked on in memory. In fact, if possible, it is a good idea to run the sync command before shutting down the machine, as this will flush unwritten filesystem blocks in memory to the disk and avoid boot time filesystem inconsistencies.

As you ll recall from Chapter 1, during the Fedora 2 installation you are prompted to create a boot disk. This is particularly useful if the partition containing the bootable image of the kernel becomes corrupted. With a boot disk, you can boot up to a minimal shell and run diagnostics and repair tools.

If you have important data on your system, it is always a good idea to use some form of backup utility to back up the system periodically. We look at this in more detail in Chapter 11.

Running fsck

Most UNIX filesystem partitions contain a super block , which is essentially a bookkeeping section of that partition. When a system is shut down gracefully (that is, without errors), a flag is set to indicate the graceful shutdown. When the system comes up the next time, it examines this flag to see if the shutdown was graceful or not. If not, the system may require you to run diagnostic and repair tools on that partition.

The most popular diagnostics and repair utility on Linux (and in the UNIX world) is fsck . Running fsck with the y option allows it to proceed with any repairs that need to be performed in the course of diagnostic analysis. The N option to fsck performs a dry run; the actual repair routines are not performed, but only printed out. Here is a typical output with the N option on a partition with a corrupted superblock.

   $ /sbin/fsck -N /dev/hda   fsck 1.27 (8-Mar-2002) [/sbin/fsck.ext3 (1) -- /dev/had] fsck.ext3 /dev/hda  $ /sbin/fsck -y /dev/hda fsck 1.27 (8-Mar-2002) e2fsck 1.27 (8-Mar-2002) Couldn't find ext3 superblock, trying backup blocks... fsck.ext3: Bad magic number in super-block while trying to open /dev/hda The superblock could not be read or does not describe a correct ext3 filesystem.  If the device is valid and it really contains an ext3 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock:     e2fsck -b 8193 <device> 

Tuning the Filesystem

The tune2fs command allows you to set various tunable parameters on the ext2 filesystem partitions. It is commonly used to control the frequency at which fsck is automatically run on a filesystem:

  • The fsck utility can be run once every few days, weeks, or months by specifying the -i option. For example, the following command would force an execution of fsck once every two weeks:

       $ tune2fs i 2w   
  • The “c option controls the running of fsck based on the number of reboots. For example, -c 10 indicates that fsck will be run once in every ten system reboots.

     $ tune2fs c 10 

Note that these settings also apply to an ext3 filesystem.




Beginning Fedora 2
Beginning Fedora 2
ISBN: 0764569961
EAN: 2147483647
Year: 2006
Pages: 170

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