System Administration Guide

Understanding How the File System State Is Recorded

The fsck command uses a state flag, which is stored in the superblock, to record the condition of the file system. This flag is used by the fsck command to determine whether or not a file system needs to be checked for consistency. The flag is used by the /sbin/rcS script during booting and by the fsck command when run from a command line using the -m option. If you ignore the result from the -m option to fsck, all file systems can be checked regardless of the setting of the state flag.

The possible state flag values are described in Table 31-1.

Table 31-1 State Flag Values

State Flag Value 

Description 

FSCLEAN

If the file system was unmounted properly, the state flag is set to FSCLEAN. Any file system with an FSCLEAN state flag is not checked when the system is booted.

 

FSSTABLE

The file system is (or was) mounted but has not changed since the last checkpoint (sync or fsflush) which normally occurs every 30 seconds. For example, the kernel periodically checks if a file system is idle and, if so, flushes the information in the superblock back to the disk and marks it FSSTABLE. If the system crashes, the file system structure is stable, but users may lose a small amount of data. File systems that are marked FSSTABLE can skip the checking before mounting. The mount(2) system call will not mount a file system for read/write if the file system state is not FSCLEAN or FSSTABLE.

FSACTIVE

When a file system is mounted and then modified, the state flag is set to FSACTIVE. The file system may contain inconsistencies. A file system will be marked as FSACTIVE before any modified metadata is written to the disk. When a file system is unmounted gracefully, the state flag is set to FSCLEAN. A file system with the FSACTIVE flag must be checked by fsck because it may be inconsistent.

FSBAD

If the root (/) file system is mounted when its state is not FSCLEAN or FSSTABLE, the state flag is set to FSBAD. The kernel will not change this file system state to FSCLEAN or FSSTABLE. If a root (/) file system is flagged FSBAD as part of the boot process, it will be mounted read-only. You can run fsck on the raw root device. Then remount the root (/) file system as read/write.

Table 31-2 shows when the state flag is modified.

Table 31-2 When the State Flag is Modified

Before fsck

After fsck

 

 

 

Initial State 

 

No Errors 

New State- All Errors Corrected 

 

Uncorrected Errors 

unknown 

stable 

stable 

unknown 

active 

stable 

stable 

active 

stable 

stable 

stable 

active 

clean 

clean 

stable 

active 

bad 

stable 

stable 

bad