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