Linux System Administration

Slightly more tedious and complex than adding a disk drive to other microcomputer systems.
The Filesystem Configuration File: /etc/fstab

Here are some sample entries from /etc/fstab from a Linux system:

# device   mount  type  options   dump fsck
/dev/hda2  /      ext2  defaults    1    1
/dev/hdb1  /aux   msdos noauto      1    2
/dev/hda1  none   swap  sw          0    0
/dev/sda1  /chem  ext2  defaults    1    1

The general format for an entry is:

special-file loc type opts
dump-freq pass-number

The fields have the following meanings:

  • special-file: The name of the special file on which the filesystem resides. This must be a block device name.

  • loc: The directory at which to mount the filesystem. If the partition will be used for swapping, use none for this field.

  • type: The kind of partition the entry refers to. The value for local filesystems under Linux is ext2. Other common type values are nfs for volumes mounted remotely via NFS, and swap for swap partitions and ignore, which tells mount to ignore the entry.

  • opts: This field consists of one or more options, separated by commas. The type field, above, determines which options are allowed for any given kind of filesystem. For ignore type entries, this field is ignored. For local filesystems, the options field may include the following keywords, separated by commas:

rw

Read-write filesystem

ro

Read-only filesystem

suid

The SUID access mode is permitted (default)

nosuid

The SUID access mode is not permitted

noauto

Don't automatically mount this filesystem

usrquota

User quotas may be placed in effect

grpquota

Group quotas may be placed in effect

  • Multiple options are separated by commas, without intervening spaces. On many systems, the keyword defaults may be placed into this field if no options are needed.

  • If the filesystem type is nfs, many more options are supported (see Chapter 13).

  • dump-freq: A decimal number indicating the frequency with which this filesystem should be backed up by the dump utility. The dump utility is in alpha testing and is not available on most Linux systems, so unless you use dump, you can ignore this field.

  • pass-number: A decimal number indicating the order in which fsck should check the filesystems. A pass-number of 1 indicates that the filesystem should be checked first, 2 indicates that the filesystem should be checked second, and so on. The root filesystem must have a pass-number of 1. All other filesystems should have the same or higher pass numbers. For optimal performance, two filesystems that are on the same disk drive should have different pass numbers; however, filesystems on different drives may have the same pass number, letting fsck check the two filesystems in parallel. fsck will usually be fastest if all filesystems checked on the same pass have roughly the same size. This field should be 0 for swap devices (0 disables checking by fsck).

Viewing and Modifying the Superblock

The tune2fs command may be used to list and alter fields within the superblock of an ext2 filesystem. Here is an example of its display-mode output:

# tune2fs -l /dev/hdb1
Filesystem magic number: 0xEF53
Filesystem state:        clean
Errors behavior:         Continue
Inode count:             13104
Block count:             52208
Reserved block count:    2610
Free blocks:             50528
Free inodes:             13093
First block:             1
Block size:              1024
Fragment size:           1024
Blocks per group:        8192
Fragments per group:     8192
Inodes per group:        1872
Last mount time:         Wed Dec 31 19:00:00 1969
Last write time:         Thu Mar  2 04:19:16 1995
Mount count:             6
Maximum mount count:     20
Last checked:            Thu Mar  7 15:27:34 1996
Check interval:          2592000
Next check after:        Fri Apr  5 16:27:34 1996

The final items in the list concern when fsck will check the filesystem, even if it is clean. The Linux version of fsck for ext2 filesystems will check the filesystem if either the maximum number of mounts without a check has been exceeded or the maximum time interval between checks has expired (20 times and 30 days in the preceding output; the check interval is given in seconds).

tune2fs's -i option may be used to specify the maximum time interval between checks in days, and the -c option may be used to specify the maximum number of mounts between checks. For example, the following command disables the time-between-checks function and sets the maximum number of mounts to 25:

# tune2fs -i 0 -c 25 /dev/hdb1
Setting maximal mount count to 25
Setting interval between check 0 seconds

Another useful option to tune2fs is -m, which allows you to change the percentage of filesystem space held in reserve dynamically.

______________________

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix