sections in this module City College of San Francisco - CS260A
Unix/Linux System Administration

Module: Filesystems III
module list

Filesystem "Tuning"

In this section I will refer you to a few programs available to examine, adjust the parameters of, and measure performance of, filesystems. I am no expert on these topics, so you will have to do further reading as interested.

tune2fs [options] devicefile

The tune2fs program allows you to examine filesystem parameters stored in the superblock and to adjust some of them. To start with, let's examine the superblock of a disk partition using tune2fs -l :

# tune2fs -l /dev/sda3
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name:   <none>
Last mounted on:          /
Filesystem UUID:          83780f8f-178f-436d-8eb6-00ecb7a9d889
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              524288
Block count:              2097152
Reserved block count:     104857
Free blocks:              1943064
Free inodes:              510582
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      511
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Fri Jul  1 12:29:40 2011
Last mount time:          Sat Oct  1 17:21:04 2011
Last write time:          Fri Jul  1 13:03:42 2011
Mount count:              24
Maximum mount count:      -1
Last checked:             Fri Jul  1 12:29:40 2011
Check interval:           0 (<none>)
Lifetime writes:          1309 MB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:              256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      0c355192-c155-4ed6-afd8-0694f350647a
Journal backup:           inode blocks

A few of the parameters that you might be interested in are the filesystem label and the UUID, both of which can be used to mount the filesystem, the block size,  the size of inode, and filesystem creation dates. You can use tune2fs to change the Label (tune2fs -L) and/or the UUID (tune2fs -U), both of which are familiar.

You may also notice a parameter called filesystem error behavior in the superblock. This dictates what should happen when an error is detected on the filesystem. This filesystem is marked continue, which means the error will be reported by the kernel (using syslog), but the filesystem will be left in service. There are two other possible values for this parameter:

remount-ro  -  remount the filesystem read-only when an error is detected

panic  -  cause a kernel panic when an error is detected.

Changing this setting will, of course, severely restrict system functionality(!) In all cases, when a filesystem error is detected, the filesystem will be checked at the next reboot (or, at least, this is what the documentation says.) 

The other set of parameters you may want to adjust using tune2fs are those that govern when a filesystem is checked. As you know, the reason to use a journaled filesystem is to avoid the lengthy filesystem-checking procedure when the filesystem is reattached. At boot, the system customarily performed a filesystem check. Normaly, "clean" filesystems are skipped. Since journaled filesystems are always "clean", this meant that a full check was never performed on a journaled filesystem. Until recently, it was considered wise to force a full check every so often. This full check was performed even if fsck was given a clean filesystem, if either of the two following metrics dictated:

Recently, our systems filesystems have both of these metrics disabled at installation. This evident faith in the integrity of the journaling filesystem is curious in the light of this warning, which is twice repeated in the documentation of tune2fs(1):

It  is  strongly  recommended that either -c (mount-count-dependent) or -i (time-dependent) checking be enabled to force  periodic  full  e2fsck(8) checking of the filesystem.  Failure to do so may lead to filesystem corruption due to bad  disks,  cables, memory,  or  kernel  bugs  to go unnoticed until they cause data loss or corruption.

Here are a few options of tune2fs to adjust these parameters:

-c max-mount-count  -  set the maximum mount count. If the filesystem as installed is checked based on mount count and you reboot your system often, you may want to increase max-mount-count or set it to -1 to use the time parameter for checking instead. Conversely, if you have suspicions about one of your filesystems, you can force its checking at the next reboot by setting the maximum mount count to less than the mount count. (If your filesystem currently has a max-mount-count, it is probably better to force a check by adjusting the mount-count (below) instead.)

-C mount-count - set the mount count. To force a check, set this to more than the maximum-mount-count.

-i interval[dwm] - set the time interval between checks. The suffix d (days), w (weeks) or m (months) may be added. days is the default.

You can force a check using an interval by setting the time last checked parameter using tune2fs -T timespec, where timespec is YYYYMMDD or now (to set the time last checked to the current time).

Using tune2fs to add default mount options

As discussed in a previous section, the acl and user_xattr mount options are added by default on filesystems created by the installer. You can add these to your newly-created filesystem as well (to avoid the necessity of adding them to the mount command) by using the tune2fs command. The syntax is the same as it would be for running a mount command: tune2fs -o opt,opt1,opt2,... device

Examining (and modifying) a filesystem using debugfs [-w] devicefile

debugfs is an interactive filesystem debugger. It can be used to examine or modify a filesystem. Normally, the filesystem is opened in read-only mode (examine). The -w option enables read-write mode. I would suggest that only unmounted filesystems should be opened in read-write mode.

One useful feature of debugfs is to examine a file's complete inode. Use the stat function. You can also mark a filesystem dirty or clean, or dump raw blocks to disk. If you are interested in the internals of an ext2/3 filesystem, debugfs can help you investigate.

Of course, changing a filesystem is only for the expert. Feel free to use debugfs without the -w option though and look around as you like.

Monitoring disk health using smartd

A subsystem named smartd is provided on linux to monitor/report disk health. Many devices today are smart-compatible; however, this service is not started by default. To inquire about its results, use the smartctl command.

Examining disk parameters using hdparm device

When used with the devicefile of your disk itself (e.g., /dev/hda), hdparm can be used to examine a drive's parameters (-i or -I), to time I/O (-t or -T) and to examine, and even change, disk parameters. Try hdparm -I /dev/hda (or /dev/sda) to see information about your drive.

Prev This page was made entirely with free software on linux:  
the Mozilla Project
and Openoffice.org      
Next

Copyright 2012 Greg Boyd - All Rights Reserved.