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