Debug a file system

You can interactively modify a file system’s features by using the debugfs utility in Linux. This utility can be used to examine and change the state of an ext2, ext3, or ext4 file system. debugfs provides the abilities of dumpe2fs, tune2fs, and many other file manipulation tools. The syntax of this program is simple: just type its name, followed by the device filename. This will open up the debugfs prompt:

linux debugfs command

Here is a list of the most commonly used commands:

  • show_super_stats or stats – produces superblock information, similar to what dumpe2fs displays. 
  • undelete INODE NAME – undeletes a file. INODE is the inode number of the deleted file and NAME the filename you want to give to it. You can get a list of deleted inodes by typing list_deleted_inodes.
  • write INTERNAL_FILE EXTERNAL_FILE – extracts a file from the file system. INTERNAL_FILE is the name of a file in the file system you’re manipulating and EXTERNAL_FILE is a filename on your main Linux system. This command comes in handy when you want to extract a critical file without mounting the file system first.
  • stat filename – displays the inode data on a file or directory.
  • help – shows the commands available.
  • quit – quits the program.

In addition to commands explained above, you can use many ordinary Linux commands inside the debugfs promt like cd, rm, rmdir, etc.

Here is an example on how to get file system information using debugfs:

linux debugfs stats command

This opens up a screen with lots of useful information about the file system:

linux debugfs stats command output

Do not use debugfs on a mounted file system.


You can use the xfs_db utility to modify an XFS file system’s features. Like debugfs, xfs_db provides an interactive tool to access and manipulate a file system:

linux xfs_db command

Type help to get a list of commands available.

Subscribe to our Newsletter

Like us on Facebook

Geek University 2019