Whamcloud - gitweb
bcec1d095897f7e50cfb22771fed34354e1f4bfc
[tools/e2fsprogs.git] / debugfs / debugfs.8.in
1 .\" -*- nroff -*-
2 .\" Copyright 1993, 1994, 1995 by Theodore Ts'o.  All Rights Reserved.
3 .\" This file may be copied under the terms of the GNU Public License.
4 .\" 
5 .TH DEBUGFS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
6 .SH NAME
7 debugfs \- ext2/ext3 file system debugger
8 .SH SYNOPSIS
9 .B debugfs
10 [
11 .B \-Vwci
12 ]
13 [
14 .B \-b
15 blocksize
16 ]
17 [
18 .B \-s
19 superblock
20 ]
21 [
22 .B \-f 
23 cmd_file
24 ]
25 [
26 .B \-R
27 request
28 ]
29 [
30 .B \-d
31 data_source_device
32 ]
33 [
34 device
35 ]
36 .SH DESCRIPTION
37 The 
38 .B debugfs 
39 program is an interactive file system debugger. It can be used to
40 examine and change the state of an ext2 file system.
41 .br
42 .I device
43 is the special file corresponding to the device containing the ext2
44 file system (e.g /dev/hdXX).
45 .SH OPTIONS
46 .TP
47 .I \-w
48 Specifies that the file system should be opened in read-write mode.
49 Without this option, the file system is opened in read-only mode.
50 .TP
51 .I \-c
52 Specifies that the file system should be opened in catastrophic mode, in
53 which the inode and group bitmaps are not read initially.  This can be
54 useful for filesystems with significant corruption, but because of this,
55 catastrophic mode forces the filesystem to be opened read-only.
56 .TP
57 .I \-i
58 Specifies that 
59 .I device
60 represents an ext2 image file created by the
61 .B e2image
62 program.  Since the ext2 image file only contains the superblock, block
63 group descriptor, block and inode allocation bitmaps, and 
64 the inode table, many
65 .B debugfs
66 commands will not function properly.  
67 .B Warning:
68 no safety checks are in place, and 
69 .B debugfs 
70 may fail in interesting ways if commands such as
71 .IR ls ", " dump ", " 
72 etc. are tried without specifying the 
73 .I data_source_device
74 using the 
75 .I \-d
76 option.
77 .B debugfs 
78 is a debugging tool.  It has rough edges!
79 .TP
80 .I -d data_source_device
81 Used with the 
82 .I \-i
83 option, specifies that
84 .I data_source_device
85 should be used when reading blocks not found in the ext2 image file.
86 This includes data, directory, and indirect blocks.
87 .TP
88 .I -b blocksize
89 Forces the use of the given block size for the file system, rather than
90 detecting the correct block size as normal.
91 .TP
92 .I -s superblock
93 Causes the file system superblock to be read from the given block
94 number, instead of using the primary superblock (located at an offset of
95 1024 bytes from the beginning of the filesystem).  If you specify the
96 .I -s
97 option, you must also provide the blocksize of the filesystem via the
98 .I -b
99 option.
100 .TP
101 .I -f cmd_file
102 Causes 
103 .B debugfs
104 to read in commands from 
105 .IR cmd_file , 
106 and execute them.  When 
107 .B debugfs
108 is finished executing those commands, it will exit.
109 .TP 
110 .I -R request
111 Causes 
112 .B debugfs
113 to execute the single command 
114 .IR request ,
115 and then exit.
116 .TP
117 .I -V
118 print the version number of 
119 .B debugfs
120 and exit.
121 .SH SPECIFYING FILES
122 Many
123 .B debugfs
124 commands take a
125 .I filespec
126 as an argument to specify an inode (as opposed to a pathname) 
127 in the filesystem which is currently opened by 
128 .BR debugfs . 
129 The
130 .I filespec
131 argument may be specified in two forms.  The first form is an inode 
132 number surrounded by angle brackets, e.g., 
133 .IR <2> .
134 The second form is a pathname; if the pathname is prefixed by a forward slash
135 ('/'), then it is interpreted relative to the root of the filesystem 
136 which is currently opened by 
137 .BR debugfs .
138 If not, the pathname is 
139 interpreted relative to the current working directory as maintained by 
140 .BR debugfs .  
141 This may be modified by using the 
142 .B debugfs
143 command
144 .IR cd .
145 .\" 
146 .\"
147 .\"
148 .SH COMMANDS
149 This is a list of the commands which 
150 .B debugfs
151 supports.
152 .TP
153 .I bmap filespec logical_block
154 Print the physical block number corresponding to the logical block number
155 .I logical_block
156 in the inode
157 .IR filespec .
158 .TP
159 .I cat filespec
160 Dump the contents of the inode 
161 .I filespec
162 to stdout.
163 .TP
164 .I cd filespec
165 Change the current working directory to 
166 .IR filespec .
167 .TP
168 .I chroot filespec
169 Change the root directory to be the directory 
170 .IR filespec .
171 .TP
172 .I close
173 Close the currently open file system.
174 .TP
175 .I clri file
176 Clear the contents of the inode 
177 .IR file .
178 .TP
179 .I dump [-p] filspec out_file
180 Dump the contents of the inode 
181 .I filespec
182 to the output file 
183 .IR out_file .  
184 If the 
185 .I -p 
186 option is given set the owner, group and permissions information on 
187 .I out_file 
188 to match 
189 .IR filespec .
190 .TP
191 .I expand_dir filespec
192 Expand the directory
193 .IR filespec .
194 .TP
195 .I feature [fs_feature] [-fs_feature] ...
196 Set or clear various filesystem features in the superblock.  After setting
197 or clearing any filesystem features that were requested, print the current
198 state of the filesystem feature set.
199 .TP
200 .I find_free_block [count [goal]]
201 Find the first 
202 .I count
203 free blocks, starting from
204 .I goal
205 and allocate it.
206 .TP
207 .I find_free_inode [dir [mode]]
208 Find a free inode and allocate it.  If present, 
209 .I dir
210 specifies the inode number of the directory 
211 which the inode is to be located.  The second 
212 optional argument
213 .I mode
214 specifies the permissions of the new inode.  (If the directory bit is set
215 on the mode, the allocation routine will function differently.)
216 .TP
217 .I freeb block [count]
218 Mark the block number
219 .I block
220 as not allocated.
221 If the optional argument 
222 .I count 
223 is present, then 
224 .I count
225 blocks starting at block number
226 .I block
227 will be marked as not allocated.
228 .TP
229 .I freei filespec
230 Free the inode specified by 
231 .IR filespec .
232 .TP
233 .I help
234 Print a list of commands understood by 
235 .BR debugfs (8).
236 .TP
237 .I icheck block ...
238 Print a listing of the inodes which use the one or more blocks specified
239 on the command line.
240 .TP
241 .I imap filespec
242 Print the location of the inode data structure (in the inode table) 
243 of the inode
244 .IR filespec .
245 .TP
246 .I init_filesys device blocksize
247 Create an ext2 file system on
248 .I device
249 with device size
250 .IR blocksize .
251 Note that this does not fully initialize all of the data structures; 
252 to do this, use the 
253 .BR mke2fs (8)
254 program.  This is just a call to the low-level library, which sets up
255 the superblock and block descriptors.
256 .TP
257 .I kill_file filespec
258 Deallocate the inode 
259 .I filespec
260 and its blocks.  Note that this does not remove any directory
261 entries (if any) to this inode.  See the 
262 .BR rm (1)
263 command if you wish to unlink a file.
264 .TP
265 .I lcd directory
266 Change the current working directory of the
267 .B debugfs
268 process to
269 .I directory
270 on the native filesystem.
271 .TP
272 .I ln filespec dest_file
273 Create a link named 
274 .I dest_file
275 which is a link to 
276 .IR filespec .
277 Note this does not adjust the inode reference counts.
278 .TP
279 .I logdump [-acs] [-b<block>] [-i<filespec>] [-f<journal_file>] [output_file]
280 Dump the contents of the ext3 journal.  By default, the journal inode as
281 specified in the superblock.  However, this can be overridden with the 
282 .I \-i
283 option, which uses an inode specifier to specify the journal to be
284 used.  A file containing journal data can be specified using the
285 .I \-f
286 option.   Finally, the 
287 .I \-s
288 option utilizes the backup information in the superblock to locate the
289 journal.
290 .IP
291 The 
292 .I \-a
293 option causes the 
294 .I logdump
295 program to print the contents of all of the descriptor blocks.
296 The 
297 .I \-b
298 option causes 
299 .I logdump
300 to print all journal records that are refer to the specified block. 
301 The 
302 .I \-c
303 option will print out the contents of all of the data blocks selected by
304 the 
305 .I \-a
306 and 
307 .I \-b
308 options.
309 .TP
310 .I ls [-l] [-d] filespec
311 Print a listing of the files in the directory
312 .IR filespec .
313 The 
314 .I \-l
315 flag will list files using a more verbose format.
316 The
317 .I \-d
318 flag will list deleted entries in the directory.
319 .TP
320 .I modify_inode filespec
321 Modify the contents of the inode structure in the inode
322 .IR filespec .
323 .TP
324 .I mkdir filespec
325 Make a directory.
326 .TP
327 .I mknod filespec [p|[[c|b] major minor]]
328 Create a special device file (a named pipe, character or block device).
329 If a character or block device is to be made, the 
330 .I major
331 and
332 .I minor
333 device numbers must be specified.
334 .TP
335 .I ncheck inode_num ...
336 Take the requested list of inode numbers, and print a listing of pathnames
337 to those inodes.
338 .TP
339 .I open [-w] [-e] [-f] [-i] [-c] [-b blocksize] [-s superblock] device
340 Open a filesystem for editing.  The 
341 .I -f 
342 flag forces the filesystem to be opened even if there are some unknown 
343 or incompatible filesystem features which would normally 
344 prevent the filesystem from being opened.  The
345 .I -e
346 flag causes the filesystem to be opened in exclusive mode.  The
347 .IR -b ", " -c ", " -i ", " -s ", and " -w
348 options behave the same as the command-line options to 
349 .BR debugfs .
350 .TP
351 .I pwd
352 Print the current working directory.
353 .TP
354 .I quit
355 Quit
356 .B debugfs
357 .TP
358 .I rdump directory destination
359 Recursively dump
360 .I directory
361 and all its contents (including regular files, symbolic links, and other
362 directories) into the named
363 .I destination
364 which should be an existing directory on the native filesystem.
365 .TP
366 .I rm pathname
367 Unlink 
368 .IR pathname .
369 If this causes the inode pointed to by 
370 .I pathname
371 to have no other references, deallocate the file.  This command functions
372 as the unlink() system call.
373 .I 
374 .TP
375 .I rmdir filespec
376 Remove the directory
377 .IR filespec .
378 .TP
379 .I setb block [count]
380 Mark the block number
381 .I block
382 as allocated.
383 If the optional argument 
384 .I count 
385 is present, then 
386 .I count
387 blocks starting at block number
388 .I block
389 will be marked as allocated.
390 .TP
391 .I set_block_group bgnum field value
392 Modify the block group descriptor specified by
393 .I bgnum
394 so that the block group descriptor field
395 .I field
396 has value
397 .I value.
398 .TP
399 .I seti filespec
400 Mark inode 
401 .I filespec
402 as in use in the inode bitmap.
403 .TP
404 .I set_inode_field filespec field value
405 Modify the inode specified by 
406 .I filespec
407 so that the inode field
408 .I field
409 has value 
410 .I value.
411 The list of valid inode fields which can be set via this command 
412 can be displayed by using the command:
413 .B set_inode_field -l
414 .TP
415 .I set_super_value field value
416 Set the superblock field
417 .I field
418 to 
419 .I value.
420 The list of valid superblock fields which can be set via this command 
421 can be displayed by using the command:
422 .B set_super_value -l
423 .TP
424 .I show_super_stats [-h]
425 List the contents of the super block and the block group descriptors.  If the
426 .I -h
427 flag is given, only print out the superblock contents.
428 .TP
429 .I stat filespec
430 Display the contents of the inode structure of the inode
431 .IR filespec .
432 .TP
433 .I testb block [count]
434 Test if the block number
435 .I block
436 is marked as allocated in the block bitmap.
437 If the optional argument 
438 .I count 
439 is present, then 
440 .I count
441 blocks starting at block number
442 .I block
443 will be tested.
444 .TP
445 .I testi filespec
446 Test if the inode 
447 .I filespec
448 is marked as allocated in the inode bitmap.
449 .TP
450 .I undel <inode num> [pathname]
451 Undelete the specified inode number (which must be surrounded by angle
452 brackets) so that it and its blocks are marked in use, and optionally
453 link the recovered inode to the specified pathname.  The 
454 .B e2fsck
455 command should always be run after using the 
456 .B undel
457 command to recover deleted files.
458 .IP
459 Note that if you are recovering a large number of deleted files, linking
460 the inode to a directory may require the directory to be expanded, which
461 could allocate a block that had been used by one of the
462 yet-to-be-undeleted files.  So it is safer to undelete all of the 
463 inodes without specifying a destination pathname, and then in a separate
464 pass, use the debugfs
465 .B link
466 command to link the inode to the destination pathname, or use 
467 .B e2fsck
468 to check the filesystem and link all of the recovered inodes to the
469 lost+found dirctory.
470 .TP
471 .I unlink pathname
472 Remove the link specified by 
473 .I pathname 
474 to an inode.  Note this does not adjust the inode reference counts.
475 .TP
476 .I write source_file out_file
477 Create a file in the filesystem named
478 .IR out_file ,
479 and copy the contents of
480 .I source_file
481 into the destination file.
482 .SH ENVIRONMENT VARIABLES
483 .TP
484 .B DEBUGFS_PAGER, PAGER
485 The
486 .BR debugfs (8)
487 program always pipes the output of the some commands through a
488 pager program.  These commands include: 
489 .IR show_super_stats ,
490 .IR list_directory ,
491 .IR show_inode_info ,
492 .IR list_deleted_inodes ,
493 and
494 .IR htree_dump .
495 The specific pager can explicitly specified by the
496 .B DEBUGFS_PAGER
497 environment variable, and if it is not set, by the
498 .B PAGER
499 environment variable.  
500 .IP
501 Note that since a pager is always used, the 
502 .BR less (1)
503 pager is not particularly appropriate, since it clears the screen before
504 displaying the output of the command and clears the output the screen
505 when the pager is exited.  Many users prefer to use the 
506 .BR less (1)
507 pager for most purposes, which is why the 
508 .B DEBUGFS_PAGER 
509 environment variable is available to override the more general
510 .B PAGER
511 environment variable.
512 .SH AUTHOR
513 .B debugfs
514 was written by Theodore Ts'o <tytso@mit.edu>.
515 .SH SEE ALSO
516 .BR dumpe2fs (8),
517 .BR tune2fs (8),
518 .BR e2fsck (8),
519 .BR mke2fs (8)