1DEBUGFS(8) System Manager's Manual DEBUGFS(8)
2
3
4
6 debugfs - ext2/ext3/ext4 file system debugger
7
9 debugfs [ -Vwci ] [ -b blocksize ] [ -s superblock ] [ -f cmd_file ] [
10 -R request ] [ -d data_source_device ] [ device ]
11
13 The debugfs program is an interactive file system debugger. It can be
14 used to examine and change the state of an ext2, ext3, or ext4 file
15 system.
16 device is the special file corresponding to the device containing the
17 file system (e.g /dev/hdXX).
18
20 -w Specifies that the file system should be opened in read-write
21 mode. Without this option, the file system is opened in read-
22 only mode.
23
24 -c Specifies that the file system should be opened in catastrophic
25 mode, in which the inode and group bitmaps are not read ini‐
26 tially. This can be useful for filesystems with significant
27 corruption, but because of this, catastrophic mode forces the
28 filesystem to be opened read-only.
29
30 -i Specifies that device represents an ext2 image file created by
31 the e2image program. Since the ext2 image file only contains
32 the superblock, block group descriptor, block and inode alloca‐
33 tion bitmaps, and the inode table, many debugfs commands will
34 not function properly. Warning: no safety checks are in place,
35 and debugfs may fail in interesting ways if commands such as ls,
36 dump, etc. are tried without specifying the data_source_device
37 using the -d option. debugfs is a debugging tool. It has rough
38 edges!
39
40 -d data_source_device
41 Used with the -i option, specifies that data_source_device
42 should be used when reading blocks not found in the ext2 image
43 file. This includes data, directory, and indirect blocks.
44
45 -b blocksize
46 Forces the use of the given block size for the file system,
47 rather than detecting the correct block size as normal.
48
49 -s superblock
50 Causes the file system superblock to be read from the given
51 block number, instead of using the primary superblock (located
52 at an offset of 1024 bytes from the beginning of the filesys‐
53 tem). If you specify the -s option, you must also provide the
54 blocksize of the filesystem via the -b option.
55
56 -f cmd_file
57 Causes debugfs to read in commands from cmd_file, and execute
58 them. When debugfs is finished executing those commands, it
59 will exit.
60
61 -R request
62 Causes debugfs to execute the single command request, and then
63 exit.
64
65 -V print the version number of debugfs and exit.
66
68 Many debugfs commands take a filespec as an argument to specify an
69 inode (as opposed to a pathname) in the filesystem which is currently
70 opened by debugfs. The filespec argument may be specified in two
71 forms. The first form is an inode number surrounded by angle brackets,
72 e.g., <2>. The second form is a pathname; if the pathname is prefixed
73 by a forward slash ('/'), then it is interpreted relative to the root
74 of the filesystem which is currently opened by debugfs. If not, the
75 pathname is interpreted relative to the current working directory as
76 maintained by debugfs. This may be modified by using the debugfs com‐
77 mand cd.
78
80 This is a list of the commands which debugfs supports.
81
82 bmap filespec logical_block
83 Print the physical block number corresponding to the logical
84 block number logical_block in the inode filespec.
85
86 cat filespec
87 Dump the contents of the inode filespec to stdout.
88
89 cd filespec
90 Change the current working directory to filespec.
91
92 chroot filespec
93 Change the root directory to be the directory filespec.
94
95 close [-a]
96 Close the currently open file system. If the -a option is spec‐
97 ified, write out any changes to the superblock and block group
98 descriptors to all of the backup superblocks, not just to the
99 master superblock.
100
101 clri file
102 Clear the contents of the inode file.
103
104 dump [-p] filespec out_file
105 Dump the contents of the inode filespec to the output file
106 out_file. If the -p option is given set the owner, group and
107 permissions information on out_file to match filespec.
108
109 dump_extents [-n] [-l] filespec
110 Dump the the extent tree of the inode filespec. The -n flag
111 will cause dump_extents to only display the interior nodes in
112 the extent tree. The -l flag cause dump_extents to only dis‐
113 play the leaf nodes in the extent tree.
114
115 (Please note that the length and range of blocks for the last
116 extent in an interior node is an estimate by the extents library
117 functions, and is not stored in file esystem data structures.
118 Hence, the values displayed may not necessarily by accurate and
119 does not indicate a problem or corruption in the file system.)
120
121 expand_dir filespec
122 Expand the directory filespec.
123
124 feature [fs_feature] [-fs_feature] ...
125 Set or clear various filesystem features in the superblock.
126 After setting or clearing any filesystem features that were
127 requested, print the current state of the filesystem feature
128 set.
129
130 find_free_block [count [goal]]
131 Find the first count free blocks, starting from goal and allo‐
132 cate it.
133
134 find_free_inode [dir [mode]]
135 Find a free inode and allocate it. If present, dir specifies
136 the inode number of the directory which the inode is to be
137 located. The second optional argument mode specifies the per‐
138 missions of the new inode. (If the directory bit is set on the
139 mode, the allocation routine will function differently.)
140
141 freeb block [count]
142 Mark the block number block as not allocated. If the optional
143 argument count is present, then count blocks starting at block
144 number block will be marked as not allocated.
145
146 freei filespec
147 Free the inode specified by filespec.
148
149 help Print a list of commands understood by debugfs(8).
150
151 icheck block ...
152 Print a listing of the inodes which use the one or more blocks
153 specified on the command line.
154
155 imap filespec
156 Print the location of the inode data structure (in the inode ta‐
157 ble) of the inode filespec.
158
159 init_filesys device blocksize
160 Create an ext2 file system on device with device size blocksize.
161 Note that this does not fully initialize all of the data struc‐
162 tures; to do this, use the mke2fs(8) program. This is just a
163 call to the low-level library, which sets up the superblock and
164 block descriptors.
165
166 kill_file filespec
167 Deallocate the inode filespec and its blocks. Note that this
168 does not remove any directory entries (if any) to this inode.
169 See the rm(1) command if you wish to unlink a file.
170
171 lcd directory
172 Change the current working directory of the debugfs process to
173 directory on the native filesystem.
174
175 ln filespec dest_file
176 Create a link named dest_file which is a link to filespec. Note
177 this does not adjust the inode reference counts.
178
179 logdump [-acs] [-b<block>] [-i<filespec>] [-f<journal_file>] [out‐
180 put_file]
181 Dump the contents of the ext3 journal. By default, the journal
182 inode as specified in the superblock. However, this can be
183 overridden with the -i option, which uses an inode specifier to
184 specify the journal to be used. A file containing journal data
185 can be specified using the -f option. Finally, the -s option
186 utilizes the backup information in the superblock to locate the
187 journal.
188
189 The -a option causes the logdump program to print the contents
190 of all of the descriptor blocks. The -b option causes logdump
191 to print all journal records that are refer to the specified
192 block. The -c option will print out the contents of all of the
193 data blocks selected by the -a and -b options.
194
195 ls [-l] [-d] [-p] filespec
196 Print a listing of the files in the directory filespec. The -l
197 flag will list files using a more verbose format. The -d flag
198 will list deleted entries in the directory. The -p flag will
199 list the files in a format which is more easily parsable by
200 scripts, as well as making it more clear when there are spaces
201 or other non-printing characters at the end of filenames.
202
203 modify_inode filespec
204 Modify the contents of the inode structure in the inode file‐
205 spec.
206
207 mkdir filespec
208 Make a directory.
209
210 mknod filespec [p|[[c|b] major minor]]
211 Create a special device file (a named pipe, character or block
212 device). If a character or block device is to be made, the
213 major and minor device numbers must be specified.
214
215 ncheck inode_num ...
216 Take the requested list of inode numbers, and print a listing of
217 pathnames to those inodes.
218
219 open [-w] [-e] [-f] [-i] [-c] [-b blocksize] [-s superblock] device
220 Open a filesystem for editing. The -f flag forces the filesys‐
221 tem to be opened even if there are some unknown or incompatible
222 filesystem features which would normally prevent the filesystem
223 from being opened. The -e flag causes the filesystem to be
224 opened in exclusive mode. The -b, -c, -i, -s, and -w options
225 behave the same as the command-line options to debugfs.
226
227 pwd Print the current working directory.
228
229 quit Quit debugfs
230
231 rdump directory destination
232 Recursively dump directory and all its contents (including regu‐
233 lar files, symbolic links, and other directories) into the named
234 destination which should be an existing directory on the native
235 filesystem.
236
237 rm pathname
238 Unlink pathname. If this causes the inode pointed to by path‐
239 name to have no other references, deallocate the file. This
240 command functions as the unlink() system call.
241
242 rmdir filespec
243 Remove the directory filespec.
244
245 setb block [count]
246 Mark the block number block as allocated. If the optional argu‐
247 ment count is present, then count blocks starting at block num‐
248 ber block will be marked as allocated.
249
250 set_block_group bgnum field value
251 Modify the block group descriptor specified by bgnum so that the
252 block group descriptor field field has value value.
253
254 seti filespec
255 Mark inode filespec as in use in the inode bitmap.
256
257 set_inode_field filespec field value
258 Modify the inode specified by filespec so that the inode field
259 field has value value. The list of valid inode fields which can
260 be set via this command can be displayed by using the command:
261 set_inode_field -l
262
263 set_super_value field value
264 Set the superblock field field to value. The list of valid
265 superblock fields which can be set via this command can be dis‐
266 played by using the command: set_super_value -l
267
268 show_super_stats [-h]
269 List the contents of the super block and the block group
270 descriptors. If the -h flag is given, only print out the
271 superblock contents.
272
273 stat filespec
274 Display the contents of the inode structure of the inode file‐
275 spec.
276
277 testb block [count]
278 Test if the block number block is marked as allocated in the
279 block bitmap. If the optional argument count is present, then
280 count blocks starting at block number block will be tested.
281
282 testi filespec
283 Test if the inode filespec is marked as allocated in the inode
284 bitmap.
285
286 undel <inode num> [pathname]
287 Undelete the specified inode number (which must be surrounded by
288 angle brackets) so that it and its blocks are marked in use, and
289 optionally link the recovered inode to the specified pathname.
290 The e2fsck command should always be run after using the undel
291 command to recover deleted files.
292
293 Note that if you are recovering a large number of deleted files,
294 linking the inode to a directory may require the directory to be
295 expanded, which could allocate a block that had been used by one
296 of the yet-to-be-undeleted files. So it is safer to undelete
297 all of the inodes without specifying a destination pathname, and
298 then in a separate pass, use the debugfs link command to link
299 the inode to the destination pathname, or use e2fsck to check
300 the filesystem and link all of the recovered inodes to the
301 lost+found directory.
302
303 unlink pathname
304 Remove the link specified by pathname to an inode. Note this
305 does not adjust the inode reference counts.
306
307 write source_file out_file
308 Create a file in the filesystem named out_file, and copy the
309 contents of source_file into the destination file.
310
312 DEBUGFS_PAGER, PAGER
313 The debugfs(8) program always pipes the output of the some com‐
314 mands through a pager program. These commands include:
315 show_super_stats, list_directory, show_inode_info,
316 list_deleted_inodes, and htree_dump. The specific pager can
317 explicitly specified by the DEBUGFS_PAGER environment variable,
318 and if it is not set, by the PAGER environment variable.
319
320 Note that since a pager is always used, the less(1) pager is not
321 particularly appropriate, since it clears the screen before dis‐
322 playing the output of the command and clears the output the
323 screen when the pager is exited. Many users prefer to use the
324 less(1) pager for most purposes, which is why the DEBUGFS_PAGER
325 environment variable is available to override the more general
326 PAGER environment variable.
327
329 debugfs was written by Theodore Ts'o <tytso@mit.edu>.
330
332 dumpe2fs(8), tune2fs(8), e2fsck(8), mke2fs(8)
333
334
335
336E2fsprogs version 1.41.12 May 2010 DEBUGFS(8)