Bash Wiki
Posts (Latest 30 updated) :
Read all
Contents:
  1. [Linux] Bash e2fsck Uso: Check and repair ext2/ext3/ext4 file systems
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[Linux] Bash e2fsck Uso: Check and repair ext2/ext3/ext4 file systems

Overview

The e2fsck command is a file system check utility for ext2, ext3, and ext4 file systems in Linux. It is used to check the integrity of the file system and repair any issues that may be found. Running e2fsck can help prevent data loss and ensure the proper functioning of the file system.

Usage

The basic syntax of the e2fsck command is as follows:

e2fsck [options] [arguments]

Common Options

  • -p: Automatically repair the file system without any prompts.
  • -f: Force check, even if the file system seems clean.
  • -n: Open the file system in read-only mode and do not make any changes.
  • -y: Assume “yes” to all questions, allowing automatic repairs.
  • -c: Check for bad sectors on the disk.

Common Examples

Here are some practical examples of using e2fsck:

  1. Check a file system without making changes:
    e2fsck -n /dev/sda1
    
  2. Automatically repair a file system:
    e2fsck -p /dev/sda1
    
  3. Force a check even if the file system is clean:
    e2fsck -f /dev/sda1
    
  4. Check for bad sectors on the disk:
    e2fsck -c /dev/sda1
    
  5. Assume yes to all prompts and repair:
    e2fsck -y /dev/sda1
    

Tips

  • Always unmount the file system before running e2fsck to avoid data corruption.
  • Run e2fsck during maintenance windows or when the system is not heavily used.
  • Consider using the -n option first to see what issues might be present before making any changes.
  • Regularly check your file systems to catch issues early and maintain system health.