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.
5 .TH DEBUGFS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
7 debugfs \- ext2/ext3 file system debugger
39 program is an interactive file system debugger. It can be used to
40 examine and change the state of an ext2 file system.
43 is the special file corresponding to the device containing the ext2
44 file system (e.g /dev/hdXX).
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.
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.
60 represents an ext2 image file created by the
62 program. Since the ext2 image file only contains the superblock, block
63 group descriptor, block and inode allocation bitmaps, and
66 commands will not function properly.
68 no safety checks are in place, and
70 may fail in interesting ways if commands such as
72 etc. are tried without specifying the
78 is a debugging tool. It has rough edges!
80 .I -d data_source_device
83 option, specifies that
85 should be used when reading blocks not found in the ext2 image file.
86 This includes data, directory, and indirect blocks.
89 Forces the use of the given block size for the file system, rather than
90 detecting the correct block size as normal.
93 Causes the file system superblock to be read from the given block number,
94 rather than the default (1). If you give a
96 option, you must also give a
103 to read in commands from
105 and execute them. When
107 is finished executing those commands, it will exit.
112 to execute the single command
117 print the version number of
125 as an argument to specify an inode (as opposed to a pathname)
126 in the filesystem which is currently opened by
130 argument may be specified in two forms. The first form is an inode
131 number surrounded by angle brackets, e.g.,
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
137 If not, the pathname is
138 interpreted relative to the current working directory as maintained by
140 This may be modified by using the
148 This is a list of the commands which
152 .I bmap filespec logical_block
153 Print the physical block number corresponding to the logical block number
159 Dump the contents of the inode
164 Change the current working directory to
168 Change the root directory to be the directory
172 Close the currently open file system.
175 Clear the contents of the inode
178 .I dump [-p] filspec out_file
179 Dump the contents of the inode
185 option is given set the owner, group and permissions information on
190 .I expand_dir filespec
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.
199 .I find_free_block [count [goal]]
202 free blocks, starting from
206 .I find_free_inode [dir [mode]]
207 Find a free inode and allocate it. If present,
209 specifies the inode number of the directory
210 which the inode is to be located. The second
213 specifies the permissions of the new inode. (If the directory bit is set
214 on the mode, the allocation routine will function differently.)
216 .I freeb block [count]
217 Mark the block number
220 If the optional argument
224 blocks starting at block number
226 will be marked as not allocated.
229 Free the inode specified by
233 Print a list of commands understood by
237 Print a listing of the inodes which use the one or more blocks specified
241 Print the location of the inode data structure (in the inode table)
245 .I init_filesys device blocksize
246 Create an ext2 file system on
250 Note that this does not fully initialize all of the data structures;
253 program. This is just a call to the low-level library, which sets up
254 the superblock and block descriptors.
256 .I kill_file filespec
259 and its blocks. Note that this does not remove any directory
260 entries (if any) to this inode. See the
262 command if you wish to unlink a file.
265 Change the current working directory of the
269 on the native filesystem.
271 .I ln filespec dest_file
276 Note this does not adjust the inode reference counts.
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
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
287 option utilizes the backup information in the superblock to locate the
294 program to print the contents of all of the descriptor blocks.
299 to print all journal records that are refer to the specified block.
302 option will print out the contents of all of the data blocks selected by
309 .I ls [-l] [-d] [-p] filespec
310 Print a listing of the files in the directory
314 flag will list files using a more verbose format.
317 flag will list deleted entries in the directory.
320 flag will list the files in a format which is more easily parsable by
321 scripts, as well as making it more clear when there are spaces or other
322 non-prinitng characters at the end of filenames.
324 .I modify_inode filespec
325 Modify the contents of the inode structure in the inode
331 .I mknod filespec [p|[[c|b] major minor]]
332 Create a special device file (a named pipe, character or block device).
333 If a character or block device is to be made, the
337 device numbers must be specified.
339 .I ncheck inode_num ...
340 Take the requested list of inode numbers, and print a listing of pathnames
343 .I open [-w] [-e] [-f] [-i] [-c] [-b blocksize] [-s superblock] device
344 Open a filesystem for editing. The
346 flag forces the filesystem to be opened even if there are some unknown
347 or incompatible filesystem features which would normally
348 prevent the filesystem from being opened. The
350 flag causes the filesystem to be opened in exclusive mode. The
351 .IR -b ", " -c ", " -i ", " -s ", and " -w
352 options behave the same as the command-line options to
356 Print the current working directory.
362 .I rdump directory destination
365 and all its contents (including regular files, symbolic links, and other
366 directories) into the named
368 which should be an existing directory on the native filesystem.
373 If this causes the inode pointed to by
375 to have no other references, deallocate the file. This command functions
376 as the unlink() system call.
383 .I setb block [count]
384 Mark the block number
387 If the optional argument
391 blocks starting at block number
393 will be marked as allocated.
395 .I set_block_group bgnum field value
396 Modify the block group descriptor specified by
398 so that the block group descriptor field
406 as in use in the inode bitmap.
408 .I set_inode_field filespec field value
409 Modify the inode specified by
411 so that the inode field
415 The list of valid inode fields which can be set via this command
416 can be displayed by using the command:
417 .B set_inode_field -l
419 .I set_super_value field value
420 Set the superblock field
424 The list of valid superblock fields which can be set via this command
425 can be displayed by using the command:
426 .B set_super_value -l
428 .I show_super_stats [-h]
429 List the contents of the super block and the block group descriptors. If the
431 flag is given, only print out the superblock contents.
434 Display the contents of the inode structure of the inode
437 .I testb block [count]
438 Test if the block number
440 is marked as allocated in the block bitmap.
441 If the optional argument
445 blocks starting at block number
452 is marked as allocated in the inode bitmap.
454 .I undel <inode num> [pathname]
455 Undelete the specified inode number (which must be surrounded by angle
456 brackets) so that it and its blocks are marked in use, and optionally
457 link the recovered inode to the specified pathname. The
459 command should always be run after using the
461 command to recover deleted files.
463 Note that if you are recovering a large number of deleted files, linking
464 the inode to a directory may require the directory to be expanded, which
465 could allocate a block that had been used by one of the
466 yet-to-be-undeleted files. So it is safer to undelete all of the
467 inodes without specifying a destination pathname, and then in a separate
468 pass, use the debugfs
470 command to link the inode to the destination pathname, or use
472 to check the filesystem and link all of the recovered inodes to the
476 Remove the link specified by
478 to an inode. Note this does not adjust the inode reference counts.
480 .I write source_file out_file
481 Create a file in the filesystem named
483 and copy the contents of
485 into the destination file.
486 .SH ENVIRONMENT VARIABLES
488 .B DEBUGFS_PAGER, PAGER
491 program always pipes the output of the some commands through a
492 pager program. These commands include:
493 .IR show_super_stats ,
495 .IR show_inode_info ,
496 .IR list_deleted_inodes ,
499 The specific pager can explicitly specified by the
501 environment variable, and if it is not set, by the
503 environment variable.
505 Note that since a pager is always used, the
507 pager is not particularly appropriate, since it clears the screen before
508 displaying the output of the command and clears the output the screen
509 when the pager is exited. Many users prefer to use the
511 pager for most purposes, which is why the
513 environment variable is available to override the more general
515 environment variable.
518 was written by Theodore Ts'o <tytso@mit.edu>.