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 the special file corresponding to the device containing the
48 file system (e.g /dev/hdXX).
52 Specifies that the file system should be opened in read-write mode.
53 Without this option, the file system is opened in read-only mode.
56 Disables metadata checksum verification. This should only be used if
57 you believe the metadata to be correct despite the complaints of
61 Specifies that the file system should be opened in catastrophic mode, in
62 which the inode and group bitmaps are not read initially. This can be
63 useful for filesystems with significant corruption, but because of this,
64 catastrophic mode forces the filesystem to be opened read-only.
69 represents an ext2 image file created by the
71 program. Since the ext2 image file only contains the superblock, block
72 group descriptor, block and inode allocation bitmaps, and
75 commands will not function properly.
77 no safety checks are in place, and
79 may fail in interesting ways if commands such as
81 etc. are tried without specifying the
87 is a debugging tool. It has rough edges!
89 .I -d data_source_device
92 option, specifies that
94 should be used when reading blocks not found in the ext2 image file.
95 This includes data, directory, and indirect blocks.
98 Forces the use of the given block size for the file system, rather than
99 detecting the correct block size as normal.
102 Causes the file system superblock to be read from the given block
103 number, instead of using the primary superblock (located at an offset of
104 1024 bytes from the beginning of the filesystem). If you specify the
106 option, you must also provide the blocksize of the filesystem via the
113 to read in commands from
115 and execute them. When
117 is finished executing those commands, it will exit.
122 to open the device using Direct I/O, bypassing the buffer cache. Note
123 that some Linux devices, notably device mapper as of this writing, do
124 not support Direct I/O.
129 to execute the single command
134 print the version number of
139 Before overwriting a file system block, write the old contents of the block to
140 an undo file. This undo file can be used with e2undo(8) to restore the old
141 contents of the file system should something go wrong. If the empty string is
142 passed as the undo_file argument, the undo file will be written to a file named
143 resize2fs-\fIdevice\fR.e2undo in the directory specified via the
144 \fIE2FSPROGS_UNDO_DIR\fR environment variable.
146 WARNING: The undo file cannot be used to recover from a power or system crash.
152 as an argument to specify an inode (as opposed to a pathname)
153 in the filesystem which is currently opened by
157 argument may be specified in two forms. The first form is an inode
158 number surrounded by angle brackets, e.g.,
160 The second form is a pathname; if the pathname is prefixed by a forward slash
161 ('/'), then it is interpreted relative to the root of the filesystem
162 which is currently opened by
164 If not, the pathname is
165 interpreted relative to the current working directory as maintained by
167 This may be modified by using the
175 This is a list of the commands which
179 .BI blocks " filespace"
180 Print the blocks used by the inode
184 .BI bmap " [ -a ] filespec logical_block [physical_block]"
185 Print or set the physical block number corresponding to the logical block number
191 flag is specified, try to allocate a block if necessary.
193 .BI block_dump " [-f filespec] block_num"
194 Dump the filesystem block given by
196 in hex and ASCII format to the console. If the
198 option is specified, the block number is relative to the start of the given
202 Dump the contents of the inode
207 Change the current working directory to
210 .BI chroot " filespec"
211 Change the root directory to be the directory
215 Close the currently open file system. If the
217 option is specified, write out any changes to the superblock and block
218 group descriptors to all of the backup superblocks, not just to the
222 Clear the contents of the inode
225 .BI dirsearch " filespec filename"
232 Mark the filesystem as dirty, so that the superblocks will be written on exit.
234 .BI dump " [-p] filespec out_file"
235 Dump the contents of the inode
241 option is given set the owner, group and permissions information on
246 .BI dump_mmp " [mmp_block]"
247 Display the multiple-mount protection (mmp) field values. If
249 is specified then verify and dump the MMP values from the given block
250 number, otherwise use the
252 field in the superblock to locate and use the existing MMP block.
254 .BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
255 Calculate the directory hash of
257 The hash algorithm specified with
260 .BR legacy , " half_md4" ", or " tea .
261 The hash seed specified with
263 must be in UUID format.
265 .BI dump_extents " [-n] [-l] filespec"
266 Dump the the extent tree of the inode
272 to only display the interior nodes in the extent tree. The
276 to only display the leaf nodes in the extent tree.
278 (Please note that the length and range of blocks for the last extent in
279 an interior node is an estimate by the extents library functions, and is
280 not stored in filesystem data structures. Hence, the values displayed
281 may not necessarily by accurate and does not indicate a problem or
282 corruption in the file system.)
284 .BI ea_get " [-f outfile] filespec attr_name"
285 Retrieve the value of the extended attribute
289 and write it either to stdout or to \fIoutfile\fR.
291 .BI ea_list " filespec
292 List the extended attributes associated with the file
296 .BI ea_set " [-f infile] filespec attr_name attr_value
297 Set the value of the extended attribute
303 or read it from \fIinfile\fR.
305 .BI ea_rm " filespec attr_names...
306 Remove the extended attribute
308 from the file \fIfilespec\fR.
310 .BI expand_dir " filespec"
314 .BI fallocate " filespec start_block [end_block]
315 Allocate and map uninitialized blocks into \fIfilespec\fR between
316 logical block \fIstart_block\fR and \fIend_block\fR, inclusive. If
317 \fIend_block\fR is not supplied, this function maps until it runs out
318 of free disk blocks or the maximum file size is reached. Existing
319 mappings are left alone.
321 .BI feature " [fs_feature] [-fs_feature] ..."
322 Set or clear various filesystem features in the superblock. After setting
323 or clearing any filesystem features that were requested, print the current
324 state of the filesystem feature set.
326 .BI filefrag " [-dvr] filespec"
327 Print the number of contiguous extents in
331 is a directory and the
333 option is not specified,
335 will print the number of contiguous extents for each file in
340 print a tabular listing of the contiguous extents in the
345 to do a recursive listing of the directory.
347 .BI find_free_block " [count [goal]]"
350 free blocks, starting from
352 and allocate it. Also available as
355 .BI find_free_inode " [dir [mode]]"
356 Find a free inode and allocate it. If present,
358 specifies the inode number of the directory
359 which the inode is to be located. The second
362 specifies the permissions of the new inode. (If the directory bit is set
363 on the mode, the allocation routine will function differently.) Also
367 .BI freeb " block [count]"
368 Mark the block number
371 If the optional argument
375 blocks starting at block number
377 will be marked as not allocated.
379 .BI freefrag " [-c chunk_kb]"
380 Report free space fragmentation on the currently open file system.
383 option is specified then the filefrag command will print how many free
386 can be found in the file system. The chunk size must be a power of two
387 and be larger than the file system block size.
389 .BI freei " filespec [num]"
390 Free the inode specified by
394 is specified, also clear num-1 inodes after the specified inode.
397 Print a list of commands understood by
400 .BI htree_dump " filespec"
401 Dump the hash-indexed directory
403 showing its tree structure.
405 .BI icheck " block ..."
406 Print a listing of the inodes which use the one or more blocks specified
409 .BI inode_dump " filespec"
410 Print the contents of the inode data structure in hex and ASCII format.
413 Print the location of the inode data structure (in the inode table)
417 .BI init_filesys " device blocksize"
418 Create an ext2 file system on
422 Note that this does not fully initialize all of the data structures;
425 program. This is just a call to the low-level library, which sets up
426 the superblock and block descriptors.
429 Close the open journal.
431 .BI journal_open " [-c] [-v ver] [-j ext_jnl]
432 Opens the journal for reading and writing. Journal checksumming can
433 be enabled by supplying \fI-c\fR; checksum formats 2 and 3 can be
434 selected with the \fI-v\fR option. An external journal can be loaded
438 Replay all transactions in the open journal.
440 .BI journal_write " [-b blocks] [-r revoke] [-c] file
441 Write a transaction to the open journal. The list of blocks to write
442 should be supplied as a comma-separated list in \fIblocks\fR; the
443 blocks themselves should be readable from \fIfile\fR. A list of
444 blocks to revoke can be supplied as a comma-separated list in
445 \fIrevoke\fR. By default, a commit record is written at the end; the
446 \fI-c\fR switch writes an uncommitted transaction.
448 .BI kill_file " filespec"
451 and its blocks. Note that this does not remove any directory
452 entries (if any) to this inode. See the
454 command if you wish to unlink a file.
457 Change the current working directory of the
461 on the native filesystem.
463 .BI ln " filespec dest_file"
466 which is a hard link to
468 Note this does not adjust the inode reference counts.
470 .BI logdump " [-acsO] [-b block] [-i filespec] [-f journal_file] [output_file]"
471 Dump the contents of the ext3 journal. By default, dump the journal inode as
472 specified in the superblock. However, this can be overridden with the
474 option, which dumps the journal from the internal inode given by
476 A regular file containing journal data can be specified using the
480 option utilizes the backup information in the superblock to locate the
487 program to print the contents of all of the descriptor blocks.
492 to print all journal records that are refer to the specified block.
495 option will print out the contents of all of the data blocks selected by
504 option causes logdump to display old (checkpointed) journal entries.
505 This can be used to try to track down journal problems even after the
506 journal has been replayed.
508 .BI ls " [-l] [-c] [-d] [-p] [-r] filespec"
509 Print a listing of the files in the directory
513 flag causes directory block checksums (if present) to be displayed.
516 flag will list deleted entries in the directory.
519 flag will list files using a more verbose format.
522 flag will list the files in a format which is more easily parsable by
523 scripts, as well as making it more clear when there are spaces or other
524 non-printing characters at the end of filenames.
527 flag will force the printing of the filename, even if it is encrypted.
529 .BI list_deleted_inodes " [limit]"
530 List deleted inodes, optionally limited to those deleted within
532 seconds ago. Also available as
535 This command was useful for recovering from accidental file deletions
536 for ext2 file systems. Unfortunately, it is not useful for this purpose
537 if the files were deleted using ext3 or ext4, since the inode's
538 data blocks are no longer available after the inode is released.
540 .BI modify_inode " filespec"
541 Modify the contents of the inode structure in the inode
546 .BI mkdir " filespec"
549 .BI mknod " filespec [p|[[c|b] major minor]]"
550 Create a special device file (a named pipe, character or block device).
551 If a character or block device is to be made, the
555 device numbers must be specified.
557 .BI ncheck " [-c] inode_num ..."
558 Take the requested list of inode numbers, and print a listing of pathnames
561 flag will enable checking the file type information in the directory
562 entry to make sure it matches the inode's type.
564 .BI open " [-weficD] [-b blocksize] [-s superblock] [-z undo_file] device"
565 Open a filesystem for editing. The
567 flag forces the filesystem to be opened even if there are some unknown
568 or incompatible filesystem features which would normally
569 prevent the filesystem from being opened. The
571 flag causes the filesystem to be opened in exclusive mode. The
572 .IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
573 options behave the same as the command-line options to
576 .BI punch " filespec start_blk [end_blk]"
577 Delete the blocks in the inode ranging from
583 is omitted then this command will function as a truncate command; that
584 is, all of the blocks starting at
586 through to the end of the file will be deallocated.
588 .BI symlink " filespec target"
589 Make a symbolic link.
592 Print the current working directory.
598 .BI rdump " directory[...] destination"
603 and all its contents (including regular files, symbolic links, and other
604 directories) into the named
606 which should be an existing directory on the native filesystem.
611 If this causes the inode pointed to by
613 to have no other references, deallocate the file. This command functions
614 as the unlink() system call.
617 .BI rmdir " filespec"
621 .BI setb " block [count]"
622 Mark the block number
625 If the optional argument
629 blocks starting at block number
631 will be marked as allocated.
633 .BI set_block_group " bgnum field value"
634 Modify the block group descriptor specified by
636 so that the block group descriptor field
643 .BI seti " filespec [num]"
646 as in use in the inode bitmap. If
648 is specified, also set num-1 inodes after the specified inode.
650 .BI set_inode_field " filespec field value"
651 Modify the inode specified by
653 so that the inode field
657 The list of valid inode fields which can be set via this command
658 can be displayed by using the command:
659 .B set_inode_field -l
663 .BI set_mmp_value " field value"
664 Modify the multiple-mount protection (MMP) data so that the MMP field
668 The list of valid MMP fields which can be set via this command
669 can be displayed by using the command:
674 .BI set_super_value " field value"
675 Set the superblock field
679 The list of valid superblock fields which can be set via this command
680 can be displayed by using the command:
681 .B set_super_value -l
685 .BI show_super_stats " [-h]"
686 List the contents of the super block and the block group descriptors. If the
688 flag is given, only print out the superblock contents. Also available as
692 Display the contents of the inode structure of the inode
695 .BI testb " block [count]"
696 Test if the block number
698 is marked as allocated in the block bitmap.
699 If the optional argument
703 blocks starting at block number
707 .BI testi " filespec"
710 is marked as allocated in the inode bitmap.
712 .BI undel " <inode_number> [pathname]"
713 Undelete the specified inode number (which must be surrounded by angle
714 brackets) so that it and its blocks are marked in use, and optionally
715 link the recovered inode to the specified pathname. The
717 command should always be run after using the
719 command to recover deleted files.
721 Note that if you are recovering a large number of deleted files, linking
722 the inode to a directory may require the directory to be expanded, which
723 could allocate a block that had been used by one of the
724 yet-to-be-undeleted files. So it is safer to undelete all of the
725 inodes without specifying a destination pathname, and then in a separate
726 pass, use the debugfs
728 command to link the inode to the destination pathname, or use
730 to check the filesystem and link all of the recovered inodes to the
731 lost+found directory.
733 .BI unlink " pathname"
734 Remove the link specified by
736 to an inode. Note this does not adjust the inode reference counts.
738 .BI write " source_file out_file"
741 into a newly-created file in the filesystem named
744 .BI zap_block " [-f filespec] [-o offset] [-l length] [-p pattern] block_num"
745 Overwrite the block specified by
747 with zero (NUL) bytes, or if
749 is given use the byte specified by
755 is relative to the start of the file given by
761 options limit the range of bytes to zap to the specified
765 relative to the start of the block.
767 .BI zap_block " [-f filespec] [-b bit] block_num"
768 Bit-flip portions of the physical
774 is a logical block relative to the start of
776 .SH ENVIRONMENT VARIABLES
778 .B DEBUGFS_PAGER, PAGER
781 program always pipes the output of the some commands through a
782 pager program. These commands include:
783 .IR show_super_stats " (" stats ),
784 .IR list_directory " (" ls ),
785 .IR show_inode_info " (" stat ),
786 .IR list_deleted_inodes " (" lsdel ),
789 The specific pager can explicitly specified by the
791 environment variable, and if it is not set, by the
793 environment variable.
795 Note that since a pager is always used, the
797 pager is not particularly appropriate, since it clears the screen before
798 displaying the output of the command and clears the output the screen
799 when the pager is exited. Many users prefer to use the
801 pager for most purposes, which is why the
803 environment variable is available to override the more general
805 environment variable.
808 was written by Theodore Ts'o <tytso@mit.edu>.