.SH SYNOPSIS
.B debugfs
[
+.B \-b
+blocksize
+]
+[
+.B \-s
+superblock
+]
+[
.B \-f
cmd_file
]
.B \-V
]
[
+[
.B \-w
+]
+[
+.B \-c
+]
+[
+.B \-i
+]
[
device
]
.SH DESCRIPTION
The
.B debugfs
-program
-is a file system debugger. It can be used to examine and change the
-state of an ext2 file system.
+program is an interactive file system debugger. It can be used to
+examine and change the state of an ext2 file system.
.br
.I device
is the special file corresponding to the device containing the ext2
file system (e.g /dev/hdXX).
.SH OPTIONS
.TP
-.I -w
+.I \-w
Specifies that the file system should be opened in read-write mode.
Without this option, the file system is opened in read-only mode.
.TP
+.I \-c
+Specifies that the file system should be opened in catastrophic mode, in
+which the inode and group bitmaps are not read initially. This can be
+useful for filesystems with significant corruption, but because of this,
+catastrophic mode forces the filesystem to be opened read-only.
+.TP
+.I \-i
+Specifies that
+.I device
+represents an ext2 image file created by the
+.B e2image
+program. Since the ext2 image file only contains the superblock, block
+group descriptor, block and inode allocation bitmaps, and
+the inode table, many
+.B debugfs
+commands will not function properly.
+.B Warning:
+no safety checks are in place, and
+.B debugfs
+may fail in interesting ways if commands such as
+.IR ls ", " dump ", "
+etc. are tried.
+.B debugfs
+is a debugging tool. It has rough edges!
+.TP
+.I -b blocksize
+Forces the use of the given block size for the file system, rather than
+detecting the correct block size as normal.
+.TP
+.I -s superblock
+Causes the file system superblock to be read from the given block number,
+rather than the default (1). If you give a
+.I -s
+option, you must also give a
+.I -b
+option.
+.TP
.I -f cmd_file
Causes
.B debugfs
print the version number of
.B debugfs
and exit.
+.SH SPECIFYING FILES
+Many
+.B debugfs
+commands take a
+.I filespec
+as an argument to specify an inode (as opposed to a pathname)
+in the filesystem which is currently opened by
+.BR debugfs .
+The
+.I filespec
+argument may be specified in two forms. The first form is an inode
+number surrounded by angle brackets, e.g.,
+.IR <2> .
+The second form is a pathname; if the pathname is prefixed by a forward slash
+('/'), then it is interpreted relative to the root of the filesystem
+which is currently opened by
+.BR debugfs .
+If not, the pathname is
+interpreted relative to the current working directory as maintained by
+.BR debugfs .
+This may be modified by using the
+.B debugfs
+command
+.IR cd .
+.\"
+.\"
+.\"
.SH COMMANDS
+This is a list of the commands which
.B debugfs
-is an interactive debugger. It understands a number of commands.
+supports.
.TP
.I cat filespec
Dump the contents of the inode
Expand the directory
.IR filespec .
.TP
-.I find_free_block [goal]
-Find the first free block, starting from
+.I feature [fs_feature] [-fs_feature] ...
+Set or clear various filesystem features in the superblock. After setting
+or clearing any filesystem features that were requested, print the current
+state of the filesystem feature set.
+.TP
+.I find_free_block [count [goal]]
+Find the first
+.I count
+free blocks, starting from
.I goal
and allocate it.
.TP
specifies the permissions of the new inode. (If the directory bit is set
on the mode, the allocation routine will function differently.)
.TP
-.I freeb block
+.I freeb block [count]
Mark the block number
.I block
as not allocated.
+If the optional argument
+.I count
+is present, then
+.I count
+blocks starting at block number
+.I block
+will be marked as not allocated.
.TP
.I freei filespec
Free the inode specified by
.BR rm (1)
command if you wish to unlink a file.
.TP
+.I lcd directory
+Change the current working directory of the
+.B debugfs
+process to
+.I directory
+on the native filesystem.
+.TP
.I ln filespec dest_file
Create a link named
.I dest_file
.IR filespec .
Note this does not adjust the inode reference counts.
.TP
-.I ls [-l] filespec
+.I logdump [-ac] [-b<block>] [-i<inode>] [-f<journal_file>] [output_file]
+Dump the contents of the ext3 journal.
+.TP
+.I ls [-l] [-d] filespec
Print a listing of the files in the directory
.IR filespec .
+The
+.I \-l
+flag will list files using a more verbose format.
+The
+.I \-d
+flag will list deleted entries in the directory.
.TP
.I modify_inode filespec
Modify the contents of the inode structure in the inode
Take the requested list of inode numbers, and print a listing of pathnames
to those inodes.
.TP
-.I open [-w] device
-Open a file system for editing.
+.I open [-w] [-f] [-i] [-c] [-b blocksize] [-s superblock] device
+Open a filesystem for editing. The
+.I -w
+flag causes the filesystem to be opened for writing. The
+.I -f
+flag forces the filesystem to be opened even if there are some unknown
+or incompatible filesystem features which would normally
+prevent the filesystem from being opened. The
+.IR -c ", " -b ", " -i ", " and " -s
+options behave the same as those to
+.B debugfs
+itself.
.TP
.I pwd
Print the current working directory.
Quit
.B debugfs
.TP
+.I rdump directory destination
+Recursively dump
+.I directory
+and all its contents (including regular files, symbolic links, and other
+directories) into the named
+.I destination
+which should be an existing directory on the native filesystem.
+.TP
.I rm pathname
Unlink
.IR pathname .
.IR filespec .
This function is currently not implemented.
.TP
-.I setb block
+.I setb block [count]
Mark the block number
.I block
as allocated.
+If the optional argument
+.I count
+is present, then
+.I count
+blocks starting at block number
+.I block
+will be marked as allocated.
.TP
.I seti filespec
Mark inode
.I filespec
as in use in the inode bitmap.
.TP
-.I show_super_stats
-List the contents of the super block.
+.I set_super_value field value
+Set the superblock field
+.I field
+to
+.I value.
+The list of valid superblock fields which can be set via this command
+can be displayed by using the command:
+.B set_super_value -l
+.TP
+.I show_super_stats [-h]
+List the contents of the super block and the block group descriptors. If the
+.I -h
+flag is given, only print out the superblock contents.
.TP
.I stat filespec
Display the contents of the inode structure of the inode
.IR filespec .
.TP
-.I testb block
+.I testb block [count]
Test if the block number
.I block
is marked as allocated in the block bitmap.
+If the optional argument
+.I count
+is present, then
+.I count
+blocks starting at block number
+.I block
+will be tested.
.TP
.I testi filespec
Test if the inode
and copy the contents of
.I source_file
into the destination file.
-.SH SPECIFYING FILES
-Many
-.B debugfs
-commands take a
-.I filespec
-as an argument to specify an inode (as opposed to a pathname)
-in the filesystem which is currently opened by
-.BR debugfs .
-The
-.I filespec
-argument may be specified in two forms. The first form is an inode
-number surrounded by angle brackets, e.g.,
-.IR <2> .
-The second form is a pathname; if the pathname is prefixed by a forward slash
-('/'), then it is interpreted relative to the root of the filesystem
-which is currently opened by
-.BR debugfs .
-If not, the pathname is
-interpreted relative to the current working directory as maintained by
-.BR debugfs .
-This may be modified by using the
-.B debugfs
-command
-.IR cd .
.SH AUTHOR
.B debugfs
was written by Theodore Ts'o <tytso@mit.edu>.