LinuxCommandLibrary

debugfs

TLDR

Open filesystem in read-only mode

$ debugfs [/dev/sdXN]
copy
Open filesystem in read-write mode
$ debugfs -w [/dev/sdXN]
copy
Read commands from file
$ debugfs -f [path/to/cmd_file] [/dev/sdXN]
copy
View filesystem stats (interactive)
$ stats
copy
Close the filesystem (interactive)
$ close -a
copy
List available commands (interactive)
$ lr
copy

SYNOPSIS

debugfs [options] [device]

DESCRIPTION

debugfs is an interactive debugger for ext2/ext3/ext4 filesystems. It allows direct manipulation of filesystem structures, which is useful for data recovery, analysis, and troubleshooting.
Can be used to recover deleted files, examine inodes, and manually fix filesystem issues.

PARAMETERS

-w

Open in read-write mode
-f file
Read commands from file
-R command
Execute single command and exit
-c
Open filesystem as catastrophic mode (for corrupted filesystems)

INTERACTIVE COMMANDS

stats

Show filesystem statistics
ls dir
List directory
cat file
Display file contents
lsdel
List deleted inodes
dump inode file
Dump inode to file

CAVEATS

Requires root privileges. Use with extreme caution in write mode. Unmount filesystem before making changes. Improper use can cause data loss.

SEE ALSO

e2fsck(8), dumpe2fs(8), tune2fs(8)

Copied to clipboard