]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - debugfs/debugfs.8.in
Merge branch 'maint' into next
[thirdparty/e2fsprogs.git] / debugfs / debugfs.8.in
1 .\" -*- nroff -*-
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.
4 .\"
5 .TH DEBUGFS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
6 .SH NAME
7 debugfs \- ext2/ext3/ext4 file system debugger
8 .SH SYNOPSIS
9 .B debugfs
10 [
11 .B \-DVwcin
12 ]
13 [
14 .B \-b
15 blocksize
16 ]
17 [
18 .B \-s
19 superblock
20 ]
21 [
22 .B \-f
23 cmd_file
24 ]
25 [
26 .B \-R
27 request
28 ]
29 [
30 .B \-d
31 data_source_device
32 ]
33 [
34 .B \-z
35 .I undo_file
36 ]
37 [
38 device
39 ]
40 .SH DESCRIPTION
41 The
42 .B debugfs
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.
45 .br
46 .I device
47 is the special file corresponding to the device containing the
48 file system (e.g /dev/hdXX).
49 .SH OPTIONS
50 .TP
51 .I \-w
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.
54 .TP
55 .I \-n
56 Disables metadata checksum verification. This should only be used if
57 you believe the metadata to be correct despite the complaints of
58 e2fsprogs.
59 .TP
60 .I \-c
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.
65 .TP
66 .I \-i
67 Specifies that
68 .I device
69 represents an ext2 image file created by the
70 .B e2image
71 program. Since the ext2 image file only contains the superblock, block
72 group descriptor, block and inode allocation bitmaps, and
73 the inode table, many
74 .B debugfs
75 commands will not function properly.
76 .B Warning:
77 no safety checks are in place, and
78 .B debugfs
79 may fail in interesting ways if commands such as
80 .IR ls ", " dump ", "
81 etc. are tried without specifying the
82 .I data_source_device
83 using the
84 .I \-d
85 option.
86 .B debugfs
87 is a debugging tool. It has rough edges!
88 .TP
89 .I -d data_source_device
90 Used with the
91 .I \-i
92 option, specifies that
93 .I data_source_device
94 should be used when reading blocks not found in the ext2 image file.
95 This includes data, directory, and indirect blocks.
96 .TP
97 .I -b blocksize
98 Forces the use of the given block size for the file system, rather than
99 detecting the correct block size as normal.
100 .TP
101 .I -s superblock
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
105 .I -s
106 option, you must also provide the blocksize of the filesystem via the
107 .I -b
108 option.
109 .TP
110 .I -f cmd_file
111 Causes
112 .B debugfs
113 to read in commands from
114 .IR cmd_file ,
115 and execute them. When
116 .B debugfs
117 is finished executing those commands, it will exit.
118 .TP
119 .I -D
120 Causes
121 .B debugfs
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.
125 .TP
126 .I -R request
127 Causes
128 .B debugfs
129 to execute the single command
130 .IR request ,
131 and then exit.
132 .TP
133 .I -V
134 print the version number of
135 .B debugfs
136 and exit.
137 .TP
138 .BI \-z " undo_file"
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.
145
146 WARNING: The undo file cannot be used to recover from a power or system crash.
147 .SH SPECIFYING FILES
148 Many
149 .B debugfs
150 commands take a
151 .I filespec
152 as an argument to specify an inode (as opposed to a pathname)
153 in the filesystem which is currently opened by
154 .BR debugfs .
155 The
156 .I filespec
157 argument may be specified in two forms. The first form is an inode
158 number surrounded by angle brackets, e.g.,
159 .IR <2> .
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
163 .BR debugfs .
164 If not, the pathname is
165 interpreted relative to the current working directory as maintained by
166 .BR debugfs .
167 This may be modified by using the
168 .B debugfs
169 command
170 .IR cd .
171 .\"
172 .\"
173 .\"
174 .SH COMMANDS
175 This is a list of the commands which
176 .B debugfs
177 supports.
178 .TP
179 .BI blocks " filespace"
180 Print the blocks used by the inode
181 .I filespec
182 to stdout.
183 .TP
184 .BI bmap " [ -a ] filespec logical_block [physical_block]"
185 Print or set the physical block number corresponding to the logical block number
186 .I logical_block
187 in the inode
188 .IR filespec .
189 If the
190 .I -a
191 flag is specified, try to allocate a block if necessary.
192 .TP
193 .BI block_dump " [-f filespec] block_num"
194 Dump the filesystem block given by
195 .I block_num
196 in hex and ASCII format to the console. If the
197 .I -f
198 option is specified, the block number is relative to the start of the given
199 .BR filespec .
200 .TP
201 .BI cat " filespec"
202 Dump the contents of the inode
203 .I filespec
204 to stdout.
205 .TP
206 .BI cd " filespec"
207 Change the current working directory to
208 .IR filespec .
209 .TP
210 .BI chroot " filespec"
211 Change the root directory to be the directory
212 .IR filespec .
213 .TP
214 .BI close " [-a]"
215 Close the currently open file system. If the
216 .I -a
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
219 master superblock.
220 .TP
221 .BI clri " filespec"
222 Clear the contents of the inode
223 .IR filespec .
224 .TP
225 .BI dirsearch " filespec filename"
226 Search the directory
227 .I filespec
228 for
229 .IR filename .
230 .TP
231 .B dirty
232 Mark the filesystem as dirty, so that the superblocks will be written on exit.
233 .TP
234 .BI dump " [-p] filespec out_file"
235 Dump the contents of the inode
236 .I filespec
237 to the output file
238 .IR out_file .
239 If the
240 .I -p
241 option is given set the owner, group and permissions information on
242 .I out_file
243 to match
244 .IR filespec .
245 .TP
246 .BI dump_mmp " [mmp_block]"
247 Display the multiple-mount protection (mmp) field values. If
248 .I mmp_block
249 is specified then verify and dump the MMP values from the given block
250 number, otherwise use the
251 .B s_mmp_block
252 field in the superblock to locate and use the existing MMP block.
253 .TP
254 .BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
255 Calculate the directory hash of
256 .IR filename .
257 The hash algorithm specified with
258 .I -h
259 may be
260 .BR legacy , " half_md4" ", or " tea .
261 The hash seed specified with
262 .I -s
263 must be in UUID format.
264 .TP
265 .BI dump_extents " [-n] [-l] filespec"
266 Dump the the extent tree of the inode
267 .IR filespec .
268 The
269 .I -n
270 flag will cause
271 .B dump_extents
272 to only display the interior nodes in the extent tree. The
273 .I -l
274 flag will cause
275 .B dump_extents
276 to only display the leaf nodes in the extent tree.
277 .IP
278 (Please note that the length and range of blocks for the last extent in
279 an interior node is an estimate by the extents library functions, and is
280 not stored in filesystem data structures. Hence, the values displayed
281 may not necessarily by accurate and does not indicate a problem or
282 corruption in the file system.)
283 .TP
284 .BI ea_get " [-f outfile] filespec attr_name"
285 Retrieve the value of the extended attribute
286 .I attr_name
287 in the file
288 .I filespec
289 and write it either to stdout or to \fIoutfile\fR.
290 .TP
291 .BI ea_list " filespec
292 List the extended attributes associated with the file
293 .I filespec
294 to standard output.
295 .TP
296 .BI ea_set " [-f infile] filespec attr_name attr_value
297 Set the value of the extended attribute
298 .I attr_name
299 in the file
300 .I filespec
301 to the string value
302 .I attr_value
303 or read it from \fIinfile\fR.
304 .TP
305 .BI ea_rm " filespec attr_names...
306 Remove the extended attribute
307 .I attr_name
308 from the file \fIfilespec\fR.
309 .TP
310 .BI expand_dir " filespec"
311 Expand the directory
312 .IR filespec .
313 .TP
314 .BI fallocate " filespec start_block [end_block]
315 Allocate and map uninitialized blocks into \fIfilespec\fR between
316 logical block \fIstart_block\fR and \fIend_block\fR, inclusive. If
317 \fIend_block\fR is not supplied, this function maps until it runs out
318 of free disk blocks or the maximum file size is reached. Existing
319 mappings are left alone.
320 .TP
321 .BI feature " [fs_feature] [-fs_feature] ..."
322 Set or clear various filesystem features in the superblock. After setting
323 or clearing any filesystem features that were requested, print the current
324 state of the filesystem feature set.
325 .TP
326 .BI filefrag " [-dvr] filespec"
327 Print the number of contiguous extents in
328 .IR filespec .
329 If
330 .I filespec
331 is a directory and the
332 .I -d
333 option is not specified,
334 .I filefrag
335 will print the number of contiguous extents for each file in
336 the directory. The
337 .I -v
338 option will cause
339 .I filefrag
340 print a tabular listing of the contiguous extents in the
341 file. The
342 .I -r
343 option will cause
344 .I filefrag
345 to do a recursive listing of the directory.
346 .TP
347 .BI find_free_block " [count [goal]]"
348 Find the first
349 .I count
350 free blocks, starting from
351 .I goal
352 and allocate it. Also available as
353 .BR ffb .
354 .TP
355 .BI find_free_inode " [dir [mode]]"
356 Find a free inode and allocate it. If present,
357 .I dir
358 specifies the inode number of the directory
359 which the inode is to be located. The second
360 optional argument
361 .I mode
362 specifies the permissions of the new inode. (If the directory bit is set
363 on the mode, the allocation routine will function differently.) Also
364 available as
365 .BR ffi .
366 .TP
367 .BI freeb " block [count]"
368 Mark the block number
369 .I block
370 as not allocated.
371 If the optional argument
372 .I count
373 is present, then
374 .I count
375 blocks starting at block number
376 .I block
377 will be marked as not allocated.
378 .TP
379 .BI freefrag " [-c chunk_kb]"
380 Report free space fragmentation on the currently open file system.
381 If the
382 .I \-c
383 option is specified then the filefrag command will print how many free
384 chunks of size
385 .I chunk_kb
386 can be found in the file system. The chunk size must be a power of two
387 and be larger than the file system block size.
388 .TP
389 .BI freei " filespec [num]"
390 Free the inode specified by
391 .IR filespec .
392 If
393 .I num
394 is specified, also clear num-1 inodes after the specified inode.
395 .TP
396 .B help
397 Print a list of commands understood by
398 .BR debugfs .
399 .TP
400 .BI htree_dump " filespec"
401 Dump the hash-indexed directory
402 .IR filespec ,
403 showing its tree structure.
404 .TP
405 .BI icheck " block ..."
406 Print a listing of the inodes which use the one or more blocks specified
407 on the command line.
408 .TP
409 .BI inode_dump " filespec"
410 Print the contents of the inode data structure in hex and ASCII format.
411 .TP
412 .BI imap " filespec"
413 Print the location of the inode data structure (in the inode table)
414 of the inode
415 .IR filespec .
416 .TP
417 .BI init_filesys " device blocksize"
418 Create an ext2 file system on
419 .I device
420 with device size
421 .IR blocksize .
422 Note that this does not fully initialize all of the data structures;
423 to do this, use the
424 .BR mke2fs (8)
425 program. This is just a call to the low-level library, which sets up
426 the superblock and block descriptors.
427 .TP
428 .BI journal_close
429 Close the open journal.
430 .TP
431 .BI journal_open " [-c] [-v ver] [-j ext_jnl]
432 Opens the journal for reading and writing. Journal checksumming can
433 be enabled by supplying \fI-c\fR; checksum formats 2 and 3 can be
434 selected with the \fI-v\fR option. An external journal can be loaded
435 from \fIext_jnl\fR.
436 .TP
437 .BI journal_run
438 Replay all transactions in the open journal.
439 .TP
440 .BI journal_write " [-b blocks] [-r revoke] [-c] file
441 Write a transaction to the open journal. The list of blocks to write
442 should be supplied as a comma-separated list in \fIblocks\fR; the
443 blocks themselves should be readable from \fIfile\fR. A list of
444 blocks to revoke can be supplied as a comma-separated list in
445 \fIrevoke\fR. By default, a commit record is written at the end; the
446 \fI-c\fR switch writes an uncommitted transaction.
447 .TP
448 .BI kill_file " filespec"
449 Deallocate the inode
450 .I filespec
451 and its blocks. Note that this does not remove any directory
452 entries (if any) to this inode. See the
453 .BR rm (1)
454 command if you wish to unlink a file.
455 .TP
456 .BI lcd " directory"
457 Change the current working directory of the
458 .B debugfs
459 process to
460 .I directory
461 on the native filesystem.
462 .TP
463 .BI ln " filespec dest_file"
464 Create a link named
465 .I dest_file
466 which is a hard link to
467 .IR filespec .
468 Note this does not adjust the inode reference counts.
469 .TP
470 .BI logdump " [-acsO] [-b block] [-i filespec] [-f journal_file] [output_file]"
471 Dump the contents of the ext3 journal. By default, dump the journal inode as
472 specified in the superblock. However, this can be overridden with the
473 .I \-i
474 option, which dumps the journal from the internal inode given by
475 .IR filespec .
476 A regular file containing journal data can be specified using the
477 .I \-f
478 option. Finally, the
479 .I \-s
480 option utilizes the backup information in the superblock to locate the
481 journal.
482 .IP
483 The
484 .I \-a
485 option causes the
486 .B logdump
487 program to print the contents of all of the descriptor blocks.
488 The
489 .I \-b
490 option causes
491 .B logdump
492 to print all journal records that are refer to the specified block.
493 The
494 .I \-c
495 option will print out the contents of all of the data blocks selected by
496 the
497 .I \-a
498 and
499 .I \-b
500 options.
501 .IP
502 The
503 .I \-O
504 option causes logdump to display old (checkpointed) journal entries.
505 This can be used to try to track down journal problems even after the
506 journal has been replayed.
507 .TP
508 .BI ls " [-l] [-c] [-d] [-p] [-r] filespec"
509 Print a listing of the files in the directory
510 .IR filespec .
511 The
512 .I \-c
513 flag causes directory block checksums (if present) to be displayed.
514 The
515 .I \-d
516 flag will list deleted entries in the directory.
517 The
518 .I \-l
519 flag will list files using a more verbose format.
520 The
521 .I \-p
522 flag will list the files in a format which is more easily parsable by
523 scripts, as well as making it more clear when there are spaces or other
524 non-printing characters at the end of filenames.
525 The
526 .I \-r
527 flag will force the printing of the filename, even if it is encrypted.
528 .TP
529 .BI list_deleted_inodes " [limit]"
530 List deleted inodes, optionally limited to those deleted within
531 .I limit
532 seconds ago. Also available as
533 .BR lsdel .
534 .IP
535 This command was useful for recovering from accidental file deletions
536 for ext2 file systems. Unfortunately, it is not useful for this purpose
537 if the files were deleted using ext3 or ext4, since the inode's
538 data blocks are no longer available after the inode is released.
539 .TP
540 .BI modify_inode " filespec"
541 Modify the contents of the inode structure in the inode
542 .IR filespec .
543 Also available as
544 .BR mi .
545 .TP
546 .BI mkdir " filespec"
547 Make a directory.
548 .TP
549 .BI mknod " filespec [p|[[c|b] major minor]]"
550 Create a special device file (a named pipe, character or block device).
551 If a character or block device is to be made, the
552 .I major
553 and
554 .I minor
555 device numbers must be specified.
556 .TP
557 .BI ncheck " [-c] inode_num ..."
558 Take the requested list of inode numbers, and print a listing of pathnames
559 to those inodes. The
560 .I -c
561 flag will enable checking the file type information in the directory
562 entry to make sure it matches the inode's type.
563 .TP
564 .BI open " [-weficD] [-b blocksize] [-s superblock] [-z undo_file] device"
565 Open a filesystem for editing. The
566 .I -f
567 flag forces the filesystem to be opened even if there are some unknown
568 or incompatible filesystem features which would normally
569 prevent the filesystem from being opened. The
570 .I -e
571 flag causes the filesystem to be opened in exclusive mode. The
572 .IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
573 options behave the same as the command-line options to
574 .BR debugfs .
575 .TP
576 .BI punch " filespec start_blk [end_blk]"
577 Delete the blocks in the inode ranging from
578 .I start_blk
579 to
580 .IR end_blk .
581 If
582 .I end_blk
583 is omitted then this command will function as a truncate command; that
584 is, all of the blocks starting at
585 .I start_blk
586 through to the end of the file will be deallocated.
587 .TP
588 .BI symlink " filespec target"
589 Make a symbolic link.
590 .TP
591 .B pwd
592 Print the current working directory.
593 .TP
594 .B quit
595 Quit
596 .B debugfs
597 .TP
598 .BI rdump " directory[...] destination"
599 Recursively dump
600 .IR directory ,
601 or multiple
602 .IR directories ,
603 and all its contents (including regular files, symbolic links, and other
604 directories) into the named
605 .IR destination ,
606 which should be an existing directory on the native filesystem.
607 .TP
608 .BI rm " pathname"
609 Unlink
610 .IR pathname .
611 If this causes the inode pointed to by
612 .I pathname
613 to have no other references, deallocate the file. This command functions
614 as the unlink() system call.
615 .I
616 .TP
617 .BI rmdir " filespec"
618 Remove the directory
619 .IR filespec .
620 .TP
621 .BI setb " block [count]"
622 Mark the block number
623 .I block
624 as allocated.
625 If the optional argument
626 .I count
627 is present, then
628 .I count
629 blocks starting at block number
630 .I block
631 will be marked as allocated.
632 .TP
633 .BI set_block_group " bgnum field value"
634 Modify the block group descriptor specified by
635 .I bgnum
636 so that the block group descriptor field
637 .I field
638 has value
639 .IR value .
640 Also available as
641 .BR set_bg .
642 .TP
643 .BI seti " filespec [num]"
644 Mark inode
645 .I filespec
646 as in use in the inode bitmap. If
647 .I num
648 is specified, also set num-1 inodes after the specified inode.
649 .TP
650 .BI set_inode_field " filespec field value"
651 Modify the inode specified by
652 .I filespec
653 so that the inode field
654 .I field
655 has value
656 .I value.
657 The list of valid inode fields which can be set via this command
658 can be displayed by using the command:
659 .B set_inode_field -l
660 Also available as
661 .BR sif .
662 .TP
663 .BI set_mmp_value " field value"
664 Modify the multiple-mount protection (MMP) data so that the MMP field
665 .I field
666 has value
667 .I value.
668 The list of valid MMP fields which can be set via this command
669 can be displayed by using the command:
670 .B set_mmp_value -l
671 Also available as
672 .BR smmp .
673 .TP
674 .BI set_super_value " field value"
675 Set the superblock field
676 .I field
677 to
678 .I value.
679 The list of valid superblock fields which can be set via this command
680 can be displayed by using the command:
681 .B set_super_value -l
682 Also available as
683 .BR ssv .
684 .TP
685 .BI show_super_stats " [-h]"
686 List the contents of the super block and the block group descriptors. If the
687 .I -h
688 flag is given, only print out the superblock contents. Also available as
689 .BR stats .
690 .TP
691 .BI stat " filespec"
692 Display the contents of the inode structure of the inode
693 .IR filespec .
694 .TP
695 .BI testb " block [count]"
696 Test if the block number
697 .I block
698 is marked as allocated in the block bitmap.
699 If the optional argument
700 .I count
701 is present, then
702 .I count
703 blocks starting at block number
704 .I block
705 will be tested.
706 .TP
707 .BI testi " filespec"
708 Test if the inode
709 .I filespec
710 is marked as allocated in the inode bitmap.
711 .TP
712 .BI undel " <inode_number> [pathname]"
713 Undelete the specified inode number (which must be surrounded by angle
714 brackets) so that it and its blocks are marked in use, and optionally
715 link the recovered inode to the specified pathname. The
716 .B e2fsck
717 command should always be run after using the
718 .B undel
719 command to recover deleted files.
720 .IP
721 Note that if you are recovering a large number of deleted files, linking
722 the inode to a directory may require the directory to be expanded, which
723 could allocate a block that had been used by one of the
724 yet-to-be-undeleted files. So it is safer to undelete all of the
725 inodes without specifying a destination pathname, and then in a separate
726 pass, use the debugfs
727 .B link
728 command to link the inode to the destination pathname, or use
729 .B e2fsck
730 to check the filesystem and link all of the recovered inodes to the
731 lost+found directory.
732 .TP
733 .BI unlink " pathname"
734 Remove the link specified by
735 .I pathname
736 to an inode. Note this does not adjust the inode reference counts.
737 .TP
738 .BI write " source_file out_file"
739 Copy the contents of
740 .I source_file
741 into a newly-created file in the filesystem named
742 .IR out_file .
743 .TP
744 .BI zap_block " [-f filespec] [-o offset] [-l length] [-p pattern] block_num"
745 Overwrite the block specified by
746 .I block_num
747 with zero (NUL) bytes, or if
748 .I -p
749 is given use the byte specified by
750 .IR pattern .
751 If
752 .I -f
753 is given then
754 .I block_num
755 is relative to the start of the file given by
756 .IR filespec .
757 The
758 .I -o
759 and
760 .I -l
761 options limit the range of bytes to zap to the specified
762 .I offset
763 and
764 .I length
765 relative to the start of the block.
766 .TP
767 .BI zap_block " [-f filespec] [-b bit] block_num"
768 Bit-flip portions of the physical
769 .IR block_num .
770 If
771 .I -f
772 is given, then
773 .I block_num
774 is a logical block relative to the start of
775 .IR filespec .
776 .SH ENVIRONMENT VARIABLES
777 .TP
778 .B DEBUGFS_PAGER, PAGER
779 The
780 .B debugfs
781 program always pipes the output of the some commands through a
782 pager program. These commands include:
783 .IR show_super_stats " (" stats ),
784 .IR list_directory " (" ls ),
785 .IR show_inode_info " (" stat ),
786 .IR list_deleted_inodes " (" lsdel ),
787 and
788 .IR htree_dump .
789 The specific pager can explicitly specified by the
790 .B DEBUGFS_PAGER
791 environment variable, and if it is not set, by the
792 .B PAGER
793 environment variable.
794 .IP
795 Note that since a pager is always used, the
796 .BR less (1)
797 pager is not particularly appropriate, since it clears the screen before
798 displaying the output of the command and clears the output the screen
799 when the pager is exited. Many users prefer to use the
800 .BR less (1)
801 pager for most purposes, which is why the
802 .B DEBUGFS_PAGER
803 environment variable is available to override the more general
804 .B PAGER
805 environment variable.
806 .SH AUTHOR
807 .B debugfs
808 was written by Theodore Ts'o <tytso@mit.edu>.
809 .SH SEE ALSO
810 .BR dumpe2fs (8),
811 .BR tune2fs (8),
812 .BR e2fsck (8),
813 .BR mke2fs (8),
814 .BR ext4 (5)