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 Disables metadata checksum verification. This should only be used if
53 you believe the metadata to be correct despite the complaints of
57 Specifies that the file system should be opened in catastrophic mode, in
58 which the inode and group bitmaps are not read initially. This can be
59 useful for filesystems with significant corruption, but because of this,
60 catastrophic mode forces the filesystem to be opened read-only.
65 represents an ext2 image file created by the
67 program. Since the ext2 image file only contains the superblock, block
68 group descriptor, block and inode allocation bitmaps, and
71 commands will not function properly.
73 no safety checks are in place, and
75 may fail in interesting ways if commands such as
77 etc. are tried without specifying the
83 is a debugging tool. It has rough edges!
85 .I -d data_source_device
88 option, specifies that
90 should be used when reading blocks not found in the ext2 image file.
91 This includes data, directory, and indirect blocks.
94 Forces the use of the given block size for the file system, rather than
95 detecting the correct block size as normal.
98 Causes the file system superblock to be read from the given block
99 number, instead of using the primary superblock (located at an offset of
100 1024 bytes from the beginning of the filesystem). If you specify the
102 option, you must also provide the blocksize of the filesystem via the
109 to read in commands from
111 and execute them. When
113 is finished executing those commands, it will exit.
118 to open the device using Direct I/O, bypassing the buffer cache. Note
119 that some Linux devices, notably device mapper as of this writing, do
120 not support Direct I/O.
125 to execute the single command
130 print the version number of
138 as an argument to specify an inode (as opposed to a pathname)
139 in the filesystem which is currently opened by
143 argument may be specified in two forms. The first form is an inode
144 number surrounded by angle brackets, e.g.,
146 The second form is a pathname; if the pathname is prefixed by a forward slash
147 ('/'), then it is interpreted relative to the root of the filesystem
148 which is currently opened by
150 If not, the pathname is
151 interpreted relative to the current working directory as maintained by
153 This may be modified by using the
161 This is a list of the commands which
165 .BI blocks " filespace"
166 Print the blocks used by the inode
170 .BI bmap " [ -a ] filespec logical_block [physical_block]"
171 Print or set the physical block number corresponding to the logical block number
177 flag is specified, try to allocate a block if necessary.
179 .BI block_dump " [-f filespec] block_num"
180 Dump the filesystem block given by
182 in hex and ASCII format to the console. If the
184 option is specified, the block number is relative to the start of the given
188 Dump the contents of the inode
193 Change the current working directory to
196 .BI chroot " filespec"
197 Change the root directory to be the directory
201 Close the currently open file system. If the
203 option is specified, write out any changes to the superblock and block
204 group descriptors to all of the backup superblocks, not just to the
208 Clear the contents of the inode
211 .BI dirsearch " filespec filename"
218 Mark the filesystem as dirty, so that the superblocks will be written on exit.
220 .BI dump " [-p] filespec out_file"
221 Dump the contents of the inode
227 option is given set the owner, group and permissions information on
233 Display the multiple-mount protection (mmp) field values.
235 .BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
236 Calculate the directory hash of
238 The hash algorithm specified with
241 .BR legacy , " half_md4" ", or " tea .
242 The hash seed specified with
244 must be in UUID format.
246 .BI dump_extents " [-n] [-l] filespec"
247 Dump the the extent tree of the inode
253 to only display the interior nodes in the extent tree. The
257 to only display the leaf nodes in the extent tree.
259 (Please note that the length and range of blocks for the last extent in
260 an interior node is an estimate by the extents library functions, and is
261 not stored in filesystem data structures. Hence, the values displayed
262 may not necessarily by accurate and does not indicate a problem or
263 corruption in the file system.)
265 .BI ea_get " [-f outfile] filespec attr_name"
266 Retrieve the value of the extended attribute
270 and write it either to stdout or to \fIoutfile\fR.
272 .BI ea_list " filespec
273 List the extended attributes associated with the file
277 .BI ea_set " [-f infile] filespec attr_name attr_value
278 Set the value of the extended attribute
284 or read it from \fIinfile\fR.
286 .BI ea_rm " filespec attr_names...
287 Remove the extended attribute
289 from the file \fIfilespec\fR.
291 .BI expand_dir " filespec"
295 .BI feature " [fs_feature] [-fs_feature] ..."
296 Set or clear various filesystem features in the superblock. After setting
297 or clearing any filesystem features that were requested, print the current
298 state of the filesystem feature set.
300 .BI filefrag " [-dvr] filespec"
301 Print the number of contiguous extents in
305 is a directory and the
307 option is not specified,
309 will print the number of contiguous extents for each file in
314 print a tabular listing of the contiguous extents in the
319 to do a recursive listing of the directory.
321 .BI find_free_block " [count [goal]]"
324 free blocks, starting from
326 and allocate it. Also available as
329 .BI find_free_inode " [dir [mode]]"
330 Find a free inode and allocate it. If present,
332 specifies the inode number of the directory
333 which the inode is to be located. The second
336 specifies the permissions of the new inode. (If the directory bit is set
337 on the mode, the allocation routine will function differently.) Also
341 .BI freeb " block [count]"
342 Mark the block number
345 If the optional argument
349 blocks starting at block number
351 will be marked as not allocated.
353 .BI freefrag " [-c chunk_kb]"
354 Report free space fragmentation on the currently open file system.
357 option is specified then the filefrag command will print how many free
360 can be found in the file system. The chunk size must be a power of two
361 and be larger than the file system block size.
363 .BI freei " filespec [num]"
364 Free the inode specified by
368 is specified, also clear num-1 inodes after the specified inode.
371 Print a list of commands understood by
374 .BI htree_dump " filespec"
375 Dump the hash-indexed directory
377 showing its tree structure.
379 .BI icheck " block ..."
380 Print a listing of the inodes which use the one or more blocks specified
383 .BI inode_dump " filespec"
384 Print the contents of the inode data structure in hex and ASCII format.
387 Print the location of the inode data structure (in the inode table)
391 .BI init_filesys " device blocksize"
392 Create an ext2 file system on
396 Note that this does not fully initialize all of the data structures;
399 program. This is just a call to the low-level library, which sets up
400 the superblock and block descriptors.
403 Close the open journal.
405 .BI journal_open " [-c] [-v ver] [-j ext_jnl]
406 Opens the journal for reading and writing. Journal checksumming can
407 be enabled by supplying \fI-c\fR; checksum formats 2 and 3 can be
408 selected with the \fI-v\fR option. An external journal can be loaded
412 Replay all transactions in the open journal.
414 .BI journal_write " [-b blocks] [-r revoke] [-c] file
415 Write a transaction to the open journal. The list of blocks to write
416 should be supplied as a comma-separated list in \fIblocks\fR; the
417 blocks themselves should be readable from \fIfile\fR. A list of
418 blocks to revoke can be supplied as a comma-separated list in
419 \fIrevoke\fR. By default, a commit record is written at the end; the
420 \fI-c\fR switch writes an uncommitted transaction.
422 .BI kill_file " filespec"
425 and its blocks. Note that this does not remove any directory
426 entries (if any) to this inode. See the
428 command if you wish to unlink a file.
431 Change the current working directory of the
435 on the native filesystem.
437 .BI ln " filespec dest_file"
440 which is a hard link to
442 Note this does not adjust the inode reference counts.
444 .BI logdump " [-acsO] [-b block] [-i filespec] [-f journal_file] [output_file]"
445 Dump the contents of the ext3 journal. By default, dump the journal inode as
446 specified in the superblock. However, this can be overridden with the
448 option, which dumps the journal from the internal inode given by
450 A regular file containing journal data can be specified using the
454 option utilizes the backup information in the superblock to locate the
461 program to print the contents of all of the descriptor blocks.
466 to print all journal records that are refer to the specified block.
469 option will print out the contents of all of the data blocks selected by
478 option causes logdump to display old (checkpointed) journal entries.
479 This can be used to try to track down journal problems even after the
480 journal has been replayed.
482 .BI ls " [-l] [-c] [-d] [-p] filespec"
483 Print a listing of the files in the directory
487 flag causes directory block checksums (if present) to be displayed.
490 flag will list deleted entries in the directory.
493 flag will list files using a more verbose format.
496 flag will list the files in a format which is more easily parsable by
497 scripts, as well as making it more clear when there are spaces or other
498 non-printing characters at the end of filenames.
500 .BI list_deleted_inodes " [limit]"
501 List deleted inodes, optionally limited to those deleted within
503 seconds ago. Also available as
506 This command was useful for recovering from accidental file deletions
507 for ext2 file systems. Unfortunately, it is not useful for this purpose
508 if the files were deleted using ext3 or ext4, since the inode's
509 data blocks are no longer available after the inode is released.
511 .BI modify_inode " filespec"
512 Modify the contents of the inode structure in the inode
517 .BI mkdir " filespec"
520 .BI mknod " filespec [p|[[c|b] major minor]]"
521 Create a special device file (a named pipe, character or block device).
522 If a character or block device is to be made, the
526 device numbers must be specified.
528 .BI ncheck " [-c] inode_num ..."
529 Take the requested list of inode numbers, and print a listing of pathnames
532 flag will enable checking the file type information in the directory
533 entry to make sure it matches the inode's type.
535 .BI open " [-weficD] [-b blocksize] [-s superblock] device"
536 Open a filesystem for editing. The
538 flag forces the filesystem to be opened even if there are some unknown
539 or incompatible filesystem features which would normally
540 prevent the filesystem from being opened. The
542 flag causes the filesystem to be opened in exclusive mode. The
543 .IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
544 options behave the same as the command-line options to
547 .BI punch " filespec start_blk [end_blk]"
548 Delete the blocks in the inode ranging from
554 is omitted then this command will function as a truncate command; that
555 is, all of the blocks starting at
557 through to the end of the file will be deallocated.
559 .BI symlink " filespec target"
560 Make a symbolic link.
563 Print the current working directory.
569 .BI rdump " directory[...] destination"
574 and all its contents (including regular files, symbolic links, and other
575 directories) into the named
577 which should be an existing directory on the native filesystem.
582 If this causes the inode pointed to by
584 to have no other references, deallocate the file. This command functions
585 as the unlink() system call.
588 .BI rmdir " filespec"
592 .BI setb " block [count]"
593 Mark the block number
596 If the optional argument
600 blocks starting at block number
602 will be marked as allocated.
604 .BI set_block_group " bgnum field value"
605 Modify the block group descriptor specified by
607 so that the block group descriptor field
614 .BI seti " filespec [num]"
617 as in use in the inode bitmap. If
619 is specified, also set num-1 inodes after the specified inode.
621 .BI set_inode_field " filespec field value"
622 Modify the inode specified by
624 so that the inode field
628 The list of valid inode fields which can be set via this command
629 can be displayed by using the command:
630 .B set_inode_field -l
634 .BI set_mmp_value " field value"
635 Modify the multiple-mount protection (MMP) data so that the MMP field
639 The list of valid MMP fields which can be set via this command
640 can be displayed by using the command:
645 .BI set_super_value " field value"
646 Set the superblock field
650 The list of valid superblock fields which can be set via this command
651 can be displayed by using the command:
652 .B set_super_value -l
656 .BI show_super_stats " [-h]"
657 List the contents of the super block and the block group descriptors. If the
659 flag is given, only print out the superblock contents. Also available as
663 Display the contents of the inode structure of the inode
666 .BI testb " block [count]"
667 Test if the block number
669 is marked as allocated in the block bitmap.
670 If the optional argument
674 blocks starting at block number
678 .BI testi " filespec"
681 is marked as allocated in the inode bitmap.
683 .BI undel " <inode_number> [pathname]"
684 Undelete the specified inode number (which must be surrounded by angle
685 brackets) so that it and its blocks are marked in use, and optionally
686 link the recovered inode to the specified pathname. The
688 command should always be run after using the
690 command to recover deleted files.
692 Note that if you are recovering a large number of deleted files, linking
693 the inode to a directory may require the directory to be expanded, which
694 could allocate a block that had been used by one of the
695 yet-to-be-undeleted files. So it is safer to undelete all of the
696 inodes without specifying a destination pathname, and then in a separate
697 pass, use the debugfs
699 command to link the inode to the destination pathname, or use
701 to check the filesystem and link all of the recovered inodes to the
702 lost+found directory.
704 .BI unlink " pathname"
705 Remove the link specified by
707 to an inode. Note this does not adjust the inode reference counts.
709 .BI write " source_file out_file"
712 into a newly-created file in the filesystem named
715 .BI zap_block " [-f filespec] [-o offset] [-l length] [-p pattern] block_num"
716 Overwrite the block specified by
718 with zero (NUL) bytes, or if
720 is given use the byte specified by
726 is relative to the start of the file given by
732 options limit the range of bytes to zap to the specified
736 relative to the start of the block.
738 .BI zap_block " [-f filespec] [-b bit] block_num"
739 Bit-flip portions of the physical
745 is a logical block relative to the start of
747 .SH ENVIRONMENT VARIABLES
749 .B DEBUGFS_PAGER, PAGER
752 program always pipes the output of the some commands through a
753 pager program. These commands include:
754 .IR show_super_stats " (" stats ),
755 .IR list_directory " (" ls ),
756 .IR show_inode_info " (" stat ),
757 .IR list_deleted_inodes " (" lsdel ),
760 The specific pager can explicitly specified by the
762 environment variable, and if it is not set, by the
764 environment variable.
766 Note that since a pager is always used, the
768 pager is not particularly appropriate, since it clears the screen before
769 displaying the output of the command and clears the output the screen
770 when the pager is exited. Many users prefer to use the
772 pager for most purposes, which is why the
774 environment variable is available to override the more general
776 environment variable.
779 was written by Theodore Ts'o <tytso@mit.edu>.