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