Whamcloud - gitweb
Add an option to debugfs to open filesystems in exclusive mode
[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 number,
94 rather than the default (1).  If you give a
95 .I -s
96 option, you must also give a
97 .I -b
98 option.
99 .TP
100 .I -f cmd_file
101 Causes 
102 .B debugfs
103 to read in commands from 
104 .IR cmd_file , 
105 and execute them.  When 
106 .B debugfs
107 is finished executing those commands, it will exit.
108 .TP 
109 .I -R request
110 Causes 
111 .B debugfs
112 to execute the single command 
113 .IR request ,
114 and then exit.
115 .TP
116 .I -V
117 print the version number of 
118 .B debugfs
119 and exit.
120 .SH SPECIFYING FILES
121 Many
122 .B debugfs
123 commands take a
124 .I filespec
125 as an argument to specify an inode (as opposed to a pathname) 
126 in the filesystem which is currently opened by 
127 .BR debugfs . 
128 The
129 .I filespec
130 argument may be specified in two forms.  The first form is an inode 
131 number surrounded by angle brackets, e.g., 
132 .IR <2> .
133 The second form is a pathname; if the pathname is prefixed by a forward slash
134 ('/'), then it is interpreted relative to the root of the filesystem 
135 which is currently opened by 
136 .BR debugfs .
137 If not, the pathname is 
138 interpreted relative to the current working directory as maintained by 
139 .BR debugfs .  
140 This may be modified by using the 
141 .B debugfs
142 command
143 .IR cd .
144 .\" 
145 .\"
146 .\"
147 .SH COMMANDS
148 This is a list of the commands which 
149 .B debugfs
150 supports.
151 .TP
152 .I bmap filespec logical_block
153 Print the physical block number corresponding to the logical block number
154 .I logical_block
155 in the inode
156 .IR filespec .
157 .TP
158 .I cat filespec
159 Dump the contents of the inode 
160 .I filespec
161 to stdout.
162 .TP
163 .I cd filespec
164 Change the current working directory to 
165 .IR filespec .
166 .TP
167 .I chroot filespec
168 Change the root directory to be the directory 
169 .IR filespec .
170 .TP
171 .I close
172 Close the currently open file system.
173 .TP
174 .I clri file
175 Clear the contents of the inode 
176 .IR file .
177 .TP
178 .I dump [-p] filspec out_file
179 Dump the contents of the inode 
180 .I filespec
181 to the output file 
182 .IR out_file .  
183 If the 
184 .I -p 
185 option is given set the owner, group and permissions information on 
186 .I out_file 
187 to match 
188 .IR filespec .
189 .TP
190 .I expand_dir filespec
191 Expand the directory
192 .IR filespec .
193 .TP
194 .I feature [fs_feature] [-fs_feature] ...
195 Set or clear various filesystem features in the superblock.  After setting
196 or clearing any filesystem features that were requested, print the current
197 state of the filesystem feature set.
198 .TP
199 .I find_free_block [count [goal]]
200 Find the first 
201 .I count
202 free blocks, starting from
203 .I goal
204 and allocate it.
205 .TP
206 .I find_free_inode [dir [mode]]
207 Find a free inode and allocate it.  If present, 
208 .I dir
209 specifies the inode number of the directory 
210 which the inode is to be located.  The second 
211 optional argument
212 .I mode
213 specifies the permissions of the new inode.  (If the directory bit is set
214 on the mode, the allocation routine will function differently.)
215 .TP
216 .I freeb block [count]
217 Mark the block number
218 .I block
219 as not allocated.
220 If the optional argument 
221 .I count 
222 is present, then 
223 .I count
224 blocks starting at block number
225 .I block
226 will be marked as not allocated.
227 .TP
228 .I freei filespec
229 Free the inode specified by 
230 .IR filespec .
231 .TP
232 .I help
233 Print a list of commands understood by 
234 .BR debugfs (8).
235 .TP
236 .I icheck block ...
237 Print a listing of the inodes which use the one or more blocks specified
238 on the command line.
239 .TP
240 .I imap filespec
241 Print the location of the inode data structure (in the inode table) 
242 of the inode
243 .IR filespec .
244 .TP
245 .I init_filesys device blocksize
246 Create an ext2 file system on
247 .I device
248 with device size
249 .IR blocksize .
250 Note that this does not fully initialize all of the data structures; 
251 to do this, use the 
252 .BR mke2fs (8)
253 program.  This is just a call to the low-level library, which sets up
254 the superblock and block descriptors.
255 .TP
256 .I kill_file filespec
257 Deallocate the inode 
258 .I filespec
259 and its blocks.  Note that this does not remove any directory
260 entries (if any) to this inode.  See the 
261 .BR rm (1)
262 command if you wish to unlink a file.
263 .TP
264 .I lcd directory
265 Change the current working directory of the
266 .B debugfs
267 process to
268 .I directory
269 on the native filesystem.
270 .TP
271 .I ln filespec dest_file
272 Create a link named 
273 .I dest_file
274 which is a link to 
275 .IR filespec .
276 Note this does not adjust the inode reference counts.
277 .TP
278 .I logdump [-acs] [-b<block>] [-i<filespec>] [-f<journal_file>] [output_file]
279 Dump the contents of the ext3 journal.  By default, the journal inode as
280 specified in the superblock.  However, this can be overridden with the 
281 .I \-i
282 option, which uses an inode specifier to specify the journal to be
283 used.  A file containing journal data can be specified using the
284 .I \-f
285 option.   Finally, the 
286 .I \-s
287 option utilizes the backup information in the superblock to locate the
288 journal.
289 .IP
290 The 
291 .I \-a
292 option causes the 
293 .I logdump
294 program to print the contents of all of the descriptor blocks.
295 The 
296 .I \-b
297 option causes 
298 .I logdump
299 to print all journal records that are refer to the specified block. 
300 The 
301 .I \-c
302 option will print out the contents of all of the data blocks selected by
303 the 
304 .I \-a
305 and 
306 .I \-b
307 options.
308 .TP
309 .I ls [-l] [-d] filespec
310 Print a listing of the files in the directory
311 .IR filespec .
312 The 
313 .I \-l
314 flag will list files using a more verbose format.
315 The
316 .I \-d
317 flag will list deleted entries in the directory.
318 .TP
319 .I modify_inode filespec
320 Modify the contents of the inode structure in the inode
321 .IR filespec .
322 .TP
323 .I mkdir filespec
324 Make a directory.
325 .TP
326 .I mknod filespec [p|[[c|b] major minor]]
327 Create a special device file (a named pipe, character or block device).
328 If a character or block device is to be made, the 
329 .I major
330 and
331 .I minor
332 device numbers must be specified.
333 .TP
334 .I ncheck inode_num ...
335 Take the requested list of inode numbers, and print a listing of pathnames
336 to those inodes.
337 .TP
338 .I open [-w] [-e] [-f] [-i] [-c] [-b blocksize] [-s superblock] device
339 Open a filesystem for editing.  The 
340 .I -f 
341 flag forces the filesystem to be opened even if there are some unknown 
342 or incompatible filesystem features which would normally 
343 prevent the filesystem from being opened.  The
344 .I -e
345 flag causes the filesystem to be opened in exclusive mode.  The
346 .IR -b ", " -c ", " -i ", " -s ", and " -w
347 options behave the same as the command-line options to 
348 .BR debugfs .
349 .TP
350 .I pwd
351 Print the current working directory.
352 .TP
353 .I quit
354 Quit
355 .B debugfs
356 .TP
357 .I rdump directory destination
358 Recursively dump
359 .I directory
360 and all its contents (including regular files, symbolic links, and other
361 directories) into the named
362 .I destination
363 which should be an existing directory on the native filesystem.
364 .TP
365 .I rm pathname
366 Unlink 
367 .IR pathname .
368 If this causes the inode pointed to by 
369 .I pathname
370 to have no other references, deallocate the file.  This command functions
371 as the unlink() system call.
372 .I 
373 .TP
374 .I rmdir filespec
375 Remove the directory
376 .IR filespec .
377 .TP
378 .I setb block [count]
379 Mark the block number
380 .I block
381 as allocated.
382 If the optional argument 
383 .I count 
384 is present, then 
385 .I count
386 blocks starting at block number
387 .I block
388 will be marked as allocated.
389 .TP
390 .I seti filespec
391 Mark inode 
392 .I filespec
393 as in use in the inode bitmap.
394 .TP
395 .I set_inode_field filespec field value
396 Modify the inode specified by 
397 .I filespec
398 so that the inode field
399 .I field
400 has value 
401 .I value.
402 The list of valid inode fields which can be set via this command 
403 can be displayed by using the command:
404 .B set_inode_field -l
405 .TP
406 .I set_super_value field value
407 Set the superblock field
408 .I field
409 to 
410 .I value.
411 The list of valid superblock fields which can be set via this command 
412 can be displayed by using the command:
413 .B set_super_value -l
414 .TP
415 .I show_super_stats [-h]
416 List the contents of the super block and the block group descriptors.  If the
417 .I -h
418 flag is given, only print out the superblock contents.
419 .TP
420 .I stat filespec
421 Display the contents of the inode structure of the inode
422 .IR filespec .
423 .TP
424 .I testb block [count]
425 Test if the block number
426 .I block
427 is marked as allocated in the block bitmap.
428 If the optional argument 
429 .I count 
430 is present, then 
431 .I count
432 blocks starting at block number
433 .I block
434 will be tested.
435 .TP
436 .I testi filespec
437 Test if the inode 
438 .I filespec
439 is marked as allocated in the inode bitmap.
440 .TP
441 .I unlink pathname
442 Remove the link specified by 
443 .I pathname 
444 to an inode.  Note this does not adjust the inode reference counts.
445 .TP
446 .I write source_file out_file
447 Create a file in the filesystem named
448 .IR out_file ,
449 and copy the contents of
450 .I source_file
451 into the destination file.
452 .SH ENVIRONMENT VARIABLES
453 .TP
454 .B DEBUGFS_PAGER, PAGER
455 The
456 .BR debugfs (8)
457 program always pipes the output of the some commands through a
458 pager program.  These commands include: 
459 .IR show_super_stats ,
460 .IR list_directory ,
461 .IR show_inode_info ,
462 .IR list_deleted_inodes ,
463 and
464 .IR htree_dump .
465 The specific pager can explicitly specified by the
466 .B DEBUGFS_PAGER
467 environment variable, and if it is not set, by the
468 .B PAGER
469 environment variable.  
470 .IP
471 Note that since a pager is always used, the 
472 .BR less (1)
473 pager is not particularly appropriate, since it clears the screen before
474 displaying the output of the command and clears the output the screen
475 when the pager is exited.  Many users prefer to use the 
476 .BR less (1)
477 pager for most purposes, which is why the 
478 .B DEBUGFS_PAGER 
479 environment variable is available to override the more general
480 .B PAGER
481 environment variable.
482 .SH AUTHOR
483 .B debugfs
484 was written by Theodore Ts'o <tytso@mit.edu>.
485 .SH SEE ALSO
486 .BR dumpe2fs (8),
487 .BR e2fsck (8),
488 .BR mke2fs (8)