]> 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 device
35 ]
36 .SH DESCRIPTION
37 The
38 .B debugfs
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.
41 .br
42 .I device
43 is the special file corresponding to the device containing the
44 file system (e.g /dev/hdXX).
45 .SH OPTIONS
46 .TP
47 .I \-w
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.
50 .TP
51 .I \-n
52 Disables metadata checksum verification. This should only be used if
53 you believe the metadata to be correct despite the complaints of
54 e2fsprogs.
55 .TP
56 .I \-c
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.
61 .TP
62 .I \-i
63 Specifies that
64 .I device
65 represents an ext2 image file created by the
66 .B e2image
67 program. Since the ext2 image file only contains the superblock, block
68 group descriptor, block and inode allocation bitmaps, and
69 the inode table, many
70 .B debugfs
71 commands will not function properly.
72 .B Warning:
73 no safety checks are in place, and
74 .B debugfs
75 may fail in interesting ways if commands such as
76 .IR ls ", " dump ", "
77 etc. are tried without specifying the
78 .I data_source_device
79 using the
80 .I \-d
81 option.
82 .B debugfs
83 is a debugging tool. It has rough edges!
84 .TP
85 .I -d data_source_device
86 Used with the
87 .I \-i
88 option, specifies that
89 .I data_source_device
90 should be used when reading blocks not found in the ext2 image file.
91 This includes data, directory, and indirect blocks.
92 .TP
93 .I -b blocksize
94 Forces the use of the given block size for the file system, rather than
95 detecting the correct block size as normal.
96 .TP
97 .I -s superblock
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
101 .I -s
102 option, you must also provide the blocksize of the filesystem via the
103 .I -b
104 option.
105 .TP
106 .I -f cmd_file
107 Causes
108 .B debugfs
109 to read in commands from
110 .IR cmd_file ,
111 and execute them. When
112 .B debugfs
113 is finished executing those commands, it will exit.
114 .TP
115 .I -D
116 Causes
117 .B debugfs
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.
121 .TP
122 .I -R request
123 Causes
124 .B debugfs
125 to execute the single command
126 .IR request ,
127 and then exit.
128 .TP
129 .I -V
130 print the version number of
131 .B debugfs
132 and exit.
133 .SH SPECIFYING FILES
134 Many
135 .B debugfs
136 commands take a
137 .I filespec
138 as an argument to specify an inode (as opposed to a pathname)
139 in the filesystem which is currently opened by
140 .BR debugfs .
141 The
142 .I filespec
143 argument may be specified in two forms. The first form is an inode
144 number surrounded by angle brackets, e.g.,
145 .IR <2> .
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
149 .BR debugfs .
150 If not, the pathname is
151 interpreted relative to the current working directory as maintained by
152 .BR debugfs .
153 This may be modified by using the
154 .B debugfs
155 command
156 .IR cd .
157 .\"
158 .\"
159 .\"
160 .SH COMMANDS
161 This is a list of the commands which
162 .B debugfs
163 supports.
164 .TP
165 .I blocks filespace
166 Print the blocks used by the inode
167 .I filespec
168 to stdout.
169 .TP
170 .I bmap filespec logical_block
171 Print the physical block number corresponding to the logical block number
172 .I logical_block
173 in the inode
174 .IR filespec .
175 .TP
176 .I block_dump [-f out_file] block_num
177 Dump the contents of a block, optionally to
178 .IR out_file .
179 .TP
180 .I cat filespec
181 Dump the contents of the inode
182 .I filespec
183 to stdout.
184 .TP
185 .I cd filespec
186 Change the current working directory to
187 .IR filespec .
188 .TP
189 .I chroot filespec
190 Change the root directory to be the directory
191 .IR filespec .
192 .TP
193 .I close [-a]
194 Close the currently open file system. If the
195 .I -a
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
198 master superblock.
199 .TP
200 .I clri file
201 Clear the contents of the inode
202 .IR file .
203 .TP
204 .I dirsearch filespec filename
205 Search the directory
206 .I filespec
207 for
208 .IR filename .
209 .TP
210 .I dump [-p] filespec out_file
211 Dump the contents of the inode
212 .I filespec
213 to the output file
214 .IR out_file .
215 If the
216 .I -p
217 option is given set the owner, group and permissions information on
218 .I out_file
219 to match
220 .IR filespec .
221 .TP
222 .I dump_mmp
223 Display the multiple-mount protection (mmp) field values.
224 .TP
225 .I dx_hash [-h hash_alg] [-s hash_seed] filename
226 Calculate the directory hash of
227 .IR filename .
228 The hash algorithm specified with
229 .I -h
230 may be "legacy" "half_md4" or "tea".
231 The hash seed specified with
232 .I -s
233 must be in UUID format.
234 .TP
235 .I dump_extents [-n] [-l] filespec
236 Dump the the extent tree of the inode
237 .IR filespec .
238 The
239 .I -n
240 flag will cause
241 .I dump_extents
242 to only display the interior nodes in the extent tree. The
243 .I -l
244 flag cause
245 .I dump_extents
246 to only display the leaf nodes in the extent tree.
247 .IP
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.)
253 .TP
254 .I expand_dir filespec
255 Expand the directory
256 .IR filespec .
257 .TP
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.
262 .TP
263 .I filefrag [-dvr] filespec
264 Print the number of contiguous extents in
265 .IR filespec .
266 If
267 .I filespec
268 is a directory and the
269 .I -d
270 option is not specified,
271 .I filefrag
272 will print the number of contiguous extents for each file in
273 the directory. The
274 .I -v
275 option will cause
276 .I filefrag
277 print a tabular listing of the contiguous extents in the
278 file. The
279 .I -r
280 option will cause
281 .I filefrag
282 to do a recursive listing of the directory.
283 .TP
284 .I find_free_block [count [goal]]
285 Find the first
286 .I count
287 free blocks, starting from
288 .I goal
289 and allocate it.
290 .TP
291 .I find_free_inode [dir [mode]]
292 Find a free inode and allocate it. If present,
293 .I dir
294 specifies the inode number of the directory
295 which the inode is to be located. The second
296 optional argument
297 .I mode
298 specifies the permissions of the new inode. (If the directory bit is set
299 on the mode, the allocation routine will function differently.)
300 .TP
301 .I freeb block [count]
302 Mark the block number
303 .I block
304 as not allocated.
305 If the optional argument
306 .I count
307 is present, then
308 .I count
309 blocks starting at block number
310 .I block
311 will be marked as not allocated.
312 .TP
313 .I freefrag [-c chunk_kb ]
314 Report free space fragmentation on the currently open file system.
315 If the
316 .I \-c
317 option is specified then the filefrag command will print how many free
318 chunks of size
319 .I chunk_kb
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.
322 .TP
323 .I freei filespec [num]
324 Free the inode specified by
325 .IR filespec .
326 If
327 .I num
328 is specified, also clear num-1 inodes after the specified inode.
329 .TP
330 .I help
331 Print a list of commands understood by
332 .BR debugfs .
333 .TP
334 .I htree_dump filespec
335 Dump the hash-indexed directory
336 .IR filespec ,
337 showing its tree structure.
338 .TP
339 .I icheck block ...
340 Print a listing of the inodes which use the one or more blocks specified
341 on the command line.
342 .TP
343 .I imap filespec
344 Print the location of the inode data structure (in the inode table)
345 of the inode
346 .IR filespec .
347 .TP
348 .I init_filesys device blocksize
349 Create an ext2 file system on
350 .I device
351 with device size
352 .IR blocksize .
353 Note that this does not fully initialize all of the data structures;
354 to do this, use the
355 .BR mke2fs (8)
356 program. This is just a call to the low-level library, which sets up
357 the superblock and block descriptors.
358 .TP
359 .I kill_file filespec
360 Deallocate the inode
361 .I filespec
362 and its blocks. Note that this does not remove any directory
363 entries (if any) to this inode. See the
364 .BR rm (1)
365 command if you wish to unlink a file.
366 .TP
367 .I lcd directory
368 Change the current working directory of the
369 .B debugfs
370 process to
371 .I directory
372 on the native filesystem.
373 .TP
374 .I ln filespec dest_file
375 Create a link named
376 .I dest_file
377 which is a link to
378 .IR filespec .
379 Note this does not adjust the inode reference counts.
380 .TP
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
384 .I \-i
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
387 .I \-f
388 option. Finally, the
389 .I \-s
390 option utilizes the backup information in the superblock to locate the
391 journal.
392 .IP
393 The
394 .I \-a
395 option causes the
396 .I logdump
397 program to print the contents of all of the descriptor blocks.
398 The
399 .I \-b
400 option causes
401 .I logdump
402 to print all journal records that are refer to the specified block.
403 The
404 .I \-c
405 option will print out the contents of all of the data blocks selected by
406 the
407 .I \-a
408 and
409 .I \-b
410 options.
411 .TP
412 .I ls [-l] [-c] [-d] [-p] filespec
413 Print a listing of the files in the directory
414 .IR filespec .
415 The
416 .I \-l
417 flag will list files using a more verbose format.
418 The
419 .I \-c
420 flag causes directory block checksums (if present) to be displayed.
421 The
422 .I \-d
423 flag will list deleted entries in the directory.
424 The
425 .I \-p
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.
429 .TP
430 .I modify_inode filespec
431 Modify the contents of the inode structure in the inode
432 .IR filespec .
433 .TP
434 .I mkdir filespec
435 Make a directory.
436 .TP
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
440 .I major
441 and
442 .I minor
443 device numbers must be specified.
444 .TP
445 .I ncheck [-c] inode_num ...
446 Take the requested list of inode numbers, and print a listing of pathnames
447 to those inodes. The
448 .I -c
449 flag will enable checking the file type information in the directory
450 entry to make sure it matches the inode's type.
451 .TP
452 .I open [-w] [-e] [-f] [-i] [-c] [-D] [-b blocksize] [-s superblock] device
453 Open a filesystem for editing. The
454 .I -f
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
458 .I -e
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
462 .BR debugfs .
463 .TP
464 .I punch filespec start_blk [end_blk]
465 Delete the blocks in the inode ranging from
466 .I start_blk
467 to
468 .IR end_blk .
469 If
470 .I end_blk
471 is omitted then this command will function as a truncate command; that
472 is, all of the blocks starting at
473 .I start_blk
474 through to the end of the file will be deallocated.
475 .TP
476 .I symlink filespec target
477 Make a symbolic link.
478 .TP
479 .I pwd
480 Print the current working directory.
481 .TP
482 .I quit
483 Quit
484 .B debugfs
485 .TP
486 .I rdump directory destination
487 Recursively dump
488 .I directory
489 and all its contents (including regular files, symbolic links, and other
490 directories) into the named
491 .I destination
492 which should be an existing directory on the native filesystem.
493 .TP
494 .I rm pathname
495 Unlink
496 .IR pathname .
497 If this causes the inode pointed to by
498 .I pathname
499 to have no other references, deallocate the file. This command functions
500 as the unlink() system call.
501 .I
502 .TP
503 .I rmdir filespec
504 Remove the directory
505 .IR filespec .
506 .TP
507 .I setb block [count]
508 Mark the block number
509 .I block
510 as allocated.
511 If the optional argument
512 .I count
513 is present, then
514 .I count
515 blocks starting at block number
516 .I block
517 will be marked as allocated.
518 .TP
519 .I set_block_group bgnum field value
520 Modify the block group descriptor specified by
521 .I bgnum
522 so that the block group descriptor field
523 .I field
524 has value
525 .I value.
526 .TP
527 .I seti filespec [num]
528 Mark inode
529 .I filespec
530 as in use in the inode bitmap. If
531 .I num
532 is specified, also set num-1 inodes after the specified inode.
533 .TP
534 .I set_inode_field filespec field value
535 Modify the inode specified by
536 .I filespec
537 so that the inode field
538 .I field
539 has value
540 .I value.
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
544 .TP
545 .I set_mmp_value field value
546 Modify the multiple-mount protection (mmp) data so that the
547 mmp field
548 .I field
549 has value
550 .I value.
551 The list of valid mmp fields which can be set via this command
552 can be displayed by using the command:
553 .B set_mmp_value -l
554 .TP
555 .I set_super_value field value
556 Set the superblock field
557 .I field
558 to
559 .I value.
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
563 .TP
564 .I show_super_stats [-h]
565 List the contents of the super block and the block group descriptors. If the
566 .I -h
567 flag is given, only print out the superblock contents.
568 .TP
569 .I stat filespec
570 Display the contents of the inode structure of the inode
571 .IR filespec .
572 .TP
573 .I testb block [count]
574 Test if the block number
575 .I block
576 is marked as allocated in the block bitmap.
577 If the optional argument
578 .I count
579 is present, then
580 .I count
581 blocks starting at block number
582 .I block
583 will be tested.
584 .TP
585 .I testi filespec
586 Test if the inode
587 .I filespec
588 is marked as allocated in the inode bitmap.
589 .TP
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
594 .B e2fsck
595 command should always be run after using the
596 .B undel
597 command to recover deleted files.
598 .IP
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
605 .B link
606 command to link the inode to the destination pathname, or use
607 .B e2fsck
608 to check the filesystem and link all of the recovered inodes to the
609 lost+found directory.
610 .TP
611 .I unlink pathname
612 Remove the link specified by
613 .I pathname
614 to an inode. Note this does not adjust the inode reference counts.
615 .TP
616 .I write source_file out_file
617 Create a file in the filesystem named
618 .IR out_file ,
619 and copy the contents of
620 .I source_file
621 into the destination file.
622 .TP
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.
626 .TP
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
631 .TP
632 .B DEBUGFS_PAGER, PAGER
633 The
634 .B debugfs
635 program always pipes the output of the some commands through a
636 pager program. These commands include:
637 .IR show_super_stats ,
638 .IR list_directory ,
639 .IR show_inode_info ,
640 .IR list_deleted_inodes ,
641 and
642 .IR htree_dump .
643 The specific pager can explicitly specified by the
644 .B DEBUGFS_PAGER
645 environment variable, and if it is not set, by the
646 .B PAGER
647 environment variable.
648 .IP
649 Note that since a pager is always used, the
650 .BR less (1)
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
654 .BR less (1)
655 pager for most purposes, which is why the
656 .B DEBUGFS_PAGER
657 environment variable is available to override the more general
658 .B PAGER
659 environment variable.
660 .SH AUTHOR
661 .B debugfs
662 was written by Theodore Ts'o <tytso@mit.edu>.
663 .SH SEE ALSO
664 .BR dumpe2fs (8),
665 .BR tune2fs (8),
666 .BR e2fsck (8),
667 .BR mke2fs (8)