blob: 231a3e31c34b94df2a2107d4a10888429ff598ae [file] [log] [blame]
.\" -*- nroff -*-
.\" Copyright 1993, 1994, 1995 by Theodore Ts'o. All Rights Reserved.
.\" This file may be copied under the terms of the GNU Public License.
.\"
.TH DEBUGFS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
.SH NAME
debugfs \- ext2 file system debugger
.SH SYNOPSIS
.B debugfs
[
.B \-b
blocksize
]
[
.B \-s
superblock
]
[
.B \-f
cmd_file
]
[
.B \-R
request
]
[
.B \-V
]
[
[
.B \-w
]
[
.B \-c
]
[
.B \-i
]
[
device
]
]
.SH DESCRIPTION
The
.B debugfs
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
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
to read in commands from
.IR cmd_file ,
and execute them. When
.B debugfs
is finished executing those commands, it will exit.
.TP
.I -R request
Causes
.B debugfs
to execute the single command
.IR request ,
and then exit.
.TP
.I -V
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
supports.
.TP
.I cat filespec
Dump the contents of the inode
.I filespec
to stdout.
.TP
.I cd filespec
Change the current working directory to
.IR filespec .
.TP
.I chroot filespec
Change the root directory to be the directory
.IR filespec .
.TP
.I close
Close the currently open file system.
.TP
.I clri file
Clear the contents of the inode
.IR file .
.TP
.I dump [-p] filspec out_file
Dump the contents of the inode
.I filespec
to the output file
.IR out_file .
If the
.I -p
option is given set the owner, group and permissions information on
.I out_file
to match
.IR filespec .
.TP
.I expand_dir filespec
Expand the directory
.IR filespec .
.TP
.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
.I find_free_inode [dir [mode]]
Find a free inode and allocate it. If present,
.I dir
specifies the inode number of the directory
which the inode is to be located. The second
optional argument
.I mode
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 [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
.IR filespec .
.TP
.I help
Print a list of commands understood by
.BR debugfs (8).
.TP
.I icheck block ...
Print a listing of the inodes which use the one or more blocks specified
on the command line.
.TP
.I initialize device blocksize
Create an ext2 file system on
.I device
with device size
.IR blocksize .
Note that this does not fully initialize all of the data structures;
to do this, use the
.BR mke2fs (8)
program. This is just a call to the low-level library, which sets up
the superblock and block descriptors.
.TP
.I kill_file filespec
Deallocate the inode
.I filespec
and its blocks. Note that this does not remove any directory
entries (if any) to this inode. See the
.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
which is a link to
.IR filespec .
Note this does not adjust the inode reference counts.
.TP
.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
.IR filespec .
.TP
.I mkdir filespec
Make a directory.
.TP
.I mknod filespec [p|[[c|b] major minor]]
Create a special device file (a named pipe, character or block device).
If a character or block device is to be made, the
.I major
and
.I minor
device numbers must be specified.
.TP
.I ncheck inode_num ...
Take the requested list of inode numbers, and print a listing of pathnames
to those inodes.
.TP
.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.
.TP
.I quit
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 .
If this causes the inode pointed to by
.I pathname
to have no other references, deallocate the file. This command functions
as the unlink() system call.
.I
.TP
.I rmdir filespec
Remove the directory
.IR filespec .
This function is currently not implemented.
.TP
.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 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 [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
.I filespec
is marked as allocated in the inode bitmap.
.TP
.I unlink pathname
Remove the link specified by
.I pathname
to an inode. Note this does not adjust the inode reference counts.
.TP
.I write source_file out_file
Create a file in the filesystem named
.IR out_file ,
and copy the contents of
.I source_file
into the destination file.
.SH AUTHOR
.B debugfs
was written by Theodore Ts'o <tytso@mit.edu>.
.SH SEE ALSO
.BR dumpe2fs (8),
.BR e2fsck (8),
.BR mke2fs (8)