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

NAME

6       debugfs - ext2/ext3/ext4 file system debugger
7

SYNOPSIS

9       debugfs [ -DVwci ] [ -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, ext3, or ext4 file
15       system.
16       device is the special file corresponding to the device  containing  the
17       file system (e.g /dev/hdXX).
18

OPTIONS

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

SPECIFYING FILES

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

COMMANDS

84       This is a list of the commands which debugfs supports.
85
86       blocks filespace
87              Print the blocks used by the inode filespec to stdout.
88
89       bmap filespec logical_block
90              Print the physical block number  corresponding  to  the  logical
91              block number logical_block in the inode filespec.
92
93       block_dump [-f filespec] block_num
94              Dump  the  filesystem  block given by block_num in hex and ASCII
95              format to the console.  If the -f option is specified, the block
96              number is relative to the start of the given filespec.
97
98       cat filespec
99              Dump the contents of the inode filespec to stdout.
100
101       cd filespec
102              Change the current working directory to filespec.
103
104       chroot filespec
105              Change the root directory to be the directory filespec.
106
107       close [-a]
108              Close the currently open file system.  If the -a option is spec‐
109              ified, write out any changes to the superblock and  block  group
110              descriptors  to  all  of the backup superblocks, not just to the
111              master superblock.
112
113       clri filespec
114              Clear the contents of the inode filespec.
115
116       dirsearch filespec filename
117              Search the directory filespec for filename.
118
119       dirty  Mark the filesystem as dirty, so that the  superblocks  will  be
120              written on exit.
121
122       dump [-p] filespec out_file
123              Dump  the  contents  of  the  inode  filespec to the output file
124              out_file.  If the -p option is given set the  owner,  group  and
125              permissions information on out_file to match filespec.
126
127       dump_mmp
128              Display the multiple-mount protection (mmp) field values.
129
130       dx_hash [-h hash_alg] [-s hash_seed] filename
131              Calculate  the  directory  hash of filename.  The hash algorithm
132              specified with -h may be legacy, half_md4,  or  tea.   The  hash
133              seed specified with -s must be in UUID format.
134
135       dump_extents [-n] [-l] filespec
136              Dump  the  the  extent  tree of the inode filespec.  The -n flag
137              will cause dump_extents to only display the  interior  nodes  in
138              the  extent  tree.   The -l flag will cause dump_extents to only
139              display the leaf nodes in the extent tree.
140
141              (Please note that the length and range of blocks  for  the  last
142              extent in an interior node is an estimate by the extents library
143              functions, and is not  stored  in  filesystem  data  structures.
144              Hence,  the values displayed may not necessarily by accurate and
145              does not indicate a problem or corruption in the file system.)
146
147       expand_dir filespec
148              Expand the directory filespec.
149
150       feature [fs_feature] [-fs_feature] ...
151              Set or clear various  filesystem  features  in  the  superblock.
152              After  setting  or  clearing  any  filesystem features that were
153              requested, print the current state  of  the  filesystem  feature
154              set.
155
156       filefrag [-dvr] filespec
157              Print the number of contiguous extents in filespec.  If filespec
158              is a directory and the -d option is not specified, filefrag will
159              print  the  number  of  contiguous  extents for each file in the
160              directory.  The -v option will cause filefrag  print  a  tabular
161              listing  of  the  contiguous extents in the file.  The -r option
162              will cause filefrag to do a recursive listing of the directory.
163
164       find_free_block [count [goal]]
165              Find the first count free blocks, starting from goal  and  allo‐
166              cate it.  Also available as ffb.
167
168       find_free_inode [dir [mode]]
169              Find  a  free  inode and allocate it.  If present, dir specifies
170              the inode number of the directory  which  the  inode  is  to  be
171              located.   The  second optional argument mode specifies the per‐
172              missions of the new inode.  (If the directory bit is set on  the
173              mode,  the  allocation routine will function differently.)  Also
174              available as ffi.
175
176       freeb block [count]
177              Mark the block number block as not allocated.  If  the  optional
178              argument  count  is present, then count blocks starting at block
179              number block will be marked as not allocated.
180
181       freefrag [-c chunk_kb]
182              Report free space fragmentation on the currently open file  sys‐
183              tem.   If  the  -c option is specified then the filefrag command
184              will print how many free chunks of size chunk_kb can be found in
185              the  file  system.  The chunk size must be a power of two and be
186              larger than the file system block size.
187
188       freei filespec [num]
189              Free the inode specified by filespec.  If num is specified, also
190              clear num-1 inodes after the specified inode.
191
192       help   Print a list of commands understood by debugfs.
193
194       htree_dump filespec
195              Dump  the  hash-indexed  directory  filespec,  showing  its tree
196              structure.
197
198       icheck block ...
199              Print a listing of the inodes which use the one or  more  blocks
200              specified on the command line.
201
202       imap filespec
203              Print the location of the inode data structure (in the inode ta‐
204              ble) of the inode filespec.
205
206       init_filesys device blocksize
207              Create an ext2 file system on device with device size blocksize.
208              Note  that this does not fully initialize all of the data struc‐
209              tures; to do this, use the mke2fs(8) program.  This  is  just  a
210              call  to the low-level library, which sets up the superblock and
211              block descriptors.
212
213       kill_file filespec
214              Deallocate the inode filespec and its blocks.   Note  that  this
215              does  not  remove  any directory entries (if any) to this inode.
216              See the rm(1) command if you wish to unlink a file.
217
218       lcd directory
219              Change the current working directory of the debugfs  process  to
220              directory on the native filesystem.
221
222       ln filespec dest_file
223              Create  a link named dest_file which is a hard link to filespec.
224              Note this does not adjust the inode reference counts.
225
226       logdump [-acs] [-b block] [-i filespec] [-f journal_file] [output_file]
227              Dump the contents of the ext3 journal.   By  default,  dump  the
228              journal inode as specified in the superblock.  However, this can
229              be overridden with the -i option, which dumps the  journal  from
230              the internal inode given by filespec.  A regular file containing
231              journal data can be specified using the -f option.  Finally, the
232              -s  option  utilizes the backup information in the superblock to
233              locate the journal.
234
235              The -a option causes the logdump program to print  the  contents
236              of  all  of the descriptor blocks.  The -b option causes logdump
237              to print all journal records that are  refer  to  the  specified
238              block.   The -c option will print out the contents of all of the
239              data blocks selected by the -a and -b options.
240
241       ls [-d] [-l] [-p] filespec
242              Print a listing of the files in the directory filespec.  The  -d
243              flag  will  list  deleted entries in the directory.  The -l flag
244              will list files using a more verbose format.  The -p  flag  will
245              list  the  files  in  a  format which is more easily parsable by
246              scripts, as well as making it more clear when there  are  spaces
247              or other non-printing characters at the end of filenames.
248
249       list_deleted_inodes [limit]
250              List  deleted inodes, optionally limited to those deleted within
251              limit seconds ago.  Also available as lsdel.
252
253              This command was useful  for  recovering  from  accidental  file
254              deletions  for ext2 file systems.  Unfortunately, it is not use‐
255              ful for this purpose if the files were  deleted  using  ext3  or
256              ext4,  since  the  inode's  data  blocks are no longer available
257              after the inode is released.
258
259       modify_inode filespec
260              Modify the contents of the inode structure in  the  inode  file‐
261              spec.  Also available as mi.
262
263       mkdir filespec
264              Make a directory.
265
266       mknod filespec [p|[[c|b] major minor]]
267              Create  a  special device file (a named pipe, character or block
268              device).  If a character or block device  is  to  be  made,  the
269              major and minor device numbers must be specified.
270
271       ncheck [-c] inode_num ...
272              Take the requested list of inode numbers, and print a listing of
273              pathnames to those inodes.  The -c flag will enable checking the
274              file  type  information  in  the directory entry to make sure it
275              matches the inode's type.
276
277       open [-weficD] [-b blocksize] [-s superblock] device
278              Open a filesystem for editing.  The -f flag forces the  filesys‐
279              tem  to be opened even if there are some unknown or incompatible
280              filesystem features which would normally prevent the  filesystem
281              from  being  opened.   The  -e  flag causes the filesystem to be
282              opened in exclusive mode.  The  -b,  -c,  -i,  -s,  -w,  and  -D
283              options behave the same as the command-line options to debugfs.
284
285       punch filespec start_blk [end_blk]
286              Delete  the  blocks  in  the  inode  ranging  from  start_blk to
287              end_blk.  If end_blk is omitted then this command will  function
288              as  a  truncate  command; that is, all of the blocks starting at
289              start_blk through to the end of the file will be deallocated.
290
291       symlink filespec target
292              Make a symbolic link.
293
294       pwd    Print the current working directory.
295
296       quit   Quit debugfs
297
298       rdump directory destination
299              Recursively dump directory and all its contents (including regu‐
300              lar files, symbolic links, and other directories) into the named
301              destination which should be an existing directory on the  native
302              filesystem.
303
304       rm pathname
305              Unlink  pathname.   If this causes the inode pointed to by path‐
306              name to have no other references,  deallocate  the  file.   This
307              command functions as the unlink() system call.
308
309       rmdir filespec
310              Remove the directory filespec.
311
312       setb block [count]
313              Mark the block number block as allocated.  If the optional argu‐
314              ment count is present, then count blocks starting at block  num‐
315              ber block will be marked as allocated.
316
317       set_block_group bgnum field value
318              Modify the block group descriptor specified by bgnum so that the
319              block group descriptor field field has value value.  Also avail‐
320              able as set_bg.
321
322       seti filespec [num]
323              Mark  inode  filespec  as in use in the inode bitmap.  If num is
324              specified, also set num-1 inodes after the specified inode.
325
326       set_inode_field filespec field value
327              Modify the inode specified by filespec so that the  inode  field
328              field has value value.  The list of valid inode fields which can
329              be set via this command can be displayed by using  the  command:
330              set_inode_field -l Also available as sif.
331
332       set_mmp_value field value
333              Modify  the multiple-mount protection (MMP) data so that the MMP
334              field field has value value.  The list of valid MMP fields which
335              can  be  set via this command can be displayed by using the com‐
336              mand: set_mmp_value -l Also available as smmp.
337
338       set_super_value field value
339              Set the superblock field field to  value.   The  list  of  valid
340              superblock  fields which can be set via this command can be dis‐
341              played by using the command: set_super_value -l  Also  available
342              as ssv.
343
344       show_super_stats [-h]
345              List  the  contents  of  the  super  block  and  the block group
346              descriptors.  If the -h  flag  is  given,  only  print  out  the
347              superblock contents. Also available as stats.
348
349       stat filespec
350              Display  the  contents of the inode structure of the inode file‐
351              spec.
352
353       testb block [count]
354              Test if the block number block is marked  as  allocated  in  the
355              block  bitmap.   If the optional argument count is present, then
356              count blocks starting at block number block will be tested.
357
358       testi filespec
359              Test if the inode filespec is marked as allocated in  the  inode
360              bitmap.
361
362       undel <inode_number> [pathname]
363              Undelete the specified inode number (which must be surrounded by
364              angle brackets) so that it and its blocks are marked in use, and
365              optionally  link  the recovered inode to the specified pathname.
366              The e2fsck command should always be run after  using  the  undel
367              command to recover deleted files.
368
369              Note that if you are recovering a large number of deleted files,
370              linking the inode to a directory may require the directory to be
371              expanded, which could allocate a block that had been used by one
372              of the yet-to-be-undeleted files.  So it is  safer  to  undelete
373              all of the inodes without specifying a destination pathname, and
374              then in a separate pass, use the debugfs link  command  to  link
375              the  inode  to  the destination pathname, or use e2fsck to check
376              the filesystem and link all  of  the  recovered  inodes  to  the
377              lost+found directory.
378
379       unlink pathname
380              Remove  the  link  specified by pathname to an inode.  Note this
381              does not adjust the inode reference counts.
382
383       write source_file out_file
384              Copy the contents of source_file into a  newly-created  file  in
385              the filesystem named out_file.
386
387       zap_block [-f filespec] [-o offset] [-l length] [-p pattern] block_num
388
389       Overwrite the block specified by
390              block_num  with zero (NUL) bytes, or if -p is given use the byte
391              specified by pattern.  If -f is given then block_num is relative
392              to  the  start  of  the  file  given by filespec.  The -o and -l
393              options limit the range of bytes to zap to the specified  offset
394              and length relative to the start of the block.
395
396       zap_block [-f filespec] [-b bit] block_num
397              Bit-flip  portions  of  the physical block_num.  If -f is given,
398              then block_num is a logical block relative to the start of file‐
399              spec.
400

ENVIRONMENT VARIABLES

402       DEBUGFS_PAGER, PAGER
403              The debugfs program always pipes the output of the some commands
404              through   a   pager   program.     These    commands    include:
405              show_super_stats  (stats),  list_directory (ls), show_inode_info
406              (stat), list_deleted_inodes (lsdel), and htree_dump.   The  spe‐
407              cific  pager can explicitly specified by the DEBUGFS_PAGER envi‐
408              ronment variable, and if it is not set, by the PAGER environment
409              variable.
410
411              Note that since a pager is always used, the less(1) pager is not
412              particularly appropriate, since it clears the screen before dis‐
413              playing  the  output  of  the  command and clears the output the
414              screen when the pager is exited.  Many users prefer to  use  the
415              less(1)  pager for most purposes, which is why the DEBUGFS_PAGER
416              environment variable is available to override the  more  general
417              PAGER environment variable.
418

AUTHOR

420       debugfs was written by Theodore Ts'o <tytso@mit.edu>.
421

SEE ALSO

423       dumpe2fs(8), tune2fs(8), e2fsck(8), mke2fs(8), ext4(5)
424
425
426
427E2fsprogs version 1.42.9         December 2013                      DEBUGFS(8)
Impressum