OSDN Git Service

Merge "Xcode 4.3 compatibility checkin"
[android-x86/external-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/ext4 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, ext3, or ext4 file system.
41 .br
42 .I device
43 is the special file corresponding to the device containing the
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 [-a]
173 Close the currently open file system.  If the 
174 .I -a
175 option is specified, write out any changes to the superblock and block
176 group descriptors to all of the backup superblocks, not just to the
177 master superblock.
178 .TP
179 .I clri file
180 Clear the contents of the inode 
181 .IR file .
182 .TP
183 .I dump [-p] filespec out_file
184 Dump the contents of the inode 
185 .I filespec
186 to the output file 
187 .IR out_file .  
188 If the 
189 .I -p 
190 option is given set the owner, group and permissions information on 
191 .I out_file 
192 to match 
193 .IR filespec .
194 .TP
195 .I dump_extents [-n] [-l] filespec
196 Dump the the extent tree of the inode
197 .IR filespec .
198 The 
199 .I -n
200 flag will cause
201 .I dump_extents
202 to only display the interior nodes in the extent tree.   The
203 .I  -l
204 flag cause
205 .I dump_extents
206 to only display the leaf nodes in the extent tree.
207 .IP
208 (Please note that the length and range of blocks for the last extent in
209 an interior node is an estimate by the extents library functions, and is
210 not stored in file esystem data structures.   Hence, the values displayed
211 may not necessarily by accurate and does not indicate a problem or 
212 corruption in the file system.)
213 .TP
214 .I expand_dir filespec
215 Expand the directory
216 .IR filespec .
217 .TP
218 .I feature [fs_feature] [-fs_feature] ...
219 Set or clear various filesystem features in the superblock.  After setting
220 or clearing any filesystem features that were requested, print the current
221 state of the filesystem feature set.
222 .TP
223 .I find_free_block [count [goal]]
224 Find the first 
225 .I count
226 free blocks, starting from
227 .I goal
228 and allocate it.
229 .TP
230 .I find_free_inode [dir [mode]]
231 Find a free inode and allocate it.  If present, 
232 .I dir
233 specifies the inode number of the directory 
234 which the inode is to be located.  The second 
235 optional argument
236 .I mode
237 specifies the permissions of the new inode.  (If the directory bit is set
238 on the mode, the allocation routine will function differently.)
239 .TP
240 .I freeb block [count]
241 Mark the block number
242 .I block
243 as not allocated.
244 If the optional argument 
245 .I count 
246 is present, then 
247 .I count
248 blocks starting at block number
249 .I block
250 will be marked as not allocated.
251 .TP
252 .I freei filespec
253 Free the inode specified by 
254 .IR filespec .
255 .TP
256 .I help
257 Print a list of commands understood by 
258 .BR debugfs (8).
259 .TP
260 .I icheck block ...
261 Print a listing of the inodes which use the one or more blocks specified
262 on the command line.
263 .TP
264 .I imap filespec
265 Print the location of the inode data structure (in the inode table) 
266 of the inode
267 .IR filespec .
268 .TP
269 .I init_filesys device blocksize
270 Create an ext2 file system on
271 .I device
272 with device size
273 .IR blocksize .
274 Note that this does not fully initialize all of the data structures; 
275 to do this, use the 
276 .BR mke2fs (8)
277 program.  This is just a call to the low-level library, which sets up
278 the superblock and block descriptors.
279 .TP
280 .I kill_file filespec
281 Deallocate the inode 
282 .I filespec
283 and its blocks.  Note that this does not remove any directory
284 entries (if any) to this inode.  See the 
285 .BR rm (1)
286 command if you wish to unlink a file.
287 .TP
288 .I lcd directory
289 Change the current working directory of the
290 .B debugfs
291 process to
292 .I directory
293 on the native filesystem.
294 .TP
295 .I ln filespec dest_file
296 Create a link named 
297 .I dest_file
298 which is a link to 
299 .IR filespec .
300 Note this does not adjust the inode reference counts.
301 .TP
302 .I logdump [-acs] [-b<block>] [-i<filespec>] [-f<journal_file>] [output_file]
303 Dump the contents of the ext3 journal.  By default, the journal inode as
304 specified in the superblock.  However, this can be overridden with the 
305 .I \-i
306 option, which uses an inode specifier to specify the journal to be
307 used.  A file containing journal data can be specified using the
308 .I \-f
309 option.   Finally, the 
310 .I \-s
311 option utilizes the backup information in the superblock to locate the
312 journal.
313 .IP
314 The 
315 .I \-a
316 option causes the 
317 .I logdump
318 program to print the contents of all of the descriptor blocks.
319 The 
320 .I \-b
321 option causes 
322 .I logdump
323 to print all journal records that are refer to the specified block. 
324 The 
325 .I \-c
326 option will print out the contents of all of the data blocks selected by
327 the 
328 .I \-a
329 and 
330 .I \-b
331 options.
332 .TP
333 .I ls [-l] [-d] [-p] filespec
334 Print a listing of the files in the directory
335 .IR filespec .
336 The 
337 .I \-l
338 flag will list files using a more verbose format.
339 The
340 .I \-d
341 flag will list deleted entries in the directory.
342 The 
343 .I \-p
344 flag will list the files in a format which is more easily parsable by
345 scripts, as well as making it more clear when there are spaces or other
346 non-printing characters at the end of filenames.
347 .TP
348 .I modify_inode filespec
349 Modify the contents of the inode structure in the inode
350 .IR filespec .
351 .TP
352 .I mkdir filespec
353 Make a directory.
354 .TP
355 .I mknod filespec [p|[[c|b] major minor]]
356 Create a special device file (a named pipe, character or block device).
357 If a character or block device is to be made, the 
358 .I major
359 and
360 .I minor
361 device numbers must be specified.
362 .TP
363 .I ncheck inode_num ...
364 Take the requested list of inode numbers, and print a listing of pathnames
365 to those inodes.
366 .TP
367 .I open [-w] [-e] [-f] [-i] [-c] [-b blocksize] [-s superblock] device
368 Open a filesystem for editing.  The 
369 .I -f 
370 flag forces the filesystem to be opened even if there are some unknown 
371 or incompatible filesystem features which would normally 
372 prevent the filesystem from being opened.  The
373 .I -e
374 flag causes the filesystem to be opened in exclusive mode.  The
375 .IR -b ", " -c ", " -i ", " -s ", and " -w
376 options behave the same as the command-line options to 
377 .BR debugfs .
378 .TP
379 .I pwd
380 Print the current working directory.
381 .TP
382 .I quit
383 Quit
384 .B debugfs
385 .TP
386 .I rdump directory destination
387 Recursively dump
388 .I directory
389 and all its contents (including regular files, symbolic links, and other
390 directories) into the named
391 .I destination
392 which should be an existing directory on the native filesystem.
393 .TP
394 .I rm pathname
395 Unlink 
396 .IR pathname .
397 If this causes the inode pointed to by 
398 .I pathname
399 to have no other references, deallocate the file.  This command functions
400 as the unlink() system call.
401 .I 
402 .TP
403 .I rmdir filespec
404 Remove the directory
405 .IR filespec .
406 .TP
407 .I setb block [count]
408 Mark the block number
409 .I block
410 as allocated.
411 If the optional argument 
412 .I count 
413 is present, then 
414 .I count
415 blocks starting at block number
416 .I block
417 will be marked as allocated.
418 .TP
419 .I set_block_group bgnum field value
420 Modify the block group descriptor specified by
421 .I bgnum
422 so that the block group descriptor field
423 .I field
424 has value
425 .I value.
426 .TP
427 .I seti filespec
428 Mark inode 
429 .I filespec
430 as in use in the inode bitmap.
431 .TP
432 .I set_inode_field filespec field value
433 Modify the inode specified by 
434 .I filespec
435 so that the inode field
436 .I field
437 has value 
438 .I value.
439 The list of valid inode fields which can be set via this command 
440 can be displayed by using the command:
441 .B set_inode_field -l
442 .TP
443 .I set_super_value field value
444 Set the superblock field
445 .I field
446 to 
447 .I value.
448 The list of valid superblock fields which can be set via this command 
449 can be displayed by using the command:
450 .B set_super_value -l
451 .TP
452 .I show_super_stats [-h]
453 List the contents of the super block and the block group descriptors.  If the
454 .I -h
455 flag is given, only print out the superblock contents.
456 .TP
457 .I stat filespec
458 Display the contents of the inode structure of the inode
459 .IR filespec .
460 .TP
461 .I testb block [count]
462 Test if the block number
463 .I block
464 is marked as allocated in the block bitmap.
465 If the optional argument 
466 .I count 
467 is present, then 
468 .I count
469 blocks starting at block number
470 .I block
471 will be tested.
472 .TP
473 .I testi filespec
474 Test if the inode 
475 .I filespec
476 is marked as allocated in the inode bitmap.
477 .TP
478 .I undel <inode num> [pathname]
479 Undelete the specified inode number (which must be surrounded by angle
480 brackets) so that it and its blocks are marked in use, and optionally
481 link the recovered inode to the specified pathname.  The 
482 .B e2fsck
483 command should always be run after using the 
484 .B undel
485 command to recover deleted files.
486 .IP
487 Note that if you are recovering a large number of deleted files, linking
488 the inode to a directory may require the directory to be expanded, which
489 could allocate a block that had been used by one of the
490 yet-to-be-undeleted files.  So it is safer to undelete all of the 
491 inodes without specifying a destination pathname, and then in a separate
492 pass, use the debugfs
493 .B link
494 command to link the inode to the destination pathname, or use 
495 .B e2fsck
496 to check the filesystem and link all of the recovered inodes to the
497 lost+found directory.
498 .TP
499 .I unlink pathname
500 Remove the link specified by 
501 .I pathname 
502 to an inode.  Note this does not adjust the inode reference counts.
503 .TP
504 .I write source_file out_file
505 Create a file in the filesystem named
506 .IR out_file ,
507 and copy the contents of
508 .I source_file
509 into the destination file.
510 .SH ENVIRONMENT VARIABLES
511 .TP
512 .B DEBUGFS_PAGER, PAGER
513 The
514 .BR debugfs (8)
515 program always pipes the output of the some commands through a
516 pager program.  These commands include: 
517 .IR show_super_stats ,
518 .IR list_directory ,
519 .IR show_inode_info ,
520 .IR list_deleted_inodes ,
521 and
522 .IR htree_dump .
523 The specific pager can explicitly specified by the
524 .B DEBUGFS_PAGER
525 environment variable, and if it is not set, by the
526 .B PAGER
527 environment variable.  
528 .IP
529 Note that since a pager is always used, the 
530 .BR less (1)
531 pager is not particularly appropriate, since it clears the screen before
532 displaying the output of the command and clears the output the screen
533 when the pager is exited.  Many users prefer to use the 
534 .BR less (1)
535 pager for most purposes, which is why the 
536 .B DEBUGFS_PAGER 
537 environment variable is available to override the more general
538 .B PAGER
539 environment variable.
540 .SH AUTHOR
541 .B debugfs
542 was written by Theodore Ts'o <tytso@mit.edu>.
543 .SH SEE ALSO
544 .BR dumpe2fs (8),
545 .BR tune2fs (8),
546 .BR e2fsck (8),
547 .BR mke2fs (8)