Ora

How to Check AIX Filesystems?

Published in AIX Filesystem Management 5 mins read

Checking AIX filesystems is crucial for maintaining data integrity and system stability. AIX automatically performs checks during boot, and administrators can also initiate manual checks using the fsck command.

Understanding AIX Filesystem Checks

Filesystem checks are vital processes that verify the consistency and integrity of a filesystem's structure. This helps detect and correct errors that could lead to data loss or system instability, often caused by unexpected shutdowns, hardware failures, or software issues.

Automatic Checks at Boot Time

AIX is designed to proactively maintain filesystem health during system startup.

  • When an AIX system boots, it attempts to check all filesystems listed in its configuration file, /etc/filesystems.
  • This automatic check is specifically performed for filesystems that have the check=true attribute set within their /etc/filesystems entry.
  • The system uses the fsck (filesystem check) command to execute these automatic integrity checks. This ensures that the filesystems are in a consistent state before they are made fully available to the operating system and users.

Example: /etc/filesystems entry with check=true

/home:
        dev             = /dev/hd1
        vfs             = jfs2
        log             = /dev/hd8
        mount           = true
        check           = true
        options         = rw
        account         = false

Manual Filesystem Checks with fsck

For immediate troubleshooting or planned maintenance, you can manually run the fsck command.

Crucially, filesystems should ideally be unmounted before running fsck to prevent data corruption. Running fsck on a mounted, active filesystem can lead to severe data loss.

Basic fsck Usage

  1. Unmount the Filesystem: Before checking, ensure the target filesystem is not in use.

    umount /your_filesystem_name

    If the filesystem is busy, you might need to identify and terminate processes using it or boot into maintenance mode.

  2. Run fsck on the Raw Logical Volume: The fsck command is typically run on the underlying logical volume (raw device) associated with the filesystem.

    # For JFS2 filesystems
    fsck -yV jfs2 /dev/logical_volume_name
    
    # For JFS filesystems (less common now)
    fsck -yV jfs /dev/logical_volume_name
    • -y: Automatically assumes 'yes' to all prompts, allowing fsck to fix inconsistencies without user interaction. Use with caution, but it's common for automated repairs.
    • -V filesystem_type: Specifies the Virtual File System (VFS) type (e.g., jfs2 for Journaled Filesystem 2, jfs for the older Journaled Filesystem).
  3. Mount the Filesystem: After fsck completes and reports a clean status, remount the filesystem.

    mount /your_filesystem_name

Common fsck Options

Option Description
-y Assumes a 'yes' response to all questions. This allows fsck to attempt to fix all detected inconsistencies automatically. Use with care, as it might sometimes make undesirable repairs without prior review.
-p Preen mode. Automatically repairs minor inconsistencies (problems that do not require administrator intervention). It's a safer option for routine checks on unmounted filesystems without full -y permissions.
-V filesystem Specifies the Virtual File System (VFS) type of the filesystem to be checked (e.g., jfs2, jfs). This ensures the correct filesystem-specific fsck utility is invoked.
-o options Provides specific options to the fsck command for the particular VFS type. For instance, fsck -o full can force a full check on a JFS2 filesystem, ignoring the log.
-n Answers 'no' to all questions, effectively performing a read-only check. This option allows you to see what fsck would do without actually making any changes. Useful for initial assessment of a problematic filesystem.
-F filesystem Specifies the mount point of the filesystem to be checked, instead of the logical volume device. Note: This is usually a wrapper that still operates on the underlying device.

Checking the Root Filesystem (/)

Checking the root filesystem (/) requires special procedures since it cannot be unmounted during normal operation.

  • Boot into AIX Maintenance Mode:
    1. Reboot the system.
    2. Interrupt the boot sequence to enter the System Management Services (SMS) menu.
    3. Select the option to boot into Maintenance Mode.
    4. Choose the option to Start a Shell with the root volume group activated.
    5. Once in the shell, you can run fsck on the root logical volume (hd4 is typically for /).
      fsck -y /dev/hd4
    6. After the check, type exit to continue the boot process.

Read-Only Checks

If unmounting a filesystem is not feasible or you want to assess potential issues before making changes, you can perform a read-only check:

fsck -n /dev/logical_volume_name

This command will report inconsistencies without attempting any repairs, giving you an idea of the filesystem's health.

Tools to Monitor Filesystem Status

While fsck focuses on integrity, other commands provide insights into filesystem usage and attributes:

  • df (disk free): Displays the amount of free disk space available on filesystems.
    df -g /your_filesystem_name # Shows usage in GB
  • lsfs: Lists information about filesystems, including their type, mount point, and whether they are configured for automatic checking.
    lsfs -q /your_filesystem_name # Shows detailed attributes including 'check'
  • mount: Shows all currently mounted filesystems and their mount options.

Best Practices for Filesystem Health

  • Regular Monitoring: Routinely check disk space usage and system logs for filesystem-related errors.
  • Planned Downtime: Schedule maintenance windows for comprehensive fsck checks, especially for critical filesystems.
  • Graceful Shutdowns: Always perform proper system shutdowns to minimize the risk of filesystem corruption.
  • Backups: Implement a robust backup strategy to protect against data loss in case of severe filesystem damage.

For more detailed information and advanced options, consult the IBM AIX documentation on fsck and related filesystem management topics.