.\" -*- 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 \-f 
cmd_file
]
[
.B \-R
request
]
[
.B \-V
]
[
.B \-w
[
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.
.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 -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 COMMANDS
.B debugfs
is an interactive debugger. It understands a number of commands.
.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 find_free_block [goal]
Find the first free block, 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
Mark the block number
.I block
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 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 ls [-l] filespec
Print a listing of the files in the directory
.IR filespec .
.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] device
Open a file system for editing.  
.TP
.I pwd
Print the current working directory.
.TP
.I quit
Quit
.B debugfs
.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
Mark the block number
.I block
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.
.TP
.I stat filespec
Display the contents of the inode structure of the inode
.IR filespec .
.TP
.I testb block
Test if the block number
.I block
is marked as allocated in the block bitmap.
.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 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>.
.SH SEE ALSO
.BR dumpe2fs (8),
.BR e2fsck (8),
.BR mke2fs (8)
