Checking and Repairing an Ext File System

You use the fsck utility to check and repair file systems. For file systems other than root (/) and /boot, mount invokes file system checking if more than a specified number of mounts have occurred or more than 180 days have elapsed without checking having being performed. You might want to run fsck manually if a file system hasn't been checked for several months.

The following procedure describes how to check and repair an Ext file system.

Attention:

Running fsck on a mounted file system can corrupt the file system and cause data loss.

  1. Unmount the file system:

    sudo umount filesystem
  2. Use the fsck command to check the file system:

    sudo fsck [-y] file-system

    In the previous example, file-system specifies a device name, a mount point, a a label, or UUID specifier, for example:

    sudo fsck UUID=ad8113d7-b279-4da8-b6e4-cfba045f66ff

    By default, the fsck command prompts you to choose whether it should apply a suggested repair to the file system. If you specify the -y option, the command assumes a yes response to all such questions.

For the ext3, and ext4 file system types, other commands that are used to perform file system maintenance include dumpe2fs and debugfs. dumpe2fs prints super block and block group information for the file system on a specified device. debugfs is an interactive file system debugger that requires expert knowledge of the file system architecture. Similar commands exist for most file system types and also require expert knowledge.

For more information, see the fsck(8) manual page.