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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. e4defrag: command not found
  2. How to Setup SSH keys for SSH “public/private key” Login On Linux
  3. einfo Command Examples in Linux
  4. du Command Examples in Linux
  5. How to Audit for Modifications to files and Executions of Files in Linux
  6. ‘docker images’ command error – “Permission Denied”
  7. CentOS / RHEL : Beginners guide to cron
  8. Failed to Download Metadata for Repo ‘repo_name’
  9. How to restrict ssh logins by user and client address on CentOS/RHEL
  10. coredumpctl: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright