2 .\" Copyright 1993, 1994, 1995 by Theodore Ts'o. All Rights Reserved.
3 .\" This file may be copied under the terms of the GNU Public License.
5 .TH DEBUGFS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
7 debugfs \- ext2/ext3/ext4 file system debugger
39 program is an interactive file system debugger. It can be used to
40 examine and change the state of an ext2, ext3, or ext4 file system.
43 is the special file corresponding to the device containing the
44 file system (e.g /dev/hdXX).
48 Specifies that the file system should be opened in read-write mode.
49 Without this option, the file system is opened in read-only mode.
52 Specifies that the file system should be opened in catastrophic mode, in
53 which the inode and group bitmaps are not read initially. This can be
54 useful for filesystems with significant corruption, but because of this,
55 catastrophic mode forces the filesystem to be opened read-only.
60 represents an ext2 image file created by the
62 program. Since the ext2 image file only contains the superblock, block
63 group descriptor, block and inode allocation bitmaps, and
66 commands will not function properly.
68 no safety checks are in place, and
70 may fail in interesting ways if commands such as
72 etc. are tried without specifying the
78 is a debugging tool. It has rough edges!
80 .I -d data_source_device
83 option, specifies that
85 should be used when reading blocks not found in the ext2 image file.
86 This includes data, directory, and indirect blocks.
89 Forces the use of the given block size for the file system, rather than
90 detecting the correct block size as normal.
93 Causes the file system superblock to be read from the given block
94 number, instead of using the primary superblock (located at an offset of
95 1024 bytes from the beginning of the filesystem). If you specify the
97 option, you must also provide the blocksize of the filesystem via the
104 to read in commands from
106 and execute them. When
108 is finished executing those commands, it will exit.
113 to open the device using Direct I/O, bypassing the buffer cache. Note
114 that some Linux devices, notably device mapper as of this writing, do
115 not support Direct I/O.
120 to execute the single command
125 print the version number of
133 as an argument to specify an inode (as opposed to a pathname)
134 in the filesystem which is currently opened by
138 argument may be specified in two forms. The first form is an inode
139 number surrounded by angle brackets, e.g.,
141 The second form is a pathname; if the pathname is prefixed by a forward slash
142 ('/'), then it is interpreted relative to the root of the filesystem
143 which is currently opened by
145 If not, the pathname is
146 interpreted relative to the current working directory as maintained by
148 This may be modified by using the
156 This is a list of the commands which
161 Print the blocks used by the inode
165 .I bmap filespec logical_block
166 Print the physical block number corresponding to the logical block number
172 Dump the contents of the inode
177 Change the current working directory to
181 Change the root directory to be the directory
185 Close the currently open file system. If the
187 option is specified, write out any changes to the superblock and block
188 group descriptors to all of the backup superblocks, not just to the
192 Clear the contents of the inode
195 .I dirsearch filespec filename
201 .I dump [-p] filespec out_file
202 Dump the contents of the inode
208 option is given set the owner, group and permissions information on
213 .I dx_hash [-h hash_alg] [-s hash_seed] filename
214 Calculate the directory hash of
216 The hash algorithm specified with
218 may be "legacy" "half_md4" or "tea".
219 The hash seed specified with
221 must be in UUID format.
223 .I dump_extents [-n] [-l] filespec
224 Dump the the extent tree of the inode
230 to only display the interior nodes in the extent tree. The
234 to only display the leaf nodes in the extent tree.
236 (Please note that the length and range of blocks for the last extent in
237 an interior node is an estimate by the extents library functions, and is
238 not stored in filesystem data structures. Hence, the values displayed
239 may not necessarily by accurate and does not indicate a problem or
240 corruption in the file system.)
242 .I expand_dir filespec
246 .I feature [fs_feature] [-fs_feature] ...
247 Set or clear various filesystem features in the superblock. After setting
248 or clearing any filesystem features that were requested, print the current
249 state of the filesystem feature set.
251 .I find_free_block [count [goal]]
254 free blocks, starting from
258 .I find_free_inode [dir [mode]]
259 Find a free inode and allocate it. If present,
261 specifies the inode number of the directory
262 which the inode is to be located. The second
265 specifies the permissions of the new inode. (If the directory bit is set
266 on the mode, the allocation routine will function differently.)
268 .I freeb block [count]
269 Mark the block number
272 If the optional argument
276 blocks starting at block number
278 will be marked as not allocated.
281 Free the inode specified by
285 Print a list of commands understood by
288 .I htree_dump filespec
289 Dump the hash-indexed directory
291 showing its tree structure.
294 Print a listing of the inodes which use the one or more blocks specified
298 Print the location of the inode data structure (in the inode table)
302 .I init_filesys device blocksize
303 Create an ext2 file system on
307 Note that this does not fully initialize all of the data structures;
310 program. This is just a call to the low-level library, which sets up
311 the superblock and block descriptors.
313 .I kill_file filespec
316 and its blocks. Note that this does not remove any directory
317 entries (if any) to this inode. See the
319 command if you wish to unlink a file.
322 Change the current working directory of the
326 on the native filesystem.
328 .I ln filespec dest_file
333 Note this does not adjust the inode reference counts.
335 .I logdump [-acs] [-b<block>] [-i<filespec>] [-f<journal_file>] [output_file]
336 Dump the contents of the ext3 journal. By default, the journal inode as
337 specified in the superblock. However, this can be overridden with the
339 option, which uses an inode specifier to specify the journal to be
340 used. A file containing journal data can be specified using the
344 option utilizes the backup information in the superblock to locate the
351 program to print the contents of all of the descriptor blocks.
356 to print all journal records that are refer to the specified block.
359 option will print out the contents of all of the data blocks selected by
366 .I ls [-l] [-d] [-p] filespec
367 Print a listing of the files in the directory
371 flag will list files using a more verbose format.
374 flag will list deleted entries in the directory.
377 flag will list the files in a format which is more easily parsable by
378 scripts, as well as making it more clear when there are spaces or other
379 non-printing characters at the end of filenames.
381 .I modify_inode filespec
382 Modify the contents of the inode structure in the inode
388 .I mknod filespec [p|[[c|b] major minor]]
389 Create a special device file (a named pipe, character or block device).
390 If a character or block device is to be made, the
394 device numbers must be specified.
396 .I ncheck inode_num ...
397 Take the requested list of inode numbers, and print a listing of pathnames
400 .I open [-w] [-e] [-f] [-i] [-c] [-D] [-b blocksize] [-s superblock] device
401 Open a filesystem for editing. The
403 flag forces the filesystem to be opened even if there are some unknown
404 or incompatible filesystem features which would normally
405 prevent the filesystem from being opened. The
407 flag causes the filesystem to be opened in exclusive mode. The
408 .IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
409 options behave the same as the command-line options to
412 .I punch filespec start_blk [end_blk]
413 Delete the blocks in the inode ranging from
419 is omitted then this command will function as a truncate command; that
420 is, all of the blocks starting at
422 through to the end of the file will be deallocated.
425 Print the current working directory.
431 .I rdump directory destination
434 and all its contents (including regular files, symbolic links, and other
435 directories) into the named
437 which should be an existing directory on the native filesystem.
442 If this causes the inode pointed to by
444 to have no other references, deallocate the file. This command functions
445 as the unlink() system call.
452 .I setb block [count]
453 Mark the block number
456 If the optional argument
460 blocks starting at block number
462 will be marked as allocated.
464 .I set_block_group bgnum field value
465 Modify the block group descriptor specified by
467 so that the block group descriptor field
475 as in use in the inode bitmap.
477 .I set_inode_field filespec field value
478 Modify the inode specified by
480 so that the inode field
484 The list of valid inode fields which can be set via this command
485 can be displayed by using the command:
486 .B set_inode_field -l
488 .I set_super_value field value
489 Set the superblock field
493 The list of valid superblock fields which can be set via this command
494 can be displayed by using the command:
495 .B set_super_value -l
497 .I show_super_stats [-h]
498 List the contents of the super block and the block group descriptors. If the
500 flag is given, only print out the superblock contents.
503 Display the contents of the inode structure of the inode
506 .I testb block [count]
507 Test if the block number
509 is marked as allocated in the block bitmap.
510 If the optional argument
514 blocks starting at block number
521 is marked as allocated in the inode bitmap.
523 .I undel <inode num> [pathname]
524 Undelete the specified inode number (which must be surrounded by angle
525 brackets) so that it and its blocks are marked in use, and optionally
526 link the recovered inode to the specified pathname. The
528 command should always be run after using the
530 command to recover deleted files.
532 Note that if you are recovering a large number of deleted files, linking
533 the inode to a directory may require the directory to be expanded, which
534 could allocate a block that had been used by one of the
535 yet-to-be-undeleted files. So it is safer to undelete all of the
536 inodes without specifying a destination pathname, and then in a separate
537 pass, use the debugfs
539 command to link the inode to the destination pathname, or use
541 to check the filesystem and link all of the recovered inodes to the
542 lost+found directory.
545 Remove the link specified by
547 to an inode. Note this does not adjust the inode reference counts.
549 .I write source_file out_file
550 Create a file in the filesystem named
552 and copy the contents of
554 into the destination file.
555 .SH ENVIRONMENT VARIABLES
557 .B DEBUGFS_PAGER, PAGER
560 program always pipes the output of the some commands through a
561 pager program. These commands include:
562 .IR show_super_stats ,
564 .IR show_inode_info ,
565 .IR list_deleted_inodes ,
568 The specific pager can explicitly specified by the
570 environment variable, and if it is not set, by the
572 environment variable.
574 Note that since a pager is always used, the
576 pager is not particularly appropriate, since it clears the screen before
577 displaying the output of the command and clears the output the screen
578 when the pager is exited. Many users prefer to use the
580 pager for most purposes, which is why the
582 environment variable is available to override the more general
584 environment variable.
587 was written by Theodore Ts'o <tytso@mit.edu>.