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
43 program is an interactive file system debugger. It can be used to
44 examine and change the state of an ext2, ext3, or ext4 file system.
47 is a block device (e.g., /dev/sdXX) or a file containing the file system.
51 Specifies that the file system should be opened in read-write mode.
52 Without this option, the file system is opened in read-only mode.
55 Disables metadata checksum verification. This should only be used if
56 you believe the metadata to be correct despite the complaints of
60 Specifies that the file system should be opened in catastrophic mode, in
61 which the inode and group bitmaps are not read initially. This can be
62 useful for filesystems with significant corruption, but because of this,
63 catastrophic mode forces the filesystem to be opened read-only.
68 represents an ext2 image file created by the
70 program. Since the ext2 image file only contains the superblock, block
71 group descriptor, block and inode allocation bitmaps, and
74 commands will not function properly.
76 no safety checks are in place, and
78 may fail in interesting ways if commands such as
80 etc. are tried without specifying the
86 is a debugging tool. It has rough edges!
88 .I -d data_source_device
91 option, specifies that
93 should be used when reading blocks not found in the ext2 image file.
94 This includes data, directory, and indirect blocks.
97 Forces the use of the given block size (in bytes) for the file system,
98 rather than detecting the correct block size automatically. (This
99 option is rarely needed; it is used primarily when the file system is
100 extremely badly damaged/corrupted.)
103 Causes the file system superblock to be read from the given block
104 number, instead of using the primary superblock (located at an offset of
105 1024 bytes from the beginning of the filesystem). If you specify the
107 option, you must also provide the blocksize of the filesystem via the
110 option is rarely needed; it is used primarily when the file system is
111 extremely badly damaged/corrupted.)
116 to read in commands from
118 and execute them. When
120 is finished executing those commands, it will exit.
125 to open the device using Direct I/O, bypassing the buffer cache. Note
126 that some Linux devices, notably device mapper as of this writing, do
127 not support Direct I/O.
132 to execute the single command
137 print the version number of
142 Before overwriting a file system block, write the old contents of the block to
143 an undo file. This undo file can be used with e2undo(8) to restore the old
144 contents of the file system should something go wrong. If the empty string is
145 passed as the undo_file argument, the undo file will be written to a file named
146 debugfs-\fIdevice\fR.e2undo in the directory specified via the
147 \fIE2FSPROGS_UNDO_DIR\fR environment variable.
149 WARNING: The undo file cannot be used to recover from a power or system crash.
155 as an argument to specify an inode (as opposed to a pathname)
156 in the filesystem which is currently opened by
160 argument may be specified in two forms. The first form is an inode
161 number surrounded by angle brackets, e.g.,
163 The second form is a pathname; if the pathname is prefixed by a forward slash
164 ('/'), then it is interpreted relative to the root of the filesystem
165 which is currently opened by
167 If not, the pathname is
168 interpreted relative to the current working directory as maintained by
170 This may be modified by using the
178 This is a list of the commands which
182 .BI blocks " filespec"
183 Print the blocks used by the inode
187 .BI bmap " [ -a ] filespec logical_block [physical_block]"
188 Print or set the physical block number corresponding to the logical block number
194 flag is specified, try to allocate a block if necessary.
196 .BI block_dump " '[ -x ] [-f filespec] block_num"
197 Dump the filesystem block given by
199 in hex and ASCII format to the console. If the
201 option is specified, the block number is relative to the start of the given
205 option is specified, the block is interpreted as an extended attribute
206 block and printed to show the structure of extended attribute data
210 Dump the contents of the inode
215 Change the current working directory to
218 .BI chroot " filespec"
219 Change the root directory to be the directory
223 Close the currently open file system. If the
225 option is specified, write out any changes to the superblock and block
226 group descriptors to all of the backup superblocks, not just to the
230 Clear the contents of the inode
233 .BI copy_inode " source_inode destination_inode"
234 Copy the contents of the inode structure in
236 and use it to overwrite the inode structure at
237 .IR destination_inode .
239 .BI dirsearch " filespec filename"
245 .BI dirty " [-clean]"
246 Mark the filesystem as dirty, so that the superblocks will be written on exit.
247 Additionally, clear the superblock's valid flag, or set it if
251 .BI dump " [-p] filespec out_file"
252 Dump the contents of the inode
258 option is given set the owner, group and permissions information on
263 .BI dump_mmp " [mmp_block]"
264 Display the multiple-mount protection (mmp) field values. If
266 is specified then verify and dump the MMP values from the given block
267 number, otherwise use the
269 field in the superblock to locate and use the existing MMP block.
271 .BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
272 Calculate the directory hash of
274 The hash algorithm specified with
277 .BR legacy , " half_md4" ", or " tea .
278 The hash seed specified with
280 must be in UUID format.
282 .BI dump_extents " [-n] [-l] filespec"
283 Dump the the extent tree of the inode
289 to only display the interior nodes in the extent tree. The
293 to only display the leaf nodes in the extent tree.
295 (Please note that the length and range of blocks for the last extent in
296 an interior node is an estimate by the extents library functions, and is
297 not stored in filesystem data structures. Hence, the values displayed
298 may not necessarily by accurate and does not indicate a problem or
299 corruption in the file system.)
302 Dump unused blocks which contain non-null bytes.
304 .BI ea_get " [-f outfile]|[-xVC] [-r] filespec attr_name"
305 Retrieve the value of the extended attribute
309 and write it either to stdout or to \fIoutfile\fR.
311 .BI ea_list " filespec
312 List the extended attributes associated with the file
316 .BI ea_set " [-f infile] [-r] filespec attr_name attr_value
317 Set the value of the extended attribute
323 or read it from \fIinfile\fR.
325 .BI ea_rm " filespec attr_names...
326 Remove the extended attribute
328 from the file \fIfilespec\fR.
330 .BI expand_dir " filespec"
334 .BI fallocate " filespec start_block [end_block]
335 Allocate and map uninitialized blocks into \fIfilespec\fR between
336 logical block \fIstart_block\fR and \fIend_block\fR, inclusive. If
337 \fIend_block\fR is not supplied, this function maps until it runs out
338 of free disk blocks or the maximum file size is reached. Existing
339 mappings are left alone.
341 .BI feature " [fs_feature] [-fs_feature] ..."
342 Set or clear various filesystem features in the superblock. After setting
343 or clearing any filesystem features that were requested, print the current
344 state of the filesystem feature set.
346 .BI filefrag " [-dvr] filespec"
347 Print the number of contiguous extents in
351 is a directory and the
353 option is not specified,
355 will print the number of contiguous extents for each file in
360 print a tabular listing of the contiguous extents in the
365 to do a recursive listing of the directory.
367 .BI find_free_block " [count [goal]]"
370 free blocks, starting from
372 and allocate it. Also available as
375 .BI find_free_inode " [dir [mode]]"
376 Find a free inode and allocate it. If present,
378 specifies the inode number of the directory
379 which the inode is to be located. The second
382 specifies the permissions of the new inode. (If the directory bit is set
383 on the mode, the allocation routine will function differently.) Also
387 .BI freeb " block [count]"
388 Mark the block number
391 If the optional argument
395 blocks starting at block number
397 will be marked as not allocated.
399 .BI freefrag " [-c chunk_kb]"
400 Report free space fragmentation on the currently open file system.
403 option is specified then the filefrag command will print how many free
406 can be found in the file system. The chunk size must be a power of two
407 and be larger than the file system block size.
409 .BI freei " filespec [num]"
410 Free the inode specified by
414 is specified, also clear num-1 inodes after the specified inode.
416 .BI get_quota " quota_type id"
417 Display quota information for given quota type (user, group, or project) and ID.
420 Print a list of commands understood by
423 .BI htree_dump " filespec"
424 Dump the hash-indexed directory
426 showing its tree structure.
428 .BI icheck " block ..."
429 Print a listing of the inodes which use the one or more blocks specified
432 .BI inode_dump " [-b]|[-e]|[-x] filespec"
433 Print the contents of the inode data structure in hex and ASCII format.
436 option causes the command to only dump the contents of the
440 option causes the command to only dump the contents of the extra inode
441 space, which is used to store in-line extended attributes. The
443 option causes the command to dump the extra inode space interpreted and
444 extended attributes. This is useful to debug corrupted inodes
445 containing extended attributes.
448 Print the location of the inode data structure (in the inode table)
452 .BI init_filesys " device blocksize"
453 Create an ext2 file system on
457 Note that this does not fully initialize all of the data structures;
460 program. This is just a call to the low-level library, which sets up
461 the superblock and block descriptors.
464 Close the open journal.
466 .BI journal_open " [-c] [-v ver] [-f ext_jnl]
467 Opens the journal for reading and writing. Journal checksumming can
468 be enabled by supplying \fI-c\fR; checksum formats 2 and 3 can be
469 selected with the \fI-v\fR option. An external journal can be loaded
473 Replay all transactions in the open journal.
475 .BI journal_write " [-b blocks] [-r revoke] [-c] file
476 Write a transaction to the open journal. The list of blocks to write
477 should be supplied as a comma-separated list in \fIblocks\fR; the
478 blocks themselves should be readable from \fIfile\fR. A list of
479 blocks to revoke can be supplied as a comma-separated list in
480 \fIrevoke\fR. By default, a commit record is written at the end; the
481 \fI-c\fR switch writes an uncommitted transaction.
483 .BI kill_file " filespec"
486 and its blocks. Note that this does not remove any directory
487 entries (if any) to this inode. See the
489 command if you wish to unlink a file.
492 Change the current working directory of the
496 on the native filesystem.
498 .BI list_quota " quota_type"
499 Display quota information for given quota type (user, group, or project).
501 .BI ln " filespec dest_file"
504 which is a hard link to
506 Note this does not adjust the inode reference counts.
508 .BI logdump " [-acsOS] [-b block] [-i filespec] [-f journal_file] [output_file]"
509 Dump the contents of the ext3 journal. By default, dump the journal inode as
510 specified in the superblock. However, this can be overridden with the
512 option, which dumps the journal from the internal inode given by
514 A regular file containing journal data can be specified using the
518 option utilizes the backup information in the superblock to locate the
525 to print the contents of the journal superblock.
531 program to print the contents of all of the descriptor blocks.
536 to print all journal records that refer to the specified block.
539 option will print out the contents of all of the data blocks selected by
548 option causes logdump to display old (checkpointed) journal entries.
549 This can be used to try to track down journal problems even after the
550 journal has been replayed.
552 .BI ls " [-l] [-c] [-d] [-p] [-r] filespec"
553 Print a listing of the files in the directory
557 flag causes directory block checksums (if present) to be displayed.
560 flag will list deleted entries in the directory.
563 flag will list files using a more verbose format.
566 flag will list the files in a format which is more easily parsable by
567 scripts, as well as making it more clear when there are spaces or other
568 non-printing characters at the end of filenames.
571 flag will force the printing of the filename, even if it is encrypted.
573 .BI list_deleted_inodes " [limit]"
574 List deleted inodes, optionally limited to those deleted within
576 seconds ago. Also available as
579 This command was useful for recovering from accidental file deletions
580 for ext2 file systems. Unfortunately, it is not useful for this purpose
581 if the files were deleted using ext3 or ext4, since the inode's
582 data blocks are no longer available after the inode is released.
584 .BI modify_inode " filespec"
585 Modify the contents of the inode structure in the inode
590 .BI mkdir " filespec"
593 .BI mknod " filespec [p|[[c|b] major minor]]"
594 Create a special device file (a named pipe, character or block device).
595 If a character or block device is to be made, the
599 device numbers must be specified.
601 .BI ncheck " [-c] inode_num ..."
602 Take the requested list of inode numbers, and print a listing of pathnames
605 flag will enable checking the file type information in the directory
606 entry to make sure it matches the inode's type.
608 .BI open " [-weficD] [-b blocksize] [-d image_filename] [-s superblock] [-z undo_file] device"
609 Open a filesystem for editing. The
611 flag forces the filesystem to be opened even if there are some unknown
612 or incompatible filesystem features which would normally
613 prevent the filesystem from being opened. The
615 flag causes the filesystem to be opened in exclusive mode. The
616 .IR -b ", " -c ", " -d ", " -i ", " -s ", " -w ", and " -D
617 options behave the same as the command-line options to
620 .BI punch " filespec start_blk [end_blk]"
621 Delete the blocks in the inode ranging from
627 is omitted then this command will function as a truncate command; that
628 is, all of the blocks starting at
630 through to the end of the file will be deallocated.
632 .BI symlink " filespec target"
633 Make a symbolic link.
636 Print the current working directory.
642 .BI rdump " directory[...] destination"
647 and all its contents (including regular files, symbolic links, and other
648 directories) into the named
650 which should be an existing directory on the native filesystem.
655 If this causes the inode pointed to by
657 to have no other references, deallocate the file. This command functions
658 as the unlink() system call.
661 .BI rmdir " filespec"
665 .BI setb " block [count]"
666 Mark the block number
669 If the optional argument
673 blocks starting at block number
675 will be marked as allocated.
677 .BI set_block_group " bgnum field value"
678 Modify the block group descriptor specified by
680 so that the block group descriptor field
687 .BI set_current_time " time"
688 Set current time in seconds since Unix epoch to use when setting filesystem
691 .BI seti " filespec [num]"
694 as in use in the inode bitmap. If
696 is specified, also set num-1 inodes after the specified inode.
698 .BI set_inode_field " filespec field value"
699 Modify the inode specified by
701 so that the inode field
705 The list of valid inode fields which can be set via this command
706 can be displayed by using the command:
707 .B set_inode_field -l
711 .BI set_mmp_value " field value"
712 Modify the multiple-mount protection (MMP) data so that the MMP field
716 The list of valid MMP fields which can be set via this command
717 can be displayed by using the command:
722 .BI set_super_value " field value"
723 Set the superblock field
727 The list of valid superblock fields which can be set via this command
728 can be displayed by using the command:
729 .B set_super_value -l
733 .B show_debugfs_params
736 parameters such as information about currently opened filesystem.
738 .BI show_super_stats " [-h]"
739 List the contents of the super block and the block group descriptors. If the
741 flag is given, only print out the superblock contents. Also available as
745 Display the contents of the inode structure of the inode
748 .B supported_features
749 Display filesystem features supported by this version of
752 .BI testb " block [count]"
753 Test if the block number
755 is marked as allocated in the block bitmap.
756 If the optional argument
760 blocks starting at block number
764 .BI testi " filespec"
767 is marked as allocated in the inode bitmap.
769 .BI undel " <inode_number> [pathname]"
770 Undelete the specified inode number (which must be surrounded by angle
771 brackets) so that it and its blocks are marked in use, and optionally
772 link the recovered inode to the specified pathname. The
774 command should always be run after using the
776 command to recover deleted files.
778 Note that if you are recovering a large number of deleted files, linking
779 the inode to a directory may require the directory to be expanded, which
780 could allocate a block that had been used by one of the
781 yet-to-be-undeleted files. So it is safer to undelete all of the
782 inodes without specifying a destination pathname, and then in a separate
783 pass, use the debugfs
785 command to link the inode to the destination pathname, or use
787 to check the filesystem and link all of the recovered inodes to the
788 lost+found directory.
790 .BI unlink " pathname"
791 Remove the link specified by
793 to an inode. Note this does not adjust the inode reference counts.
795 .BI write " source_file out_file"
798 into a newly-created file in the filesystem named
801 .BI zap_block " [-f filespec] [-o offset] [-l length] [-p pattern] block_num"
802 Overwrite the block specified by
804 with zero (NUL) bytes, or if
806 is given use the byte specified by
812 is relative to the start of the file given by
818 options limit the range of bytes to zap to the specified
822 relative to the start of the block.
824 .BI zap_block " [-f filespec] [-b bit] block_num"
825 Bit-flip portions of the physical
831 is a logical block relative to the start of
833 .SH ENVIRONMENT VARIABLES
835 .B DEBUGFS_PAGER, PAGER
838 program always pipes the output of the some commands through a
839 pager program. These commands include:
840 .IR show_super_stats " (" stats ),
841 .IR list_directory " (" ls ),
842 .IR show_inode_info " (" stat ),
843 .IR list_deleted_inodes " (" lsdel ),
846 The specific pager can explicitly specified by the
848 environment variable, and if it is not set, by the
850 environment variable.
852 Note that since a pager is always used, the
854 pager is not particularly appropriate, since it clears the screen before
855 displaying the output of the command and clears the output the screen
856 when the pager is exited. Many users prefer to use the
858 pager for most purposes, which is why the
860 environment variable is available to override the more general
862 environment variable.
865 was written by Theodore Ts'o <tytso@mit.edu>.