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
247 Display the multiple-mount protection (mmp) field values.
249 .BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
250 Calculate the directory hash of
252 The hash algorithm specified with
255 .BR legacy , " half_md4" ", or " tea .
256 The hash seed specified with
258 must be in UUID format.
260 .BI dump_extents " [-n] [-l] filespec"
261 Dump the the extent tree of the inode
267 to only display the interior nodes in the extent tree. The
271 to only display the leaf nodes in the extent tree.
273 (Please note that the length and range of blocks for the last extent in
274 an interior node is an estimate by the extents library functions, and is
275 not stored in filesystem data structures. Hence, the values displayed
276 may not necessarily by accurate and does not indicate a problem or
277 corruption in the file system.)
279 .BI ea_get " [-f outfile] filespec attr_name"
280 Retrieve the value of the extended attribute
284 and write it either to stdout or to \fIoutfile\fR.
286 .BI ea_list " filespec
287 List the extended attributes associated with the file
291 .BI ea_set " [-f infile] filespec attr_name attr_value
292 Set the value of the extended attribute
298 or read it from \fIinfile\fR.
300 .BI ea_rm " filespec attr_names...
301 Remove the extended attribute
303 from the file \fIfilespec\fR.
305 .BI expand_dir " filespec"
309 .BI fallocate " filespec start_block [end_block]
310 Allocate and map uninitialized blocks into \fIfilespec\fR between
311 logical block \fIstart_block\fR and \fIend_block\fR, inclusive. If
312 \fIend_block\fR is not supplied, this function maps until it runs out
313 of free disk blocks or the maximum file size is reached. Existing
314 mappings are left alone.
316 .BI feature " [fs_feature] [-fs_feature] ..."
317 Set or clear various filesystem features in the superblock. After setting
318 or clearing any filesystem features that were requested, print the current
319 state of the filesystem feature set.
321 .BI filefrag " [-dvr] filespec"
322 Print the number of contiguous extents in
326 is a directory and the
328 option is not specified,
330 will print the number of contiguous extents for each file in
335 print a tabular listing of the contiguous extents in the
340 to do a recursive listing of the directory.
342 .BI find_free_block " [count [goal]]"
345 free blocks, starting from
347 and allocate it. Also available as
350 .BI find_free_inode " [dir [mode]]"
351 Find a free inode and allocate it. If present,
353 specifies the inode number of the directory
354 which the inode is to be located. The second
357 specifies the permissions of the new inode. (If the directory bit is set
358 on the mode, the allocation routine will function differently.) Also
362 .BI freeb " block [count]"
363 Mark the block number
366 If the optional argument
370 blocks starting at block number
372 will be marked as not allocated.
374 .BI freefrag " [-c chunk_kb]"
375 Report free space fragmentation on the currently open file system.
378 option is specified then the filefrag command will print how many free
381 can be found in the file system. The chunk size must be a power of two
382 and be larger than the file system block size.
384 .BI freei " filespec [num]"
385 Free the inode specified by
389 is specified, also clear num-1 inodes after the specified inode.
392 Print a list of commands understood by
395 .BI htree_dump " filespec"
396 Dump the hash-indexed directory
398 showing its tree structure.
400 .BI icheck " block ..."
401 Print a listing of the inodes which use the one or more blocks specified
404 .BI inode_dump " filespec"
405 Print the contents of the inode data structure in hex and ASCII format.
408 Print the location of the inode data structure (in the inode table)
412 .BI init_filesys " device blocksize"
413 Create an ext2 file system on
417 Note that this does not fully initialize all of the data structures;
420 program. This is just a call to the low-level library, which sets up
421 the superblock and block descriptors.
424 Close the open journal.
426 .BI journal_open " [-c] [-v ver] [-j ext_jnl]
427 Opens the journal for reading and writing. Journal checksumming can
428 be enabled by supplying \fI-c\fR; checksum formats 2 and 3 can be
429 selected with the \fI-v\fR option. An external journal can be loaded
433 Replay all transactions in the open journal.
435 .BI journal_write " [-b blocks] [-r revoke] [-c] file
436 Write a transaction to the open journal. The list of blocks to write
437 should be supplied as a comma-separated list in \fIblocks\fR; the
438 blocks themselves should be readable from \fIfile\fR. A list of
439 blocks to revoke can be supplied as a comma-separated list in
440 \fIrevoke\fR. By default, a commit record is written at the end; the
441 \fI-c\fR switch writes an uncommitted transaction.
443 .BI kill_file " filespec"
446 and its blocks. Note that this does not remove any directory
447 entries (if any) to this inode. See the
449 command if you wish to unlink a file.
452 Change the current working directory of the
456 on the native filesystem.
458 .BI ln " filespec dest_file"
461 which is a hard link to
463 Note this does not adjust the inode reference counts.
465 .BI logdump " [-acsO] [-b block] [-i filespec] [-f journal_file] [output_file]"
466 Dump the contents of the ext3 journal. By default, dump the journal inode as
467 specified in the superblock. However, this can be overridden with the
469 option, which dumps the journal from the internal inode given by
471 A regular file containing journal data can be specified using the
475 option utilizes the backup information in the superblock to locate the
482 program to print the contents of all of the descriptor blocks.
487 to print all journal records that are refer to the specified block.
490 option will print out the contents of all of the data blocks selected by
499 option causes logdump to display old (checkpointed) journal entries.
500 This can be used to try to track down journal problems even after the
501 journal has been replayed.
503 .BI ls " [-l] [-c] [-d] [-p] [-r] filespec"
504 Print a listing of the files in the directory
508 flag causes directory block checksums (if present) to be displayed.
511 flag will list deleted entries in the directory.
514 flag will list files using a more verbose format.
517 flag will list the files in a format which is more easily parsable by
518 scripts, as well as making it more clear when there are spaces or other
519 non-printing characters at the end of filenames.
522 flag will force the printing of the filename, even if it is encrypted.
524 .BI list_deleted_inodes " [limit]"
525 List deleted inodes, optionally limited to those deleted within
527 seconds ago. Also available as
530 This command was useful for recovering from accidental file deletions
531 for ext2 file systems. Unfortunately, it is not useful for this purpose
532 if the files were deleted using ext3 or ext4, since the inode's
533 data blocks are no longer available after the inode is released.
535 .BI modify_inode " filespec"
536 Modify the contents of the inode structure in the inode
541 .BI mkdir " filespec"
544 .BI mknod " filespec [p|[[c|b] major minor]]"
545 Create a special device file (a named pipe, character or block device).
546 If a character or block device is to be made, the
550 device numbers must be specified.
552 .BI ncheck " [-c] inode_num ..."
553 Take the requested list of inode numbers, and print a listing of pathnames
556 flag will enable checking the file type information in the directory
557 entry to make sure it matches the inode's type.
559 .BI open " [-weficD] [-b blocksize] [-s superblock] [-z undo_file] device"
560 Open a filesystem for editing. The
562 flag forces the filesystem to be opened even if there are some unknown
563 or incompatible filesystem features which would normally
564 prevent the filesystem from being opened. The
566 flag causes the filesystem to be opened in exclusive mode. The
567 .IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
568 options behave the same as the command-line options to
571 .BI punch " filespec start_blk [end_blk]"
572 Delete the blocks in the inode ranging from
578 is omitted then this command will function as a truncate command; that
579 is, all of the blocks starting at
581 through to the end of the file will be deallocated.
583 .BI symlink " filespec target"
584 Make a symbolic link.
587 Print the current working directory.
593 .BI rdump " directory[...] destination"
598 and all its contents (including regular files, symbolic links, and other
599 directories) into the named
601 which should be an existing directory on the native filesystem.
606 If this causes the inode pointed to by
608 to have no other references, deallocate the file. This command functions
609 as the unlink() system call.
612 .BI rmdir " filespec"
616 .BI setb " block [count]"
617 Mark the block number
620 If the optional argument
624 blocks starting at block number
626 will be marked as allocated.
628 .BI set_block_group " bgnum field value"
629 Modify the block group descriptor specified by
631 so that the block group descriptor field
638 .BI seti " filespec [num]"
641 as in use in the inode bitmap. If
643 is specified, also set num-1 inodes after the specified inode.
645 .BI set_inode_field " filespec field value"
646 Modify the inode specified by
648 so that the inode field
652 The list of valid inode fields which can be set via this command
653 can be displayed by using the command:
654 .B set_inode_field -l
658 .BI set_mmp_value " field value"
659 Modify the multiple-mount protection (MMP) data so that the MMP field
663 The list of valid MMP fields which can be set via this command
664 can be displayed by using the command:
669 .BI set_super_value " field value"
670 Set the superblock field
674 The list of valid superblock fields which can be set via this command
675 can be displayed by using the command:
676 .B set_super_value -l
680 .BI show_super_stats " [-h]"
681 List the contents of the super block and the block group descriptors. If the
683 flag is given, only print out the superblock contents. Also available as
687 Display the contents of the inode structure of the inode
690 .BI testb " block [count]"
691 Test if the block number
693 is marked as allocated in the block bitmap.
694 If the optional argument
698 blocks starting at block number
702 .BI testi " filespec"
705 is marked as allocated in the inode bitmap.
707 .BI undel " <inode_number> [pathname]"
708 Undelete the specified inode number (which must be surrounded by angle
709 brackets) so that it and its blocks are marked in use, and optionally
710 link the recovered inode to the specified pathname. The
712 command should always be run after using the
714 command to recover deleted files.
716 Note that if you are recovering a large number of deleted files, linking
717 the inode to a directory may require the directory to be expanded, which
718 could allocate a block that had been used by one of the
719 yet-to-be-undeleted files. So it is safer to undelete all of the
720 inodes without specifying a destination pathname, and then in a separate
721 pass, use the debugfs
723 command to link the inode to the destination pathname, or use
725 to check the filesystem and link all of the recovered inodes to the
726 lost+found directory.
728 .BI unlink " pathname"
729 Remove the link specified by
731 to an inode. Note this does not adjust the inode reference counts.
733 .BI write " source_file out_file"
736 into a newly-created file in the filesystem named
739 .BI zap_block " [-f filespec] [-o offset] [-l length] [-p pattern] block_num"
740 Overwrite the block specified by
742 with zero (NUL) bytes, or if
744 is given use the byte specified by
750 is relative to the start of the file given by
756 options limit the range of bytes to zap to the specified
760 relative to the start of the block.
762 .BI zap_block " [-f filespec] [-b bit] block_num"
763 Bit-flip portions of the physical
769 is a logical block relative to the start of
771 .SH ENVIRONMENT VARIABLES
773 .B DEBUGFS_PAGER, PAGER
776 program always pipes the output of the some commands through a
777 pager program. These commands include:
778 .IR show_super_stats " (" stats ),
779 .IR list_directory " (" ls ),
780 .IR show_inode_info " (" stat ),
781 .IR list_deleted_inodes " (" lsdel ),
784 The specific pager can explicitly specified by the
786 environment variable, and if it is not set, by the
788 environment variable.
790 Note that since a pager is always used, the
792 pager is not particularly appropriate, since it clears the screen before
793 displaying the output of the command and clears the output the screen
794 when the pager is exited. Many users prefer to use the
796 pager for most purposes, which is why the
798 environment variable is available to override the more general
800 environment variable.
803 was written by Theodore Ts'o <tytso@mit.edu>.