• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

e2fsck Command Examples in Linux

by admin

This utility checks an ext2/ext3 file system. Most often used after a sudden shutdown, such as from a power outage, or when damage to the disk is suspected. Some useful arguments taken from man e2fsck are as follows:

  • -c: Checks for bad blocks and then marks them as bad.
  • -f: Forces checking on a clean file system.
  • -v: Verbose mode.

e2fsck Command Examples

1. To check a file system:

# e2fsck /dev/sda1
# e2fsck /dev/mapper/VG00-LV00

2. To check the file system and repair it if found any:

# e2fsck -p /dev/sda1

3. To check the file system and repair it if found any error (with backward compatibility):

# e2fsck -a /dev/sda1

4. To force e2fsck to only try locating the super-block at a particular blocksize:

# e2fsck -B 1024 /dev/sda1

5. To to do a read-only scan of the device:

# e2fsck -c /dev/sda1

6. To to write completion information to the specified file descriptor:

# e2fsck -C fd /dev/sda1

7. To print debugging output:

# e2fsck -d /dev/sda1

8. To Optimize directories in file system:

# e2fsck -D /dev/sda1

9. To set the e2fsck extended options:

# e2fsck -E ea_ver=extended_attribute_version
# e2fsck -E fragcheck

10. To Force checking even if the file system seems clean:

# e2fsck -f

11. To Set the path name where the external-journal for this file system can be found:

# e2fsck -j external-journal

12. To preserve the existing bad blocks:

# e2fsck -kc /dev/sda1

13. To add the block numbers specified in the file:

# e2fsck -l /tmp/file.txt /dev/sda1

14. To set the bad blocks list specified in the file:

# e2fsck -L /tmp/file.txt /dev/sda1

15. To open the file system read-only:

# e2fsck -n /dev/sda1

16. To have the backward compatibility:

# e2fsck -r /dev/sda1

17. To have the time stats:

# e2fsck -t /dev/sda1

18. To set the verbose mode:

# e2fsck -v /dev/sda1

19. To get the version information:

# e2fsck -V

20. To set the answer to “yes”:

# e2fsck -y /dev/sda1

Filed Under: Linux

Some more articles you might also be interested in …

  1. “Logical volume vg/lv contains a filesystem in use” – while removing LVM filesystem
  2. “az storage blob” Command Examples (Manage blob storage containers and objects in Azure)
  3. enca: Detect and convert the encoding of text files
  4. sic Command Examples in Linux
  5. ports Command Examples in Linux
  6. gh secret set: Create or update GitHub secrets from the command line
  7. kexec: command not found
  8. Upgrading from CentOS/RHEL 7 to CentOS/RHEL 8 using Leapp
  9. fdisk: command not found
  10. nmap: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright