]> 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 .B dump_mmp
247 Display the multiple-mount protection (mmp) field values.
248 .TP
249 .BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
250 Calculate the directory hash of
251 .IR filename .
252 The hash algorithm specified with
253 .I -h
254 may be
255 .BR legacy , " half_md4" ", or " tea .
256 The hash seed specified with
257 .I -s
258 must be in UUID format.
259 .TP
260 .BI dump_extents " [-n] [-l] filespec"
261 Dump the the extent tree of the inode
262 .IR filespec .
263 The
264 .I -n
265 flag will cause
266 .B dump_extents
267 to only display the interior nodes in the extent tree. The
268 .I -l
269 flag will cause
270 .B dump_extents
271 to only display the leaf nodes in the extent tree.
272 .IP
273 (Please note that the length and range of blocks for the last extent in
274 an interior node is an estimate by the extents library functions, and is
275 not stored in filesystem data structures. Hence, the values displayed
276 may not necessarily by accurate and does not indicate a problem or
277 corruption in the file system.)
278 .TP
279 .BI ea_get " [-f outfile] filespec attr_name"
280 Retrieve the value of the extended attribute
281 .I attr_name
282 in the file
283 .I filespec
284 and write it either to stdout or to \fIoutfile\fR.
285 .TP
286 .BI ea_list " filespec
287 List the extended attributes associated with the file
288 .I filespec
289 to standard output.
290 .TP
291 .BI ea_set " [-f infile] filespec attr_name attr_value
292 Set the value of the extended attribute
293 .I attr_name
294 in the file
295 .I filespec
296 to the string value
297 .I attr_value
298 or read it from \fIinfile\fR.
299 .TP
300 .BI ea_rm " filespec attr_names...
301 Remove the extended attribute
302 .I attr_name
303 from the file \fIfilespec\fR.
304 .TP
305 .BI expand_dir " filespec"
306 Expand the directory
307 .IR filespec .
308 .TP
309 .BI fallocate " filespec start_block [end_block]
310 Allocate and map uninitialized blocks into \fIfilespec\fR between
311 logical block \fIstart_block\fR and \fIend_block\fR, inclusive. If
312 \fIend_block\fR is not supplied, this function maps until it runs out
313 of free disk blocks or the maximum file size is reached. Existing
314 mappings are left alone.
315 .TP
316 .BI feature " [fs_feature] [-fs_feature] ..."
317 Set or clear various filesystem features in the superblock. After setting
318 or clearing any filesystem features that were requested, print the current
319 state of the filesystem feature set.
320 .TP
321 .BI filefrag " [-dvr] filespec"
322 Print the number of contiguous extents in
323 .IR filespec .
324 If
325 .I filespec
326 is a directory and the
327 .I -d
328 option is not specified,
329 .I filefrag
330 will print the number of contiguous extents for each file in
331 the directory. The
332 .I -v
333 option will cause
334 .I filefrag
335 print a tabular listing of the contiguous extents in the
336 file. The
337 .I -r
338 option will cause
339 .I filefrag
340 to do a recursive listing of the directory.
341 .TP
342 .BI find_free_block " [count [goal]]"
343 Find the first
344 .I count
345 free blocks, starting from
346 .I goal
347 and allocate it. Also available as
348 .BR ffb .
349 .TP
350 .BI find_free_inode " [dir [mode]]"
351 Find a free inode and allocate it. If present,
352 .I dir
353 specifies the inode number of the directory
354 which the inode is to be located. The second
355 optional argument
356 .I mode
357 specifies the permissions of the new inode. (If the directory bit is set
358 on the mode, the allocation routine will function differently.) Also
359 available as
360 .BR ffi .
361 .TP
362 .BI freeb " block [count]"
363 Mark the block number
364 .I block
365 as not allocated.
366 If the optional argument
367 .I count
368 is present, then
369 .I count
370 blocks starting at block number
371 .I block
372 will be marked as not allocated.
373 .TP
374 .BI freefrag " [-c chunk_kb]"
375 Report free space fragmentation on the currently open file system.
376 If the
377 .I \-c
378 option is specified then the filefrag command will print how many free
379 chunks of size
380 .I chunk_kb
381 can be found in the file system. The chunk size must be a power of two
382 and be larger than the file system block size.
383 .TP
384 .BI freei " filespec [num]"
385 Free the inode specified by
386 .IR filespec .
387 If
388 .I num
389 is specified, also clear num-1 inodes after the specified inode.
390 .TP
391 .B help
392 Print a list of commands understood by
393 .BR debugfs .
394 .TP
395 .BI htree_dump " filespec"
396 Dump the hash-indexed directory
397 .IR filespec ,
398 showing its tree structure.
399 .TP
400 .BI icheck " block ..."
401 Print a listing of the inodes which use the one or more blocks specified
402 on the command line.
403 .TP
404 .BI inode_dump " filespec"
405 Print the contents of the inode data structure in hex and ASCII format.
406 .TP
407 .BI imap " filespec"
408 Print the location of the inode data structure (in the inode table)
409 of the inode
410 .IR filespec .
411 .TP
412 .BI init_filesys " device blocksize"
413 Create an ext2 file system on
414 .I device
415 with device size
416 .IR blocksize .
417 Note that this does not fully initialize all of the data structures;
418 to do this, use the
419 .BR mke2fs (8)
420 program. This is just a call to the low-level library, which sets up
421 the superblock and block descriptors.
422 .TP
423 .BI journal_close
424 Close the open journal.
425 .TP
426 .BI journal_open " [-c] [-v ver] [-j ext_jnl]
427 Opens the journal for reading and writing. Journal checksumming can
428 be enabled by supplying \fI-c\fR; checksum formats 2 and 3 can be
429 selected with the \fI-v\fR option. An external journal can be loaded
430 from \fIext_jnl\fR.
431 .TP
432 .BI journal_run
433 Replay all transactions in the open journal.
434 .TP
435 .BI journal_write " [-b blocks] [-r revoke] [-c] file
436 Write a transaction to the open journal. The list of blocks to write
437 should be supplied as a comma-separated list in \fIblocks\fR; the
438 blocks themselves should be readable from \fIfile\fR. A list of
439 blocks to revoke can be supplied as a comma-separated list in
440 \fIrevoke\fR. By default, a commit record is written at the end; the
441 \fI-c\fR switch writes an uncommitted transaction.
442 .TP
443 .BI kill_file " filespec"
444 Deallocate the inode
445 .I filespec
446 and its blocks. Note that this does not remove any directory
447 entries (if any) to this inode. See the
448 .BR rm (1)
449 command if you wish to unlink a file.
450 .TP
451 .BI lcd " directory"
452 Change the current working directory of the
453 .B debugfs
454 process to
455 .I directory
456 on the native filesystem.
457 .TP
458 .BI ln " filespec dest_file"
459 Create a link named
460 .I dest_file
461 which is a hard link to
462 .IR filespec .
463 Note this does not adjust the inode reference counts.
464 .TP
465 .BI logdump " [-acsO] [-b block] [-i filespec] [-f journal_file] [output_file]"
466 Dump the contents of the ext3 journal. By default, dump the journal inode as
467 specified in the superblock. However, this can be overridden with the
468 .I \-i
469 option, which dumps the journal from the internal inode given by
470 .IR filespec .
471 A regular file containing journal data can be specified using the
472 .I \-f
473 option. Finally, the
474 .I \-s
475 option utilizes the backup information in the superblock to locate the
476 journal.
477 .IP
478 The
479 .I \-a
480 option causes the
481 .B logdump
482 program to print the contents of all of the descriptor blocks.
483 The
484 .I \-b
485 option causes
486 .B logdump
487 to print all journal records that are refer to the specified block.
488 The
489 .I \-c
490 option will print out the contents of all of the data blocks selected by
491 the
492 .I \-a
493 and
494 .I \-b
495 options.
496 .IP
497 The
498 .I \-O
499 option causes logdump to display old (checkpointed) journal entries.
500 This can be used to try to track down journal problems even after the
501 journal has been replayed.
502 .TP
503 .BI ls " [-l] [-c] [-d] [-p] [-r] filespec"
504 Print a listing of the files in the directory
505 .IR filespec .
506 The
507 .I \-c
508 flag causes directory block checksums (if present) to be displayed.
509 The
510 .I \-d
511 flag will list deleted entries in the directory.
512 The
513 .I \-l
514 flag will list files using a more verbose format.
515 The
516 .I \-p
517 flag will list the files in a format which is more easily parsable by
518 scripts, as well as making it more clear when there are spaces or other
519 non-printing characters at the end of filenames.
520 The
521 .I \-r
522 flag will force the printing of the filename, even if it is encrypted.
523 .TP
524 .BI list_deleted_inodes " [limit]"
525 List deleted inodes, optionally limited to those deleted within
526 .I limit
527 seconds ago. Also available as
528 .BR lsdel .
529 .IP
530 This command was useful for recovering from accidental file deletions
531 for ext2 file systems. Unfortunately, it is not useful for this purpose
532 if the files were deleted using ext3 or ext4, since the inode's
533 data blocks are no longer available after the inode is released.
534 .TP
535 .BI modify_inode " filespec"
536 Modify the contents of the inode structure in the inode
537 .IR filespec .
538 Also available as
539 .BR mi .
540 .TP
541 .BI mkdir " filespec"
542 Make a directory.
543 .TP
544 .BI mknod " filespec [p|[[c|b] major minor]]"
545 Create a special device file (a named pipe, character or block device).
546 If a character or block device is to be made, the
547 .I major
548 and
549 .I minor
550 device numbers must be specified.
551 .TP
552 .BI ncheck " [-c] inode_num ..."
553 Take the requested list of inode numbers, and print a listing of pathnames
554 to those inodes. The
555 .I -c
556 flag will enable checking the file type information in the directory
557 entry to make sure it matches the inode's type.
558 .TP
559 .BI open " [-weficD] [-b blocksize] [-s superblock] [-z undo_file] device"
560 Open a filesystem for editing. The
561 .I -f
562 flag forces the filesystem to be opened even if there are some unknown
563 or incompatible filesystem features which would normally
564 prevent the filesystem from being opened. The
565 .I -e
566 flag causes the filesystem to be opened in exclusive mode. The
567 .IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
568 options behave the same as the command-line options to
569 .BR debugfs .
570 .TP
571 .BI punch " filespec start_blk [end_blk]"
572 Delete the blocks in the inode ranging from
573 .I start_blk
574 to
575 .IR end_blk .
576 If
577 .I end_blk
578 is omitted then this command will function as a truncate command; that
579 is, all of the blocks starting at
580 .I start_blk
581 through to the end of the file will be deallocated.
582 .TP
583 .BI symlink " filespec target"
584 Make a symbolic link.
585 .TP
586 .B pwd
587 Print the current working directory.
588 .TP
589 .B quit
590 Quit
591 .B debugfs
592 .TP
593 .BI rdump " directory[...] destination"
594 Recursively dump
595 .IR directory ,
596 or multiple
597 .IR directories ,
598 and all its contents (including regular files, symbolic links, and other
599 directories) into the named
600 .IR destination ,
601 which should be an existing directory on the native filesystem.
602 .TP
603 .BI rm " pathname"
604 Unlink
605 .IR pathname .
606 If this causes the inode pointed to by
607 .I pathname
608 to have no other references, deallocate the file. This command functions
609 as the unlink() system call.
610 .I
611 .TP
612 .BI rmdir " filespec"
613 Remove the directory
614 .IR filespec .
615 .TP
616 .BI setb " block [count]"
617 Mark the block number
618 .I block
619 as allocated.
620 If the optional argument
621 .I count
622 is present, then
623 .I count
624 blocks starting at block number
625 .I block
626 will be marked as allocated.
627 .TP
628 .BI set_block_group " bgnum field value"
629 Modify the block group descriptor specified by
630 .I bgnum
631 so that the block group descriptor field
632 .I field
633 has value
634 .IR value .
635 Also available as
636 .BR set_bg .
637 .TP
638 .BI seti " filespec [num]"
639 Mark inode
640 .I filespec
641 as in use in the inode bitmap. If
642 .I num
643 is specified, also set num-1 inodes after the specified inode.
644 .TP
645 .BI set_inode_field " filespec field value"
646 Modify the inode specified by
647 .I filespec
648 so that the inode field
649 .I field
650 has value
651 .I value.
652 The list of valid inode fields which can be set via this command
653 can be displayed by using the command:
654 .B set_inode_field -l
655 Also available as
656 .BR sif .
657 .TP
658 .BI set_mmp_value " field value"
659 Modify the multiple-mount protection (MMP) data so that the MMP field
660 .I field
661 has value
662 .I value.
663 The list of valid MMP fields which can be set via this command
664 can be displayed by using the command:
665 .B set_mmp_value -l
666 Also available as
667 .BR smmp .
668 .TP
669 .BI set_super_value " field value"
670 Set the superblock field
671 .I field
672 to
673 .I value.
674 The list of valid superblock fields which can be set via this command
675 can be displayed by using the command:
676 .B set_super_value -l
677 Also available as
678 .BR ssv .
679 .TP
680 .BI show_super_stats " [-h]"
681 List the contents of the super block and the block group descriptors. If the
682 .I -h
683 flag is given, only print out the superblock contents. Also available as
684 .BR stats .
685 .TP
686 .BI stat " filespec"
687 Display the contents of the inode structure of the inode
688 .IR filespec .
689 .TP
690 .BI testb " block [count]"
691 Test if the block number
692 .I block
693 is marked as allocated in the block bitmap.
694 If the optional argument
695 .I count
696 is present, then
697 .I count
698 blocks starting at block number
699 .I block
700 will be tested.
701 .TP
702 .BI testi " filespec"
703 Test if the inode
704 .I filespec
705 is marked as allocated in the inode bitmap.
706 .TP
707 .BI undel " <inode_number> [pathname]"
708 Undelete the specified inode number (which must be surrounded by angle
709 brackets) so that it and its blocks are marked in use, and optionally
710 link the recovered inode to the specified pathname. The
711 .B e2fsck
712 command should always be run after using the
713 .B undel
714 command to recover deleted files.
715 .IP
716 Note that if you are recovering a large number of deleted files, linking
717 the inode to a directory may require the directory to be expanded, which
718 could allocate a block that had been used by one of the
719 yet-to-be-undeleted files. So it is safer to undelete all of the
720 inodes without specifying a destination pathname, and then in a separate
721 pass, use the debugfs
722 .B link
723 command to link the inode to the destination pathname, or use
724 .B e2fsck
725 to check the filesystem and link all of the recovered inodes to the
726 lost+found directory.
727 .TP
728 .BI unlink " pathname"
729 Remove the link specified by
730 .I pathname
731 to an inode. Note this does not adjust the inode reference counts.
732 .TP
733 .BI write " source_file out_file"
734 Copy the contents of
735 .I source_file
736 into a newly-created file in the filesystem named
737 .IR out_file .
738 .TP
739 .BI zap_block " [-f filespec] [-o offset] [-l length] [-p pattern] block_num"
740 Overwrite the block specified by
741 .I block_num
742 with zero (NUL) bytes, or if
743 .I -p
744 is given use the byte specified by
745 .IR pattern .
746 If
747 .I -f
748 is given then
749 .I block_num
750 is relative to the start of the file given by
751 .IR filespec .
752 The
753 .I -o
754 and
755 .I -l
756 options limit the range of bytes to zap to the specified
757 .I offset
758 and
759 .I length
760 relative to the start of the block.
761 .TP
762 .BI zap_block " [-f filespec] [-b bit] block_num"
763 Bit-flip portions of the physical
764 .IR block_num .
765 If
766 .I -f
767 is given, then
768 .I block_num
769 is a logical block relative to the start of
770 .IR filespec .
771 .SH ENVIRONMENT VARIABLES
772 .TP
773 .B DEBUGFS_PAGER, PAGER
774 The
775 .B debugfs
776 program always pipes the output of the some commands through a
777 pager program. These commands include:
778 .IR show_super_stats " (" stats ),
779 .IR list_directory " (" ls ),
780 .IR show_inode_info " (" stat ),
781 .IR list_deleted_inodes " (" lsdel ),
782 and
783 .IR htree_dump .
784 The specific pager can explicitly specified by the
785 .B DEBUGFS_PAGER
786 environment variable, and if it is not set, by the
787 .B PAGER
788 environment variable.
789 .IP
790 Note that since a pager is always used, the
791 .BR less (1)
792 pager is not particularly appropriate, since it clears the screen before
793 displaying the output of the command and clears the output the screen
794 when the pager is exited. Many users prefer to use the
795 .BR less (1)
796 pager for most purposes, which is why the
797 .B DEBUGFS_PAGER
798 environment variable is available to override the more general
799 .B PAGER
800 environment variable.
801 .SH AUTHOR
802 .B debugfs
803 was written by Theodore Ts'o <tytso@mit.edu>.
804 .SH SEE ALSO
805 .BR dumpe2fs (8),
806 .BR tune2fs (8),
807 .BR e2fsck (8),
808 .BR mke2fs (8),
809 .BR ext4 (5)