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 Specifies that the file system should be opened in catastrophic mode, in
53 which the inode and group bitmaps are not read initially. This can be
54 useful for filesystems with significant corruption, but because of this,
55 catastrophic mode forces the filesystem to be opened read-only.
60 represents an ext2 image file created by the
62 program. Since the ext2 image file only contains the superblock, block
63 group descriptor, block and inode allocation bitmaps, and
66 commands will not function properly.
68 no safety checks are in place, and
70 may fail in interesting ways if commands such as
72 etc. are tried without specifying the
78 is a debugging tool. It has rough edges!
80 .I -d data_source_device
83 option, specifies that
85 should be used when reading blocks not found in the ext2 image file.
86 This includes data, directory, and indirect blocks.
89 Forces the use of the given block size for the file system, rather than
90 detecting the correct block size as normal.
93 Causes the file system superblock to be read from the given block
94 number, instead of using the primary superblock (located at an offset of
95 1024 bytes from the beginning of the filesystem). If you specify the
97 option, you must also provide the blocksize of the filesystem via the
104 to read in commands from
106 and execute them. When
108 is finished executing those commands, it will exit.
113 to open the device using Direct I/O, bypassing the buffer cache. Note
114 that some Linux devices, notably device mapper as of this writing, do
115 not support Direct I/O.
120 to execute the single command
125 print the version number of
133 as an argument to specify an inode (as opposed to a pathname)
134 in the filesystem which is currently opened by
138 argument may be specified in two forms. The first form is an inode
139 number surrounded by angle brackets, e.g.,
141 The second form is a pathname; if the pathname is prefixed by a forward slash
142 ('/'), then it is interpreted relative to the root of the filesystem
143 which is currently opened by
145 If not, the pathname is
146 interpreted relative to the current working directory as maintained by
148 This may be modified by using the
156 This is a list of the commands which
160 .BI blocks " filespace"
161 Print the blocks used by the inode
165 .BI bmap " filespec logical_block"
166 Print the physical block number corresponding to the logical block number
171 .BI block_dump " [-f filespec] block_num"
172 Dump the filesystem block given by
174 in hex and ASCII format to the console. If the
176 option is specified, the block number is relative to the start of the given
180 Dump the contents of the inode
185 Change the current working directory to
188 .BI chroot " filespec"
189 Change the root directory to be the directory
193 Close the currently open file system. If the
195 option is specified, write out any changes to the superblock and block
196 group descriptors to all of the backup superblocks, not just to the
200 Clear the contents of the inode
203 .BI dirsearch " filespec filename"
210 Mark the filesystem as dirty, so that the superblocks will be written on exit.
212 .BI dump " [-p] filespec out_file"
213 Dump the contents of the inode
219 option is given set the owner, group and permissions information on
224 .BI dump_mmp " [mmp_block]"
225 Display the multiple-mount protection (mmp) field values. If
227 is specified then verify and dump the MMP values from the given block
228 number, otherwise use the
230 field in the superblock to locate and use the existing MMP block.
232 .BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
233 Calculate the directory hash of
235 The hash algorithm specified with
238 .BR legacy , " half_md4" ", or " tea .
239 The hash seed specified with
241 must be in UUID format.
243 .BI dump_extents " [-n] [-l] filespec"
244 Dump the the extent tree of the inode
250 to only display the interior nodes in the extent tree. The
254 to only display the leaf nodes in the extent tree.
256 (Please note that the length and range of blocks for the last extent in
257 an interior node is an estimate by the extents library functions, and is
258 not stored in filesystem data structures. Hence, the values displayed
259 may not necessarily by accurate and does not indicate a problem or
260 corruption in the file system.)
262 .BI expand_dir " filespec"
266 .BI feature " [fs_feature] [-fs_feature] ..."
267 Set or clear various filesystem features in the superblock. After setting
268 or clearing any filesystem features that were requested, print the current
269 state of the filesystem feature set.
271 .BI filefrag " [-dvr] filespec"
272 Print the number of contiguous extents in
276 is a directory and the
278 option is not specified,
280 will print the number of contiguous extents for each file in
285 print a tabular listing of the contiguous extents in the
290 to do a recursive listing of the directory.
292 .BI find_free_block " [count [goal]]"
295 free blocks, starting from
297 and allocate it. Also available as
300 .BI find_free_inode " [dir [mode]]"
301 Find a free inode and allocate it. If present,
303 specifies the inode number of the directory
304 which the inode is to be located. The second
307 specifies the permissions of the new inode. (If the directory bit is set
308 on the mode, the allocation routine will function differently.) Also
312 .BI freeb " block [count]"
313 Mark the block number
316 If the optional argument
320 blocks starting at block number
322 will be marked as not allocated.
324 .BI freefrag " [-c chunk_kb]"
325 Report free space fragmentation on the currently open file system.
328 option is specified then the filefrag command will print how many free
331 can be found in the file system. The chunk size must be a power of two
332 and be larger than the file system block size.
334 .BI freei " filespec [num]"
335 Free the inode specified by
339 is specified, also clear num-1 inodes after the specified inode.
342 Print a list of commands understood by
345 .BI htree_dump " filespec"
346 Dump the hash-indexed directory
348 showing its tree structure.
350 .BI icheck " block ..."
351 Print a listing of the inodes which use the one or more blocks specified
354 .BI inode_dump " filespec"
355 Print the contents of the inode data structure in hex and ASCII format.
358 Print the location of the inode data structure (in the inode table)
362 .BI init_filesys " device blocksize"
363 Create an ext2 file system on
367 Note that this does not fully initialize all of the data structures;
370 program. This is just a call to the low-level library, which sets up
371 the superblock and block descriptors.
373 .BI kill_file " filespec"
376 and its blocks. Note that this does not remove any directory
377 entries (if any) to this inode. See the
379 command if you wish to unlink a file.
382 Change the current working directory of the
386 on the native filesystem.
388 .BI ln " filespec dest_file"
391 which is a hard link to
393 Note this does not adjust the inode reference counts.
395 .BI logdump " [-acs] [-b block] [-i filespec] [-f journal_file] [output_file]"
396 Dump the contents of the ext3 journal. By default, dump the journal inode as
397 specified in the superblock. However, this can be overridden with the
399 option, which dumps the journal from the internal inode given by
401 A regular file containing journal data can be specified using the
405 option utilizes the backup information in the superblock to locate the
412 program to print the contents of all of the descriptor blocks.
417 to print all journal records that are refer to the specified block.
420 option will print out the contents of all of the data blocks selected by
427 .BI ls " [-d] [-l] [-p] filespec"
428 Print a listing of the files in the directory
432 flag will list deleted entries in the directory.
435 flag will list files using a more verbose format.
438 flag will list the files in a format which is more easily parsable by
439 scripts, as well as making it more clear when there are spaces or other
440 non-printing characters at the end of filenames.
442 .BI list_deleted_inodes " [limit]"
443 List deleted inodes, optionally limited to those deleted within
445 seconds ago. Also available as
448 This command was useful for recovering from accidental file deletions
449 for ext2 file systems. Unfortunately, it is not useful for this purpose
450 if the files were deleted using ext3 or ext4, since the inode's
451 data blocks are no longer available after the inode is released.
453 .BI modify_inode " filespec"
454 Modify the contents of the inode structure in the inode
459 .BI mkdir " filespec"
462 .BI mknod " filespec [p|[[c|b] major minor]]"
463 Create a special device file (a named pipe, character or block device).
464 If a character or block device is to be made, the
468 device numbers must be specified.
470 .BI ncheck " [-c] inode_num ..."
471 Take the requested list of inode numbers, and print a listing of pathnames
474 flag will enable checking the file type information in the directory
475 entry to make sure it matches the inode's type.
477 .BI open " [-weficD] [-b blocksize] [-s superblock] device"
478 Open a filesystem for editing. The
480 flag forces the filesystem to be opened even if there are some unknown
481 or incompatible filesystem features which would normally
482 prevent the filesystem from being opened. The
484 flag causes the filesystem to be opened in exclusive mode. The
485 .IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
486 options behave the same as the command-line options to
489 .BI punch " filespec start_blk [end_blk]"
490 Delete the blocks in the inode ranging from
496 is omitted then this command will function as a truncate command; that
497 is, all of the blocks starting at
499 through to the end of the file will be deallocated.
501 .BI symlink " filespec target"
502 Make a symbolic link.
505 Print the current working directory.
511 .BI rdump " directory[...] destination"
516 and all its contents (including regular files, symbolic links, and other
517 directories) into the named
519 which should be an existing directory on the native filesystem.
524 If this causes the inode pointed to by
526 to have no other references, deallocate the file. This command functions
527 as the unlink() system call.
530 .BI rmdir " filespec"
534 .BI setb " block [count]"
535 Mark the block number
538 If the optional argument
542 blocks starting at block number
544 will be marked as allocated.
546 .BI set_block_group " bgnum field value"
547 Modify the block group descriptor specified by
549 so that the block group descriptor field
556 .BI seti " filespec [num]"
559 as in use in the inode bitmap. If
561 is specified, also set num-1 inodes after the specified inode.
563 .BI set_inode_field " filespec field value"
564 Modify the inode specified by
566 so that the inode field
570 The list of valid inode fields which can be set via this command
571 can be displayed by using the command:
572 .B set_inode_field -l
576 .BI set_mmp_value " field value"
577 Modify the multiple-mount protection (MMP) data so that the MMP field
581 The list of valid MMP fields which can be set via this command
582 can be displayed by using the command:
587 .BI set_super_value " field value"
588 Set the superblock field
592 The list of valid superblock fields which can be set via this command
593 can be displayed by using the command:
594 .B set_super_value -l
598 .BI show_super_stats " [-h]"
599 List the contents of the super block and the block group descriptors. If the
601 flag is given, only print out the superblock contents. Also available as
605 Display the contents of the inode structure of the inode
608 .BI testb " block [count]"
609 Test if the block number
611 is marked as allocated in the block bitmap.
612 If the optional argument
616 blocks starting at block number
620 .BI testi " filespec"
623 is marked as allocated in the inode bitmap.
625 .BI undel " <inode_number> [pathname]"
626 Undelete the specified inode number (which must be surrounded by angle
627 brackets) so that it and its blocks are marked in use, and optionally
628 link the recovered inode to the specified pathname. The
630 command should always be run after using the
632 command to recover deleted files.
634 Note that if you are recovering a large number of deleted files, linking
635 the inode to a directory may require the directory to be expanded, which
636 could allocate a block that had been used by one of the
637 yet-to-be-undeleted files. So it is safer to undelete all of the
638 inodes without specifying a destination pathname, and then in a separate
639 pass, use the debugfs
641 command to link the inode to the destination pathname, or use
643 to check the filesystem and link all of the recovered inodes to the
644 lost+found directory.
646 .BI unlink " pathname"
647 Remove the link specified by
649 to an inode. Note this does not adjust the inode reference counts.
651 .BI write " source_file out_file"
654 into a newly-created file in the filesystem named
657 .BI zap_block " [-f filespec] [-o offset] [-l length] [-p pattern] block_num"
659 Overwrite the block specified by
661 with zero (NUL) bytes, or if
663 is given use the byte specified by
669 is relative to the start of the file given by
675 options limit the range of bytes to zap to the specified
679 relative to the start of the block.
681 .BI zap_block " [-f filespec] [-b bit] block_num"
682 Bit-flip portions of the physical
688 is a logical block relative to the start of
690 .SH ENVIRONMENT VARIABLES
692 .B DEBUGFS_PAGER, PAGER
695 program always pipes the output of the some commands through a
696 pager program. These commands include:
697 .IR show_super_stats " (" stats ),
698 .IR list_directory " (" ls ),
699 .IR show_inode_info " (" stat ),
700 .IR list_deleted_inodes " (" lsdel ),
703 The specific pager can explicitly specified by the
705 environment variable, and if it is not set, by the
707 environment variable.
709 Note that since a pager is always used, the
711 pager is not particularly appropriate, since it clears the screen before
712 displaying the output of the command and clears the output the screen
713 when the pager is exited. Many users prefer to use the
715 pager for most purposes, which is why the
717 environment variable is available to override the more general
719 environment variable.
722 was written by Theodore Ts'o <tytso@mit.edu>.