1DEBUGFS(8)                  System Manager's Manual                 DEBUGFS(8)
2
3
4

NAME

6       debugfs - ext2/ext3 file system debugger
7

SYNOPSIS

9       debugfs  [ -Vwci ] [ -b blocksize ] [ -s superblock ] [ -f cmd_file ] [
10       -R request ] [ -d data_source_device ] [ device ]
11

DESCRIPTION

13       The debugfs program is an interactive file system debugger. It  can  be
14       used to examine and change the state of an ext2 file system.
15       device  is  the special file corresponding to the device containing the
16       ext2 file system (e.g /dev/hdXX).
17

OPTIONS

19       -w     Specifies that the file system should be  opened  in  read-write
20              mode.   Without  this option, the file system is opened in read-
21              only mode.
22
23       -c     Specifies that the file system should be opened in  catastrophic
24              mode,  in  which  the  inode and group bitmaps are not read ini‐
25              tially.  This can be useful  for  filesystems  with  significant
26              corruption,  but  because  of this, catastrophic mode forces the
27              filesystem to be opened read-only.
28
29       -i     Specifies that device represents an ext2 image file  created  by
30              the  e2image  program.   Since the ext2 image file only contains
31              the superblock, block group descriptor, block and inode  alloca‐
32              tion  bitmaps,  and  the inode table, many debugfs commands will
33              not function properly.  Warning: no safety checks are in  place,
34              and debugfs may fail in interesting ways if commands such as ls,
35              dump, etc. are tried without specifying  the  data_source_device
36              using the -d option.  debugfs is a debugging tool.  It has rough
37              edges!
38
39       -d data_source_device
40              Used with  the  -i  option,  specifies  that  data_source_device
41              should  be  used when reading blocks not found in the ext2 image
42              file.  This includes data, directory, and indirect blocks.
43
44       -b blocksize
45              Forces the use of the given block  size  for  the  file  system,
46              rather than detecting the correct block size as normal.
47
48       -s superblock
49              Causes  the  file  system  superblock  to be read from the given
50              block number, rather than the default (1).  If  you  give  a  -s
51              option, you must also give a -b option.
52
53       -f cmd_file
54              Causes  debugfs  to  read in commands from cmd_file, and execute
55              them.  When debugfs is finished  executing  those  commands,  it
56              will exit.
57
58       -R request
59              Causes  debugfs  to execute the single command request, and then
60              exit.
61
62       -V     print the version number of debugfs and exit.
63

SPECIFYING FILES

65       Many debugfs commands take a filespec as  an  argument  to  specify  an
66       inode  (as  opposed to a pathname) in the filesystem which is currently
67       opened by debugfs.  The filespec  argument  may  be  specified  in  two
68       forms.  The first form is an inode number surrounded by angle brackets,
69       e.g., <2>.  The second form is a pathname; if the pathname is  prefixed
70       by  a  forward slash ('/'), then it is interpreted relative to the root
71       of the filesystem which is currently opened by debugfs.   If  not,  the
72       pathname  is  interpreted  relative to the current working directory as
73       maintained by debugfs.  This may be modified by using the debugfs  com‐
74       mand cd.
75

COMMANDS

77       This is a list of the commands which debugfs supports.
78
79       bmap filespec logical_block
80              Print  the  physical  block  number corresponding to the logical
81              block number logical_block in the inode filespec.
82
83       cat filespec
84              Dump the contents of the inode filespec to stdout.
85
86       cd filespec
87              Change the current working directory to filespec.
88
89       chroot filespec
90              Change the root directory to be the directory filespec.
91
92       close  Close the currently open file system.
93
94       clri file
95              Clear the contents of the inode file.
96
97       dump [-p] filspec out_file
98              Dump the contents of the  inode  filespec  to  the  output  file
99              out_file.   If  the  -p option is given set the owner, group and
100              permissions information on out_file to match filespec.
101
102       expand_dir filespec
103              Expand the directory filespec.
104
105       feature [fs_feature] [-fs_feature] ...
106              Set or clear various  filesystem  features  in  the  superblock.
107              After  setting  or  clearing  any  filesystem features that were
108              requested, print the current state  of  the  filesystem  feature
109              set.
110
111       find_free_block [count [goal]]
112              Find  the  first count free blocks, starting from goal and allo‐
113              cate it.
114
115       find_free_inode [dir [mode]]
116              Find a free inode and allocate it.  If  present,  dir  specifies
117              the  inode  number  of  the  directory  which the inode is to be
118              located.  The second optional argument mode specifies  the  per‐
119              missions  of the new inode.  (If the directory bit is set on the
120              mode, the allocation routine will function differently.)
121
122       freeb block [count]
123              Mark the block number block as not allocated.  If  the  optional
124              argument  count  is present, then count blocks starting at block
125              number block will be marked as not allocated.
126
127       freei filespec
128              Free the inode specified by filespec.
129
130       help   Print a list of commands understood by debugfs(8).
131
132       icheck block ...
133              Print a listing of the inodes which use the one or  more  blocks
134              specified on the command line.
135
136       imap filespec
137              Print the location of the inode data structure (in the inode ta‐
138              ble) of the inode filespec.
139
140       init_filesys device blocksize
141              Create an ext2 file system on device with device size blocksize.
142              Note  that this does not fully initialize all of the data struc‐
143              tures; to do this, use the mke2fs(8) program.  This  is  just  a
144              call  to the low-level library, which sets up the superblock and
145              block descriptors.
146
147       kill_file filespec
148              Deallocate the inode filespec and its blocks.   Note  that  this
149              does  not  remove  any directory entries (if any) to this inode.
150              See the rm(1) command if you wish to unlink a file.
151
152       lcd directory
153              Change the current working directory of the debugfs  process  to
154              directory on the native filesystem.
155
156       ln filespec dest_file
157              Create a link named dest_file which is a link to filespec.  Note
158              this does not adjust the inode reference counts.
159
160       logdump  [-acs]  [-b<block>]  [-i<filespec>]  [-f<journal_file>]  [out‐
161       put_file]
162              Dump  the contents of the ext3 journal.  By default, the journal
163              inode as specified in the  superblock.   However,  this  can  be
164              overridden  with the -i option, which uses an inode specifier to
165              specify the journal to be used.  A file containing journal  data
166              can  be  specified using the -f option.   Finally, the -s option
167              utilizes the backup information in the superblock to locate  the
168              journal.
169
170              The  -a  option causes the logdump program to print the contents
171              of all of the descriptor blocks.  The -b option  causes  logdump
172              to  print  all  journal  records that are refer to the specified
173              block.  The -c option will print out the contents of all of  the
174              data blocks selected by the -a and -b options.
175
176       ls [-l] [-d] filespec
177              Print  a listing of the files in the directory filespec.  The -l
178              flag will list files using a more verbose format.  The  -d  flag
179              will list deleted entries in the directory.
180
181       modify_inode filespec
182              Modify  the  contents  of the inode structure in the inode file‐
183              spec.
184
185       mkdir filespec
186              Make a directory.
187
188       mknod filespec [p|[[c|b] major minor]]
189              Create a special device file (a named pipe, character  or  block
190              device).   If  a  character  or  block device is to be made, the
191              major and minor device numbers must be specified.
192
193       ncheck inode_num ...
194              Take the requested list of inode numbers, and print a listing of
195              pathnames to those inodes.
196
197       open [-w] [-e] [-f] [-i] [-c] [-b blocksize] [-s superblock] device
198              Open  a filesystem for editing.  The -f flag forces the filesys‐
199              tem to be opened even if there are some unknown or  incompatible
200              filesystem  features which would normally prevent the filesystem
201              from being opened.  The -e flag  causes  the  filesystem  to  be
202              opened  in  exclusive  mode.  The -b, -c, -i, -s, and -w options
203              behave the same as the command-line options to debugfs.
204
205       pwd    Print the current working directory.
206
207       quit   Quit debugfs
208
209       rdump directory destination
210              Recursively dump directory and all its contents (including regu‐
211              lar files, symbolic links, and other directories) into the named
212              destination which should be an existing directory on the  native
213              filesystem.
214
215       rm pathname
216              Unlink  pathname.   If this causes the inode pointed to by path‐
217              name to have no other references,  deallocate  the  file.   This
218              command functions as the unlink() system call.
219
220       rmdir filespec
221              Remove the directory filespec.
222
223       setb block [count]
224              Mark the block number block as allocated.  If the optional argu‐
225              ment count is present, then count blocks starting at block  num‐
226              ber block will be marked as allocated.
227
228       set_block_group bgnum field value
229              Modify the block group descriptor specified by bgnum so that the
230              block group descriptor field field has value value.
231
232       seti filespec
233              Mark inode filespec as in use in the inode bitmap.
234
235       set_inode_field filespec field value
236              Modify the inode specified by filespec so that the  inode  field
237              field has value value.  The list of valid inode fields which can
238              be set via this command can be displayed by using  the  command:
239              set_inode_field -l
240
241       set_super_value field value
242              Set  the  superblock  field  field  to value.  The list of valid
243              superblock fields which can be set via this command can be  dis‐
244              played by using the command: set_super_value -l
245
246       show_super_stats [-h]
247              List  the  contents  of  the  super  block  and  the block group
248              descriptors.  If the -h  flag  is  given,  only  print  out  the
249              superblock contents.
250
251       stat filespec
252              Display  the  contents of the inode structure of the inode file‐
253              spec.
254
255       testb block [count]
256              Test if the block number block is marked  as  allocated  in  the
257              block  bitmap.   If the optional argument count is present, then
258              count blocks starting at block number block will be tested.
259
260       testi filespec
261              Test if the inode filespec is marked as allocated in  the  inode
262              bitmap.
263
264       unlink pathname
265              Remove  the  link  specified by pathname to an inode.  Note this
266              does not adjust the inode reference counts.
267
268       write source_file out_file
269              Create a file in the filesystem named  out_file,  and  copy  the
270              contents of source_file into the destination file.
271

ENVIRONMENT VARIABLES

273       DEBUGFS_PAGER, PAGER
274              The  debugfs(8) program always pipes the output of the some com‐
275              mands  through  a  pager  program.   These   commands   include:
276              show_super_stats,        list_directory,        show_inode_info,
277              list_deleted_inodes, and htree_dump.   The  specific  pager  can
278              explicitly  specified by the DEBUGFS_PAGER environment variable,
279              and if it is not set, by the PAGER environment variable.
280
281              Note that since a pager is always used, the less(1) pager is not
282              particularly appropriate, since it clears the screen before dis‐
283              playing the output of the command  and  clears  the  output  the
284              screen  when  the pager is exited.  Many users prefer to use the
285              less(1) pager for most purposes, which is why the  DEBUGFS_PAGER
286              environment  variable  is available to override the more general
287              PAGER environment variable.
288

AUTHOR

290       debugfs was written by Theodore Ts'o <tytso@mit.edu>.
291

SEE ALSO

293       dumpe2fs(8), e2fsck(8), mke2fs(8)
294
295
296
297E2fsprogs version 1.40.2           July 2007                        DEBUGFS(8)
Impressum