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 for the file system, rather than
98 detecting the correct block size as normal.
101 Causes the file system superblock to be read from the given block
102 number, instead of using the primary superblock (located at an offset of
103 1024 bytes from the beginning of the filesystem). If you specify the
105 option, you must also provide the blocksize of the filesystem via the
112 to read in commands from
114 and execute them. When
116 is finished executing those commands, it will exit.
121 to open the device using Direct I/O, bypassing the buffer cache. Note
122 that some Linux devices, notably device mapper as of this writing, do
123 not support Direct I/O.
128 to execute the single command
133 print the version number of
138 Before overwriting a file system block, write the old contents of the block to
139 an undo file. This undo file can be used with e2undo(8) to restore the old
140 contents of the file system should something go wrong. If the empty string is
141 passed as the undo_file argument, the undo file will be written to a file named
142 resize2fs-\fIdevice\fR.e2undo in the directory specified via the
143 \fIE2FSPROGS_UNDO_DIR\fR environment variable.
145 WARNING: The undo file cannot be used to recover from a power or system crash.
151 as an argument to specify an inode (as opposed to a pathname)
152 in the filesystem which is currently opened by
156 argument may be specified in two forms. The first form is an inode
157 number surrounded by angle brackets, e.g.,
159 The second form is a pathname; if the pathname is prefixed by a forward slash
160 ('/'), then it is interpreted relative to the root of the filesystem
161 which is currently opened by
163 If not, the pathname is
164 interpreted relative to the current working directory as maintained by
166 This may be modified by using the
174 This is a list of the commands which
178 .BI blocks " filespace"
179 Print the blocks used by the inode
183 .BI bmap " [ -a ] filespec logical_block [physical_block]"
184 Print or set the physical block number corresponding to the logical block number
190 flag is specified, try to allocate a block if necessary.
192 .BI block_dump " [-f filespec] block_num"
193 Dump the filesystem block given by
195 in hex and ASCII format to the console. If the
197 option is specified, the block number is relative to the start of the given
201 Dump the contents of the inode
206 Change the current working directory to
209 .BI chroot " filespec"
210 Change the root directory to be the directory
214 Close the currently open file system. If the
216 option is specified, write out any changes to the superblock and block
217 group descriptors to all of the backup superblocks, not just to the
221 Clear the contents of the inode
224 .BI dirsearch " filespec filename"
231 Mark the filesystem as dirty, so that the superblocks will be written on exit.
233 .BI dump " [-p] filespec out_file"
234 Dump the contents of the inode
240 option is given set the owner, group and permissions information on
245 .BI dump_mmp " [mmp_block]"
246 Display the multiple-mount protection (mmp) field values. If
248 is specified then verify and dump the MMP values from the given block
249 number, otherwise use the
251 field in the superblock to locate and use the existing MMP block.
253 .BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
254 Calculate the directory hash of
256 The hash algorithm specified with
259 .BR legacy , " half_md4" ", or " tea .
260 The hash seed specified with
262 must be in UUID format.
264 .BI dump_extents " [-n] [-l] filespec"
265 Dump the the extent tree of the inode
271 to only display the interior nodes in the extent tree. The
275 to only display the leaf nodes in the extent tree.
277 (Please note that the length and range of blocks for the last extent in
278 an interior node is an estimate by the extents library functions, and is
279 not stored in filesystem data structures. Hence, the values displayed
280 may not necessarily by accurate and does not indicate a problem or
281 corruption in the file system.)
283 .BI ea_get " [-f outfile] filespec attr_name"
284 Retrieve the value of the extended attribute
288 and write it either to stdout or to \fIoutfile\fR.
290 .BI ea_list " filespec
291 List the extended attributes associated with the file
295 .BI ea_set " [-f infile] filespec attr_name attr_value
296 Set the value of the extended attribute
302 or read it from \fIinfile\fR.
304 .BI ea_rm " filespec attr_names...
305 Remove the extended attribute
307 from the file \fIfilespec\fR.
309 .BI expand_dir " filespec"
313 .BI fallocate " filespec start_block [end_block]
314 Allocate and map uninitialized blocks into \fIfilespec\fR between
315 logical block \fIstart_block\fR and \fIend_block\fR, inclusive. If
316 \fIend_block\fR is not supplied, this function maps until it runs out
317 of free disk blocks or the maximum file size is reached. Existing
318 mappings are left alone.
320 .BI feature " [fs_feature] [-fs_feature] ..."
321 Set or clear various filesystem features in the superblock. After setting
322 or clearing any filesystem features that were requested, print the current
323 state of the filesystem feature set.
325 .BI filefrag " [-dvr] filespec"
326 Print the number of contiguous extents in
330 is a directory and the
332 option is not specified,
334 will print the number of contiguous extents for each file in
339 print a tabular listing of the contiguous extents in the
344 to do a recursive listing of the directory.
346 .BI find_free_block " [count [goal]]"
349 free blocks, starting from
351 and allocate it. Also available as
354 .BI find_free_inode " [dir [mode]]"
355 Find a free inode and allocate it. If present,
357 specifies the inode number of the directory
358 which the inode is to be located. The second
361 specifies the permissions of the new inode. (If the directory bit is set
362 on the mode, the allocation routine will function differently.) Also
366 .BI freeb " block [count]"
367 Mark the block number
370 If the optional argument
374 blocks starting at block number
376 will be marked as not allocated.
378 .BI freefrag " [-c chunk_kb]"
379 Report free space fragmentation on the currently open file system.
382 option is specified then the filefrag command will print how many free
385 can be found in the file system. The chunk size must be a power of two
386 and be larger than the file system block size.
388 .BI freei " filespec [num]"
389 Free the inode specified by
393 is specified, also clear num-1 inodes after the specified inode.
396 Print a list of commands understood by
399 .BI htree_dump " filespec"
400 Dump the hash-indexed directory
402 showing its tree structure.
404 .BI icheck " block ..."
405 Print a listing of the inodes which use the one or more blocks specified
408 .BI inode_dump " filespec"
409 Print the contents of the inode data structure in hex and ASCII format.
412 Print the location of the inode data structure (in the inode table)
416 .BI init_filesys " device blocksize"
417 Create an ext2 file system on
421 Note that this does not fully initialize all of the data structures;
424 program. This is just a call to the low-level library, which sets up
425 the superblock and block descriptors.
428 Close the open journal.
430 .BI journal_open " [-c] [-v ver] [-j ext_jnl]
431 Opens the journal for reading and writing. Journal checksumming can
432 be enabled by supplying \fI-c\fR; checksum formats 2 and 3 can be
433 selected with the \fI-v\fR option. An external journal can be loaded
437 Replay all transactions in the open journal.
439 .BI journal_write " [-b blocks] [-r revoke] [-c] file
440 Write a transaction to the open journal. The list of blocks to write
441 should be supplied as a comma-separated list in \fIblocks\fR; the
442 blocks themselves should be readable from \fIfile\fR. A list of
443 blocks to revoke can be supplied as a comma-separated list in
444 \fIrevoke\fR. By default, a commit record is written at the end; the
445 \fI-c\fR switch writes an uncommitted transaction.
447 .BI kill_file " filespec"
450 and its blocks. Note that this does not remove any directory
451 entries (if any) to this inode. See the
453 command if you wish to unlink a file.
456 Change the current working directory of the
460 on the native filesystem.
462 .BI ln " filespec dest_file"
465 which is a hard link to
467 Note this does not adjust the inode reference counts.
469 .BI logdump " [-acsO] [-b block] [-i filespec] [-f journal_file] [output_file]"
470 Dump the contents of the ext3 journal. By default, dump the journal inode as
471 specified in the superblock. However, this can be overridden with the
473 option, which dumps the journal from the internal inode given by
475 A regular file containing journal data can be specified using the
479 option utilizes the backup information in the superblock to locate the
486 program to print the contents of all of the descriptor blocks.
491 to print all journal records that are refer to the specified block.
494 option will print out the contents of all of the data blocks selected by
503 option causes logdump to display old (checkpointed) journal entries.
504 This can be used to try to track down journal problems even after the
505 journal has been replayed.
507 .BI ls " [-l] [-c] [-d] [-p] [-r] filespec"
508 Print a listing of the files in the directory
512 flag causes directory block checksums (if present) to be displayed.
515 flag will list deleted entries in the directory.
518 flag will list files using a more verbose format.
521 flag will list the files in a format which is more easily parsable by
522 scripts, as well as making it more clear when there are spaces or other
523 non-printing characters at the end of filenames.
526 flag will force the printing of the filename, even if it is encrypted.
528 .BI list_deleted_inodes " [limit]"
529 List deleted inodes, optionally limited to those deleted within
531 seconds ago. Also available as
534 This command was useful for recovering from accidental file deletions
535 for ext2 file systems. Unfortunately, it is not useful for this purpose
536 if the files were deleted using ext3 or ext4, since the inode's
537 data blocks are no longer available after the inode is released.
539 .BI modify_inode " filespec"
540 Modify the contents of the inode structure in the inode
545 .BI mkdir " filespec"
548 .BI mknod " filespec [p|[[c|b] major minor]]"
549 Create a special device file (a named pipe, character or block device).
550 If a character or block device is to be made, the
554 device numbers must be specified.
556 .BI ncheck " [-c] inode_num ..."
557 Take the requested list of inode numbers, and print a listing of pathnames
560 flag will enable checking the file type information in the directory
561 entry to make sure it matches the inode's type.
563 .BI open " [-weficD] [-b blocksize] [-s superblock] [-z undo_file] device"
564 Open a filesystem for editing. The
566 flag forces the filesystem to be opened even if there are some unknown
567 or incompatible filesystem features which would normally
568 prevent the filesystem from being opened. The
570 flag causes the filesystem to be opened in exclusive mode. The
571 .IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
572 options behave the same as the command-line options to
575 .BI punch " filespec start_blk [end_blk]"
576 Delete the blocks in the inode ranging from
582 is omitted then this command will function as a truncate command; that
583 is, all of the blocks starting at
585 through to the end of the file will be deallocated.
587 .BI symlink " filespec target"
588 Make a symbolic link.
591 Print the current working directory.
597 .BI rdump " directory[...] destination"
602 and all its contents (including regular files, symbolic links, and other
603 directories) into the named
605 which should be an existing directory on the native filesystem.
610 If this causes the inode pointed to by
612 to have no other references, deallocate the file. This command functions
613 as the unlink() system call.
616 .BI rmdir " filespec"
620 .BI setb " block [count]"
621 Mark the block number
624 If the optional argument
628 blocks starting at block number
630 will be marked as allocated.
632 .BI set_block_group " bgnum field value"
633 Modify the block group descriptor specified by
635 so that the block group descriptor field
642 .BI seti " filespec [num]"
645 as in use in the inode bitmap. If
647 is specified, also set num-1 inodes after the specified inode.
649 .BI set_inode_field " filespec field value"
650 Modify the inode specified by
652 so that the inode field
656 The list of valid inode fields which can be set via this command
657 can be displayed by using the command:
658 .B set_inode_field -l
662 .BI set_mmp_value " field value"
663 Modify the multiple-mount protection (MMP) data so that the MMP field
667 The list of valid MMP fields which can be set via this command
668 can be displayed by using the command:
673 .BI set_super_value " field value"
674 Set the superblock field
678 The list of valid superblock fields which can be set via this command
679 can be displayed by using the command:
680 .B set_super_value -l
684 .BI show_super_stats " [-h]"
685 List the contents of the super block and the block group descriptors. If the
687 flag is given, only print out the superblock contents. Also available as
691 Display the contents of the inode structure of the inode
694 .BI testb " block [count]"
695 Test if the block number
697 is marked as allocated in the block bitmap.
698 If the optional argument
702 blocks starting at block number
706 .BI testi " filespec"
709 is marked as allocated in the inode bitmap.
711 .BI undel " <inode_number> [pathname]"
712 Undelete the specified inode number (which must be surrounded by angle
713 brackets) so that it and its blocks are marked in use, and optionally
714 link the recovered inode to the specified pathname. The
716 command should always be run after using the
718 command to recover deleted files.
720 Note that if you are recovering a large number of deleted files, linking
721 the inode to a directory may require the directory to be expanded, which
722 could allocate a block that had been used by one of the
723 yet-to-be-undeleted files. So it is safer to undelete all of the
724 inodes without specifying a destination pathname, and then in a separate
725 pass, use the debugfs
727 command to link the inode to the destination pathname, or use
729 to check the filesystem and link all of the recovered inodes to the
730 lost+found directory.
732 .BI unlink " pathname"
733 Remove the link specified by
735 to an inode. Note this does not adjust the inode reference counts.
737 .BI write " source_file out_file"
740 into a newly-created file in the filesystem named
743 .BI zap_block " [-f filespec] [-o offset] [-l length] [-p pattern] block_num"
744 Overwrite the block specified by
746 with zero (NUL) bytes, or if
748 is given use the byte specified by
754 is relative to the start of the file given by
760 options limit the range of bytes to zap to the specified
764 relative to the start of the block.
766 .BI zap_block " [-f filespec] [-b bit] block_num"
767 Bit-flip portions of the physical
773 is a logical block relative to the start of
775 .SH ENVIRONMENT VARIABLES
777 .B DEBUGFS_PAGER, PAGER
780 program always pipes the output of the some commands through a
781 pager program. These commands include:
782 .IR show_super_stats " (" stats ),
783 .IR list_directory " (" ls ),
784 .IR show_inode_info " (" stat ),
785 .IR list_deleted_inodes " (" lsdel ),
788 The specific pager can explicitly specified by the
790 environment variable, and if it is not set, by the
792 environment variable.
794 Note that since a pager is always used, the
796 pager is not particularly appropriate, since it clears the screen before
797 displaying the output of the command and clears the output the screen
798 when the pager is exited. Many users prefer to use the
800 pager for most purposes, which is why the
802 environment variable is available to override the more general
804 environment variable.
807 was written by Theodore Ts'o <tytso@mit.edu>.