blob: 73254d31068b0e33cc98cbcf9c7e575226237009 [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001.\" -*- nroff -*-
Theodore Ts'o50e1e101997-04-26 13:58:21 +00002.\" 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.
JP Abgralle0ed7402014-03-19 19:08:39 -07004.\"
Theodore Ts'o74becf31997-04-26 14:37:06 +00005.TH DEBUGFS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
Theodore Ts'o3839e651997-04-26 13:21:57 +00006.SH NAME
Theodore Ts'o4f858542009-05-30 12:34:28 -04007debugfs \- ext2/ext3/ext4 file system debugger
Theodore Ts'o3839e651997-04-26 13:21:57 +00008.SH SYNOPSIS
9.B debugfs
10[
Theodore Ts'o0fd68e02010-09-24 10:12:54 -040011.B \-DVwci
Theodore Ts'o1ad54a92004-07-28 21:11:48 -040012]
13[
Theodore Ts'o2e8d40d2000-05-27 15:15:40 +000014.B \-b
15blocksize
16]
17[
18.B \-s
19superblock
20]
21[
JP Abgralle0ed7402014-03-19 19:08:39 -070022.B \-f
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +000023cmd_file
24]
25[
26.B \-R
27request
28]
29[
Theodore Ts'o1ad54a92004-07-28 21:11:48 -040030.B \-d
31data_source_device
Theodore Ts'o59cf7e02001-05-03 15:05:55 +000032]
33[
Theodore Ts'o3839e651997-04-26 13:21:57 +000034device
35]
36.SH DESCRIPTION
JP Abgralle0ed7402014-03-19 19:08:39 -070037The
38.B debugfs
Theodore Ts'o6e96adc2001-11-24 16:10:52 -050039program is an interactive file system debugger. It can be used to
Theodore Ts'o4f858542009-05-30 12:34:28 -040040examine and change the state of an ext2, ext3, or ext4 file system.
Theodore Ts'o3839e651997-04-26 13:21:57 +000041.br
42.I device
Theodore Ts'o4f858542009-05-30 12:34:28 -040043is the special file corresponding to the device containing the
Theodore Ts'o3839e651997-04-26 13:21:57 +000044file system (e.g /dev/hdXX).
45.SH OPTIONS
46.TP
Theodore Ts'o59cf7e02001-05-03 15:05:55 +000047.I \-w
Theodore Ts'o583ccdc1997-05-09 03:06:31 +000048Specifies that the file system should be opened in read-write mode.
49Without this option, the file system is opened in read-only mode.
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +000050.TP
Theodore Ts'o59cf7e02001-05-03 15:05:55 +000051.I \-c
Theodore Ts'o2e8d40d2000-05-27 15:15:40 +000052Specifies that the file system should be opened in catastrophic mode, in
53which the inode and group bitmaps are not read initially. This can be
54useful for filesystems with significant corruption, but because of this,
55catastrophic mode forces the filesystem to be opened read-only.
56.TP
Theodore Ts'o59cf7e02001-05-03 15:05:55 +000057.I \-i
JP Abgralle0ed7402014-03-19 19:08:39 -070058Specifies that
Theodore Ts'o59cf7e02001-05-03 15:05:55 +000059.I device
60represents an ext2 image file created by the
61.B e2image
62program. Since the ext2 image file only contains the superblock, block
JP Abgralle0ed7402014-03-19 19:08:39 -070063group descriptor, block and inode allocation bitmaps, and
Theodore Ts'o59cf7e02001-05-03 15:05:55 +000064the inode table, many
65.B debugfs
JP Abgralle0ed7402014-03-19 19:08:39 -070066commands will not function properly.
Theodore Ts'o59cf7e02001-05-03 15:05:55 +000067.B Warning:
JP Abgralle0ed7402014-03-19 19:08:39 -070068no safety checks are in place, and
69.B debugfs
Theodore Ts'o59cf7e02001-05-03 15:05:55 +000070may fail in interesting ways if commands such as
JP Abgralle0ed7402014-03-19 19:08:39 -070071.IR ls ", " dump ", "
72etc. are tried without specifying the
Theodore Ts'o1ad54a92004-07-28 21:11:48 -040073.I data_source_device
JP Abgralle0ed7402014-03-19 19:08:39 -070074using the
Theodore Ts'o1ad54a92004-07-28 21:11:48 -040075.I \-d
76option.
JP Abgralle0ed7402014-03-19 19:08:39 -070077.B debugfs
Theodore Ts'o59cf7e02001-05-03 15:05:55 +000078is a debugging tool. It has rough edges!
79.TP
Theodore Ts'o1ad54a92004-07-28 21:11:48 -040080.I -d data_source_device
JP Abgralle0ed7402014-03-19 19:08:39 -070081Used with the
Theodore Ts'o1ad54a92004-07-28 21:11:48 -040082.I \-i
83option, specifies that
84.I data_source_device
85should be used when reading blocks not found in the ext2 image file.
86This includes data, directory, and indirect blocks.
87.TP
Theodore Ts'o2e8d40d2000-05-27 15:15:40 +000088.I -b blocksize
89Forces the use of the given block size for the file system, rather than
90detecting the correct block size as normal.
91.TP
92.I -s superblock
Theodore Ts'o054cd1f2008-06-17 21:55:38 -040093Causes the file system superblock to be read from the given block
94number, instead of using the primary superblock (located at an offset of
951024 bytes from the beginning of the filesystem). If you specify the
Theodore Ts'o2e8d40d2000-05-27 15:15:40 +000096.I -s
Theodore Ts'o054cd1f2008-06-17 21:55:38 -040097option, you must also provide the blocksize of the filesystem via the
Theodore Ts'o2e8d40d2000-05-27 15:15:40 +000098.I -b
99option.
100.TP
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000101.I -f cmd_file
JP Abgralle0ed7402014-03-19 19:08:39 -0700102Causes
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000103.B debugfs
JP Abgralle0ed7402014-03-19 19:08:39 -0700104to read in commands from
105.IR cmd_file ,
106and execute them. When
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000107.B debugfs
Theodore Ts'o583ccdc1997-05-09 03:06:31 +0000108is finished executing those commands, it will exit.
Theodore Ts'o0fd68e02010-09-24 10:12:54 -0400109.TP
110.I -D
111Causes
112.B debugfs
113to open the device using Direct I/O, bypassing the buffer cache. Note
114that some Linux devices, notably device mapper as of this writing, do
115not support Direct I/O.
116.TP
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000117.I -R request
JP Abgralle0ed7402014-03-19 19:08:39 -0700118Causes
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000119.B debugfs
JP Abgralle0ed7402014-03-19 19:08:39 -0700120to execute the single command
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000121.IR request ,
122and then exit.
Theodore Ts'o818180c1998-06-27 05:11:14 +0000123.TP
124.I -V
JP Abgralle0ed7402014-03-19 19:08:39 -0700125print the version number of
Theodore Ts'o818180c1998-06-27 05:11:14 +0000126.B debugfs
127and exit.
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500128.SH SPECIFYING FILES
129Many
Theodore Ts'o3839e651997-04-26 13:21:57 +0000130.B debugfs
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500131commands take a
132.I filespec
JP Abgralle0ed7402014-03-19 19:08:39 -0700133as an argument to specify an inode (as opposed to a pathname)
134in the filesystem which is currently opened by
135.BR debugfs .
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500136The
137.I filespec
JP Abgralle0ed7402014-03-19 19:08:39 -0700138argument may be specified in two forms. The first form is an inode
139number surrounded by angle brackets, e.g.,
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500140.IR <2> .
141The second form is a pathname; if the pathname is prefixed by a forward slash
JP Abgralle0ed7402014-03-19 19:08:39 -0700142('/'), then it is interpreted relative to the root of the filesystem
143which is currently opened by
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500144.BR debugfs .
JP Abgralle0ed7402014-03-19 19:08:39 -0700145If not, the pathname is
146interpreted relative to the current working directory as maintained by
147.BR debugfs .
148This may be modified by using the
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500149.B debugfs
150command
151.IR cd .
JP Abgralle0ed7402014-03-19 19:08:39 -0700152.\"
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500153.\"
154.\"
155.SH COMMANDS
JP Abgralle0ed7402014-03-19 19:08:39 -0700156This is a list of the commands which
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500157.B debugfs
158supports.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000159.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700160.BI blocks " filespace"
161Print the blocks used by the inode
162.I filespec
163to stdout.
164.TP
165.BI bmap " filespec logical_block"
Theodore Ts'obecf36f2003-05-05 11:35:04 -0400166Print the physical block number corresponding to the logical block number
167.I logical_block
168in the inode
169.IR filespec .
170.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700171.BI block_dump " [-f filespec] block_num"
172Dump the filesystem block given by
173.I block_num
174in hex and ASCII format to the console. If the
175.I -f
176option is specified, the block number is relative to the start of the given
177.BR filespec .
178.TP
179.BI cat " filespec"
180Dump the contents of the inode
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000181.I filespec
182to stdout.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000183.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700184.BI cd " filespec"
185Change the current working directory to
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000186.IR filespec .
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000187.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700188.BI chroot " filespec"
189Change the root directory to be the directory
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000190.IR filespec .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000191.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700192.BI close " [-a]"
193Close the currently open file system. If the
Theodore Ts'o6dce5322009-05-28 22:03:33 -0400194.I -a
195option is specified, write out any changes to the superblock and block
196group descriptors to all of the backup superblocks, not just to the
197master superblock.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000198.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700199.BI clri " filespec"
200Clear the contents of the inode
Andreas Dilgerdba2bbd2013-12-15 22:12:43 -0500201.IR filespec .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000202.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700203.BI dirsearch " filespec filename"
204Search the directory
205.I filespec
206for
207.IR filename .
208.TP
209.B dirty
210Mark the filesystem as dirty, so that the superblocks will be written on exit.
211.TP
212.BI dump " [-p] filespec out_file"
213Dump the contents of the inode
214.I filespec
215to the output file
216.IR out_file .
217If the
218.I -p
219option is given set the owner, group and permissions information on
220.I out_file
221to match
222.IR filespec .
223.TP
224.B dump_mmp
225Display the multiple-mount protection (mmp) field values.
226.TP
227.BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
228Calculate the directory hash of
229.IR filename .
230The hash algorithm specified with
231.I -h
232may be
233.BR legacy , " half_md4" ", or " tea .
234The hash seed specified with
235.I -s
236must be in UUID format.
237.TP
238.BI dump_extents " [-n] [-l] filespec"
Theodore Ts'o187cb622009-07-26 22:29:47 -0400239Dump the the extent tree of the inode
240.IR filespec .
JP Abgralle0ed7402014-03-19 19:08:39 -0700241The
Theodore Ts'o187cb622009-07-26 22:29:47 -0400242.I -n
243flag will cause
JP Abgralle0ed7402014-03-19 19:08:39 -0700244.B dump_extents
Theodore Ts'o187cb622009-07-26 22:29:47 -0400245to only display the interior nodes in the extent tree. The
JP Abgralle0ed7402014-03-19 19:08:39 -0700246.I -l
247flag will cause
248.B dump_extents
Theodore Ts'o187cb622009-07-26 22:29:47 -0400249to only display the leaf nodes in the extent tree.
250.IP
251(Please note that the length and range of blocks for the last extent in
252an interior node is an estimate by the extents library functions, and is
JP Abgralle0ed7402014-03-19 19:08:39 -0700253not stored in filesystem data structures. Hence, the values displayed
254may not necessarily by accurate and does not indicate a problem or
Theodore Ts'o187cb622009-07-26 22:29:47 -0400255corruption in the file system.)
256.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700257.BI expand_dir " filespec"
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000258Expand the directory
259.IR filespec .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000260.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700261.BI feature " [fs_feature] [-fs_feature] ..."
Theodore Ts'od3aea7d1999-09-14 20:55:37 +0000262Set or clear various filesystem features in the superblock. After setting
263or clearing any filesystem features that were requested, print the current
264state of the filesystem feature set.
265.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700266.BI filefrag " [-dvr] filespec"
267Print the number of contiguous extents in
268.IR filespec .
269If
270.I filespec
271is a directory and the
272.I -d
273option is not specified,
274.I filefrag
275will print the number of contiguous extents for each file in
276the directory. The
277.I -v
278option will cause
279.I filefrag
280print a tabular listing of the contiguous extents in the
281file. The
282.I -r
283option will cause
284.I filefrag
285to do a recursive listing of the directory.
286.TP
287.BI find_free_block " [count [goal]]"
288Find the first
Theodore Ts'oe1018ee2002-01-03 04:55:25 -0500289.I count
290free blocks, starting from
Theodore Ts'o3839e651997-04-26 13:21:57 +0000291.I goal
JP Abgralle0ed7402014-03-19 19:08:39 -0700292and allocate it. Also available as
293.BR ffb .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000294.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700295.BI find_free_inode " [dir [mode]]"
296Find a free inode and allocate it. If present,
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000297.I dir
JP Abgralle0ed7402014-03-19 19:08:39 -0700298specifies the inode number of the directory
299which the inode is to be located. The second
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000300optional argument
301.I mode
302specifies the permissions of the new inode. (If the directory bit is set
JP Abgralle0ed7402014-03-19 19:08:39 -0700303on the mode, the allocation routine will function differently.) Also
304available as
305.BR ffi .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000306.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700307.BI freeb " block [count]"
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000308Mark the block number
309.I block
310as not allocated.
JP Abgralle0ed7402014-03-19 19:08:39 -0700311If the optional argument
312.I count
313is present, then
Theodore Ts'oe1018ee2002-01-03 04:55:25 -0500314.I count
315blocks starting at block number
316.I block
317will be marked as not allocated.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000318.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700319.BI freefrag " [-c chunk_kb]"
320Report free space fragmentation on the currently open file system.
321If the
322.I \-c
323option is specified then the filefrag command will print how many free
324chunks of size
325.I chunk_kb
326can be found in the file system. The chunk size must be a power of two
327and be larger than the file system block size.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000328.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700329.BI freei " filespec [num]"
330Free the inode specified by
331.IR filespec .
332If
333.I num
334is specified, also clear num-1 inodes after the specified inode.
335.TP
336.B help
337Print a list of commands understood by
Theodore Ts'o0fd68e02010-09-24 10:12:54 -0400338.BR debugfs .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000339.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700340.BI htree_dump " filespec"
341Dump the hash-indexed directory
342.IR filespec ,
343showing its tree structure.
344.TP
345.BI icheck " block ..."
Theodore Ts'o583ccdc1997-05-09 03:06:31 +0000346Print a listing of the inodes which use the one or more blocks specified
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000347on the command line.
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000348.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700349.BI imap " filespec"
350Print the location of the inode data structure (in the inode table)
Theodore Ts'obecf36f2003-05-05 11:35:04 -0400351of the inode
352.IR filespec .
353.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700354.BI init_filesys " device blocksize"
Theodore Ts'o3839e651997-04-26 13:21:57 +0000355Create an ext2 file system on
356.I device
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000357with device size
358.IR blocksize .
JP Abgralle0ed7402014-03-19 19:08:39 -0700359Note that this does not fully initialize all of the data structures;
360to do this, use the
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000361.BR mke2fs (8)
362program. This is just a call to the low-level library, which sets up
363the superblock and block descriptors.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000364.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700365.BI kill_file " filespec"
366Deallocate the inode
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000367.I filespec
368and its blocks. Note that this does not remove any directory
JP Abgralle0ed7402014-03-19 19:08:39 -0700369entries (if any) to this inode. See the
Theodore Ts'o583ccdc1997-05-09 03:06:31 +0000370.BR rm (1)
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000371command if you wish to unlink a file.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000372.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700373.BI lcd " directory"
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500374Change the current working directory of the
375.B debugfs
376process to
377.I directory
378on the native filesystem.
379.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700380.BI ln " filespec dest_file"
381Create a link named
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000382.I dest_file
JP Abgralle0ed7402014-03-19 19:08:39 -0700383which is a hard link to
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000384.IR filespec .
385Note this does not adjust the inode reference counts.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000386.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700387.BI logdump " [-acs] [-b block] [-i filespec] [-f journal_file] [output_file]"
388Dump the contents of the ext3 journal. By default, dump the journal inode as
389specified in the superblock. However, this can be overridden with the
Theodore Ts'oa435ec32003-08-21 00:40:26 -0400390.I \-i
JP Abgralle0ed7402014-03-19 19:08:39 -0700391option, which dumps the journal from the internal inode given by
392.IR filespec .
393A regular file containing journal data can be specified using the
Theodore Ts'oa435ec32003-08-21 00:40:26 -0400394.I \-f
JP Abgralle0ed7402014-03-19 19:08:39 -0700395option. Finally, the
Theodore Ts'oa435ec32003-08-21 00:40:26 -0400396.I \-s
397option utilizes the backup information in the superblock to locate the
398journal.
399.IP
JP Abgralle0ed7402014-03-19 19:08:39 -0700400The
Theodore Ts'oa435ec32003-08-21 00:40:26 -0400401.I \-a
JP Abgralle0ed7402014-03-19 19:08:39 -0700402option causes the
403.B logdump
Theodore Ts'oa435ec32003-08-21 00:40:26 -0400404program to print the contents of all of the descriptor blocks.
JP Abgralle0ed7402014-03-19 19:08:39 -0700405The
Theodore Ts'oa435ec32003-08-21 00:40:26 -0400406.I \-b
JP Abgralle0ed7402014-03-19 19:08:39 -0700407option causes
408.B logdump
409to print all journal records that are refer to the specified block.
410The
Theodore Ts'oa435ec32003-08-21 00:40:26 -0400411.I \-c
412option will print out the contents of all of the data blocks selected by
JP Abgralle0ed7402014-03-19 19:08:39 -0700413the
Theodore Ts'oa435ec32003-08-21 00:40:26 -0400414.I \-a
JP Abgralle0ed7402014-03-19 19:08:39 -0700415and
Theodore Ts'oa435ec32003-08-21 00:40:26 -0400416.I \-b
417options.
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500418.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700419.BI ls " [-d] [-l] [-p] filespec"
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000420Print a listing of the files in the directory
421.IR filespec .
Andreas Dilgerdba2bbd2013-12-15 22:12:43 -0500422The
JP Abgrall65f0aab2014-03-06 13:50:20 -0800423.I \-d
424flag will list deleted entries in the directory.
JP Abgralle0ed7402014-03-19 19:08:39 -0700425The
426.I \-l
427flag will list files using a more verbose format.
428The
Theodore Ts'od056b992008-01-04 15:28:51 -0500429.I \-p
430flag will list the files in a format which is more easily parsable by
431scripts, as well as making it more clear when there are spaces or other
Theodore Ts'o711d3842008-09-07 14:08:40 -0400432non-printing characters at the end of filenames.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000433.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700434.BI list_deleted_inodes " [limit]"
435List deleted inodes, optionally limited to those deleted within
436.I limit
437seconds ago. Also available as
438.BR lsdel .
439.IP
440This command was useful for recovering from accidental file deletions
441for ext2 file systems. Unfortunately, it is not useful for this purpose
442if the files were deleted using ext3 or ext4, since the inode's
443data blocks are no longer available after the inode is released.
444.TP
445.BI modify_inode " filespec"
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000446Modify the contents of the inode structure in the inode
447.IR filespec .
JP Abgralle0ed7402014-03-19 19:08:39 -0700448Also available as
449.BR mi .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000450.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700451.BI mkdir " filespec"
Theodore Ts'o3839e651997-04-26 13:21:57 +0000452Make a directory.
453.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700454.BI mknod " filespec [p|[[c|b] major minor]]"
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000455Create a special device file (a named pipe, character or block device).
JP Abgralle0ed7402014-03-19 19:08:39 -0700456If a character or block device is to be made, the
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000457.I major
458and
459.I minor
460device numbers must be specified.
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000461.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700462.BI ncheck " [-c] inode_num ..."
Theodore Ts'o583ccdc1997-05-09 03:06:31 +0000463Take the requested list of inode numbers, and print a listing of pathnames
JP Abgralle0ed7402014-03-19 19:08:39 -0700464to those inodes. The
465.I -c
466flag will enable checking the file type information in the directory
467entry to make sure it matches the inode's type.
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000468.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700469.BI open " [-weficD] [-b blocksize] [-s superblock] device"
470Open a filesystem for editing. The
471.I -f
472flag forces the filesystem to be opened even if there are some unknown
473or incompatible filesystem features which would normally
Theodore Ts'o2e8d40d2000-05-27 15:15:40 +0000474prevent the filesystem from being opened. The
Theodore Ts'o98eb44b2006-03-18 19:58:13 -0500475.I -e
476flag causes the filesystem to be opened in exclusive mode. The
Theodore Ts'o0fd68e02010-09-24 10:12:54 -0400477.IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
JP Abgralle0ed7402014-03-19 19:08:39 -0700478options behave the same as the command-line options to
Theodore Ts'o98eb44b2006-03-18 19:58:13 -0500479.BR debugfs .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000480.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700481.BI punch " filespec start_blk [end_blk]"
482Delete the blocks in the inode ranging from
483.I start_blk
484to
485.IR end_blk .
486If
487.I end_blk
488is omitted then this command will function as a truncate command; that
489is, all of the blocks starting at
490.I start_blk
491through to the end of the file will be deallocated.
492.TP
493.BI symlink " filespec target"
494Make a symbolic link.
495.TP
496.B pwd
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000497Print the current working directory.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000498.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700499.B quit
Theodore Ts'o3839e651997-04-26 13:21:57 +0000500Quit
501.B debugfs
502.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700503.BI rdump " directory destination"
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500504Recursively dump
505.I directory
506and all its contents (including regular files, symbolic links, and other
507directories) into the named
508.I destination
509which should be an existing directory on the native filesystem.
510.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700511.BI rm " pathname"
512Unlink
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000513.IR pathname .
JP Abgralle0ed7402014-03-19 19:08:39 -0700514If this causes the inode pointed to by
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000515.I pathname
516to have no other references, deallocate the file. This command functions
517as the unlink() system call.
JP Abgralle0ed7402014-03-19 19:08:39 -0700518.I
Theodore Ts'o3839e651997-04-26 13:21:57 +0000519.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700520.BI rmdir " filespec"
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000521Remove the directory
522.IR filespec .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000523.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700524.BI setb " block [count]"
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000525Mark the block number
526.I block
527as allocated.
JP Abgralle0ed7402014-03-19 19:08:39 -0700528If the optional argument
529.I count
530is present, then
Theodore Ts'oe1018ee2002-01-03 04:55:25 -0500531.I count
532blocks starting at block number
533.I block
534will be marked as allocated.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000535.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700536.BI set_block_group " bgnum field value"
Theodore Ts'oc7c12092007-04-13 15:56:00 -0400537Modify the block group descriptor specified by
538.I bgnum
539so that the block group descriptor field
540.I field
541has value
JP Abgralle0ed7402014-03-19 19:08:39 -0700542.IR value .
543Also available as
544.BR set_bg .
Theodore Ts'oc7c12092007-04-13 15:56:00 -0400545.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700546.BI seti " filespec [num]"
547Mark inode
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000548.I filespec
JP Abgralle0ed7402014-03-19 19:08:39 -0700549as in use in the inode bitmap. If
550.I num
551is specified, also set num-1 inodes after the specified inode.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000552.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700553.BI set_inode_field " filespec field value"
554Modify the inode specified by
Theodore Ts'o7dec0502004-12-21 20:37:36 -0500555.I filespec
556so that the inode field
557.I field
JP Abgralle0ed7402014-03-19 19:08:39 -0700558has value
Theodore Ts'o7dec0502004-12-21 20:37:36 -0500559.I value.
JP Abgralle0ed7402014-03-19 19:08:39 -0700560The list of valid inode fields which can be set via this command
Theodore Ts'o7dec0502004-12-21 20:37:36 -0500561can be displayed by using the command:
Theodore Ts'o1d3a9512005-01-07 21:14:12 -0500562.B set_inode_field -l
JP Abgralle0ed7402014-03-19 19:08:39 -0700563Also available as
564.BR sif .
Theodore Ts'o7dec0502004-12-21 20:37:36 -0500565.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700566.BI set_mmp_value " field value"
567Modify the multiple-mount protection (MMP) data so that the MMP field
568.I field
569has value
570.I value.
571The list of valid MMP fields which can be set via this command
572can be displayed by using the command:
573.B set_mmp_value -l
574Also available as
575.BR smmp .
576.TP
577.BI set_super_value " field value"
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500578Set the superblock field
579.I field
JP Abgralle0ed7402014-03-19 19:08:39 -0700580to
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500581.I value.
JP Abgralle0ed7402014-03-19 19:08:39 -0700582The list of valid superblock fields which can be set via this command
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500583can be displayed by using the command:
584.B set_super_value -l
JP Abgralle0ed7402014-03-19 19:08:39 -0700585Also available as
586.BR ssv .
Theodore Ts'o6e96adc2001-11-24 16:10:52 -0500587.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700588.BI show_super_stats " [-h]"
Theodore Ts'od3aea7d1999-09-14 20:55:37 +0000589List the contents of the super block and the block group descriptors. If the
590.I -h
JP Abgralle0ed7402014-03-19 19:08:39 -0700591flag is given, only print out the superblock contents. Also available as
592.BR stats .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000593.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700594.BI stat " filespec"
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000595Display the contents of the inode structure of the inode
596.IR filespec .
Theodore Ts'o3839e651997-04-26 13:21:57 +0000597.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700598.BI testb " block [count]"
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000599Test if the block number
600.I block
601is marked as allocated in the block bitmap.
JP Abgralle0ed7402014-03-19 19:08:39 -0700602If the optional argument
603.I count
604is present, then
Theodore Ts'oe1018ee2002-01-03 04:55:25 -0500605.I count
606blocks starting at block number
607.I block
608will be tested.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000609.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700610.BI testi " filespec"
611Test if the inode
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000612.I filespec
613is marked as allocated in the inode bitmap.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000614.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700615.BI undel " <inode_number> [pathname]"
Theodore Ts'ob026d532008-01-01 11:37:20 -0500616Undelete the specified inode number (which must be surrounded by angle
617brackets) so that it and its blocks are marked in use, and optionally
JP Abgralle0ed7402014-03-19 19:08:39 -0700618link the recovered inode to the specified pathname. The
Theodore Ts'ob026d532008-01-01 11:37:20 -0500619.B e2fsck
JP Abgralle0ed7402014-03-19 19:08:39 -0700620command should always be run after using the
Theodore Ts'ob026d532008-01-01 11:37:20 -0500621.B undel
622command to recover deleted files.
623.IP
624Note that if you are recovering a large number of deleted files, linking
625the inode to a directory may require the directory to be expanded, which
626could allocate a block that had been used by one of the
JP Abgralle0ed7402014-03-19 19:08:39 -0700627yet-to-be-undeleted files. So it is safer to undelete all of the
Theodore Ts'ob026d532008-01-01 11:37:20 -0500628inodes without specifying a destination pathname, and then in a separate
629pass, use the debugfs
630.B link
JP Abgralle0ed7402014-03-19 19:08:39 -0700631command to link the inode to the destination pathname, or use
Theodore Ts'ob026d532008-01-01 11:37:20 -0500632.B e2fsck
633to check the filesystem and link all of the recovered inodes to the
Theodore Ts'o711d3842008-09-07 14:08:40 -0400634lost+found directory.
Theodore Ts'ob026d532008-01-01 11:37:20 -0500635.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700636.BI unlink " pathname"
637Remove the link specified by
638.I pathname
Theodore Ts'ofc6d9d51997-04-29 14:51:31 +0000639to an inode. Note this does not adjust the inode reference counts.
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000640.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700641.BI write " source_file out_file"
642Copy the contents of
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000643.I source_file
JP Abgralle0ed7402014-03-19 19:08:39 -0700644into a newly-created file in the filesystem named
645.IR out_file .
646.TP
647.BI zap_block " [-f filespec] [-o offset] [-l length] [-p pattern] block_num"
648.TP
649Overwrite the block specified by
650.I block_num
651with zero (NUL) bytes, or if
652.I -p
653is given use the byte specified by
654.IR pattern .
655If
656.I -f
657is given then
658.I block_num
659is relative to the start of the file given by
660.IR filespec .
661The
662.I -o
663and
664.I -l
665options limit the range of bytes to zap to the specified
666.I offset
667and
668.I length
669relative to the start of the block.
670.TP
671.BI zap_block " [-f filespec] [-b bit] block_num"
672Bit-flip portions of the physical
673.IR block_num .
674If
675.I -f
676is given, then
677.I block_num
678is a logical block relative to the start of
679.IR filespec .
Theodore Ts'o2b5ddd72004-01-24 18:54:41 -0500680.SH ENVIRONMENT VARIABLES
681.TP
682.B DEBUGFS_PAGER, PAGER
683The
Theodore Ts'o0fd68e02010-09-24 10:12:54 -0400684.B debugfs
Theodore Ts'o2b5ddd72004-01-24 18:54:41 -0500685program always pipes the output of the some commands through a
JP Abgralle0ed7402014-03-19 19:08:39 -0700686pager program. These commands include:
687.IR show_super_stats " (" stats ),
688.IR list_directory " (" ls ),
689.IR show_inode_info " (" stat ),
690.IR list_deleted_inodes " (" lsdel ),
Theodore Ts'o2b5ddd72004-01-24 18:54:41 -0500691and
692.IR htree_dump .
693The specific pager can explicitly specified by the
694.B DEBUGFS_PAGER
695environment variable, and if it is not set, by the
696.B PAGER
JP Abgralle0ed7402014-03-19 19:08:39 -0700697environment variable.
Theodore Ts'o2b5ddd72004-01-24 18:54:41 -0500698.IP
JP Abgralle0ed7402014-03-19 19:08:39 -0700699Note that since a pager is always used, the
Theodore Ts'o2b5ddd72004-01-24 18:54:41 -0500700.BR less (1)
701pager is not particularly appropriate, since it clears the screen before
702displaying the output of the command and clears the output the screen
JP Abgralle0ed7402014-03-19 19:08:39 -0700703when the pager is exited. Many users prefer to use the
Theodore Ts'o2b5ddd72004-01-24 18:54:41 -0500704.BR less (1)
JP Abgralle0ed7402014-03-19 19:08:39 -0700705pager for most purposes, which is why the
706.B DEBUGFS_PAGER
Theodore Ts'o2b5ddd72004-01-24 18:54:41 -0500707environment variable is available to override the more general
708.B PAGER
709environment variable.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000710.SH AUTHOR
711.B debugfs
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000712was written by Theodore Ts'o <tytso@mit.edu>.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000713.SH SEE ALSO
714.BR dumpe2fs (8),
Andreas Mohr0fd2f902008-02-28 20:50:05 -0500715.BR tune2fs (8),
Theodore Ts'o3839e651997-04-26 13:21:57 +0000716.BR e2fsck (8),
JP Abgralle0ed7402014-03-19 19:08:39 -0700717.BR mke2fs (8),
718.BR ext4 (5)