e2fsck command examples

  • e2fsck is used to check a Linux ext2/ext3/ext4 file system.
  • It comes from “e2fsprogs-1.41.12” package, we have covered almost all options here.
  • Path: /sbin/e2fsck

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

 

Related Commands: e2fsck.conf, badblocks, dumpe2fs, debugfs, e2image, mke2fs, tune2fs 

Leave a Reply

Your email address will not be published. Required fields are marked *