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
166 Print the blocks used by the inode
170 .I bmap filespec logical_block
171 Print the physical block number corresponding to the logical block number
176 .I block_dump [-f out_file] block_num
177 Dump the contents of a block, optionally to
181 Dump the contents of the inode
186 Change the current working directory to
190 Change the root directory to be the directory
194 Close the currently open file system. If the
196 option is specified, write out any changes to the superblock and block
197 group descriptors to all of the backup superblocks, not just to the
201 Clear the contents of the inode
204 .I dirsearch filespec filename
210 .I dump [-p] filespec out_file
211 Dump the contents of the inode
217 option is given set the owner, group and permissions information on
223 Display the multiple-mount protection (mmp) field values.
225 .I dx_hash [-h hash_alg] [-s hash_seed] filename
226 Calculate the directory hash of
228 The hash algorithm specified with
230 may be "legacy" "half_md4" or "tea".
231 The hash seed specified with
233 must be in UUID format.
235 .I dump_extents [-n] [-l] filespec
236 Dump the the extent tree of the inode
242 to only display the interior nodes in the extent tree. The
246 to only display the leaf nodes in the extent tree.
248 (Please note that the length and range of blocks for the last extent in
249 an interior node is an estimate by the extents library functions, and is
250 not stored in filesystem data structures. Hence, the values displayed
251 may not necessarily by accurate and does not indicate a problem or
252 corruption in the file system.)
254 .I expand_dir filespec
258 .I feature [fs_feature] [-fs_feature] ...
259 Set or clear various filesystem features in the superblock. After setting
260 or clearing any filesystem features that were requested, print the current
261 state of the filesystem feature set.
263 .I filefrag [-dvr] filespec
264 Print the number of contiguous extents in
268 is a directory and the
270 option is not specified,
272 will print the number of contiguous extents for each file in
277 print a tabular listing of the contiguous extents in the
282 to do a recursive listing of the directory.
284 .I find_free_block [count [goal]]
287 free blocks, starting from
291 .I find_free_inode [dir [mode]]
292 Find a free inode and allocate it. If present,
294 specifies the inode number of the directory
295 which the inode is to be located. The second
298 specifies the permissions of the new inode. (If the directory bit is set
299 on the mode, the allocation routine will function differently.)
301 .I freeb block [count]
302 Mark the block number
305 If the optional argument
309 blocks starting at block number
311 will be marked as not allocated.
313 .I freefrag [-c chunk_kb ]
314 Report free space fragmentation on the currently open file system.
317 option is specified then the filefrag command will print how many free
320 can be found in the file system. The chunk size must be a power of two
321 and be larger than the file system block size.
323 .I freei filespec [num]
324 Free the inode specified by
328 is specified, also clear num-1 inodes after the specified inode.
331 Print a list of commands understood by
334 .I htree_dump filespec
335 Dump the hash-indexed directory
337 showing its tree structure.
340 Print a listing of the inodes which use the one or more blocks specified
344 Print the location of the inode data structure (in the inode table)
348 .I init_filesys device blocksize
349 Create an ext2 file system on
353 Note that this does not fully initialize all of the data structures;
356 program. This is just a call to the low-level library, which sets up
357 the superblock and block descriptors.
359 .I kill_file filespec
362 and its blocks. Note that this does not remove any directory
363 entries (if any) to this inode. See the
365 command if you wish to unlink a file.
368 Change the current working directory of the
372 on the native filesystem.
374 .I ln filespec dest_file
379 Note this does not adjust the inode reference counts.
381 .I logdump [-acs] [-b<block>] [-i<filespec>] [-f<journal_file>] [output_file]
382 Dump the contents of the ext3 journal. By default, the journal inode as
383 specified in the superblock. However, this can be overridden with the
385 option, which uses an inode specifier to specify the journal to be
386 used. A file containing journal data can be specified using the
390 option utilizes the backup information in the superblock to locate the
397 program to print the contents of all of the descriptor blocks.
402 to print all journal records that are refer to the specified block.
405 option will print out the contents of all of the data blocks selected by
412 .I ls [-l] [-c] [-d] [-p] filespec
413 Print a listing of the files in the directory
417 flag will list files using a more verbose format.
420 flag causes directory block checksums (if present) to be displayed.
423 flag will list deleted entries in the directory.
426 flag will list the files in a format which is more easily parsable by
427 scripts, as well as making it more clear when there are spaces or other
428 non-printing characters at the end of filenames.
430 .I modify_inode filespec
431 Modify the contents of the inode structure in the inode
437 .I mknod filespec [p|[[c|b] major minor]]
438 Create a special device file (a named pipe, character or block device).
439 If a character or block device is to be made, the
443 device numbers must be specified.
445 .I ncheck [-c] inode_num ...
446 Take the requested list of inode numbers, and print a listing of pathnames
449 flag will enable checking the file type information in the directory
450 entry to make sure it matches the inode's type.
452 .I open [-w] [-e] [-f] [-i] [-c] [-D] [-b blocksize] [-s superblock] device
453 Open a filesystem for editing. The
455 flag forces the filesystem to be opened even if there are some unknown
456 or incompatible filesystem features which would normally
457 prevent the filesystem from being opened. The
459 flag causes the filesystem to be opened in exclusive mode. The
460 .IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
461 options behave the same as the command-line options to
464 .I punch filespec start_blk [end_blk]
465 Delete the blocks in the inode ranging from
471 is omitted then this command will function as a truncate command; that
472 is, all of the blocks starting at
474 through to the end of the file will be deallocated.
476 .I symlink filespec target
477 Make a symbolic link.
480 Print the current working directory.
486 .I rdump directory destination
489 and all its contents (including regular files, symbolic links, and other
490 directories) into the named
492 which should be an existing directory on the native filesystem.
497 If this causes the inode pointed to by
499 to have no other references, deallocate the file. This command functions
500 as the unlink() system call.
507 .I setb block [count]
508 Mark the block number
511 If the optional argument
515 blocks starting at block number
517 will be marked as allocated.
519 .I set_block_group bgnum field value
520 Modify the block group descriptor specified by
522 so that the block group descriptor field
527 .I seti filespec [num]
530 as in use in the inode bitmap. If
532 is specified, also set num-1 inodes after the specified inode.
534 .I set_inode_field filespec field value
535 Modify the inode specified by
537 so that the inode field
541 The list of valid inode fields which can be set via this command
542 can be displayed by using the command:
543 .B set_inode_field -l
545 .I set_mmp_value field value
546 Modify the multiple-mount protection (mmp) data so that the
551 The list of valid mmp fields which can be set via this command
552 can be displayed by using the command:
555 .I set_super_value field value
556 Set the superblock field
560 The list of valid superblock fields which can be set via this command
561 can be displayed by using the command:
562 .B set_super_value -l
564 .I show_super_stats [-h]
565 List the contents of the super block and the block group descriptors. If the
567 flag is given, only print out the superblock contents.
570 Display the contents of the inode structure of the inode
573 .I testb block [count]
574 Test if the block number
576 is marked as allocated in the block bitmap.
577 If the optional argument
581 blocks starting at block number
588 is marked as allocated in the inode bitmap.
590 .I undel <inode num> [pathname]
591 Undelete the specified inode number (which must be surrounded by angle
592 brackets) so that it and its blocks are marked in use, and optionally
593 link the recovered inode to the specified pathname. The
595 command should always be run after using the
597 command to recover deleted files.
599 Note that if you are recovering a large number of deleted files, linking
600 the inode to a directory may require the directory to be expanded, which
601 could allocate a block that had been used by one of the
602 yet-to-be-undeleted files. So it is safer to undelete all of the
603 inodes without specifying a destination pathname, and then in a separate
604 pass, use the debugfs
606 command to link the inode to the destination pathname, or use
608 to check the filesystem and link all of the recovered inodes to the
609 lost+found directory.
612 Remove the link specified by
614 to an inode. Note this does not adjust the inode reference counts.
616 .I write source_file out_file
617 Create a file in the filesystem named
619 and copy the contents of
621 into the destination file.
623 .I zap_block [-f file] [-o offset] [-l length] [-p pattern] block_num
624 Zero, or pattern-fill, portions of a block within a file or
625 within the filesystem.
627 .I zap_block [-f file] [-b bit] block_num
628 Bit-flip portions of a block within a file or
629 within the filesystem.
630 .SH ENVIRONMENT VARIABLES
632 .B DEBUGFS_PAGER, PAGER
635 program always pipes the output of the some commands through a
636 pager program. These commands include:
637 .IR show_super_stats ,
639 .IR show_inode_info ,
640 .IR list_deleted_inodes ,
643 The specific pager can explicitly specified by the
645 environment variable, and if it is not set, by the
647 environment variable.
649 Note that since a pager is always used, the
651 pager is not particularly appropriate, since it clears the screen before
652 displaying the output of the command and clears the output the screen
653 when the pager is exited. Many users prefer to use the
655 pager for most purposes, which is why the
657 environment variable is available to override the more general
659 environment variable.
662 was written by Theodore Ts'o <tytso@mit.edu>.