| 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 "March 2025" "E2fsprogs version 1.47.4" |
| 6 |
.SH NAME |
| 7 |
debugfs \- ext2/ext3/ext4 file system debugger |
| 8 |
.SH SYNOPSIS |
| 9 |
.B debugfs |
| 10 |
[ |
| 11 |
.B \-DVwcin |
| 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 |
.B \-z |
| 35 |
.I undo_file |
| 36 |
] |
| 37 |
[ |
| 38 |
device |
| 39 |
] |
| 40 |
.SH DESCRIPTION |
| 41 |
The |
| 42 |
.B debugfs |
| 43 |
program is an interactive file system debugger. It can be used to |
| 44 |
examine and change the state of an ext2, ext3, or ext4 file system. |
| 45 |
.PP |
| 46 |
.I device |
| 47 |
is a block device (e.g., /dev/sdXX) or a file containing the file system. |
| 48 |
.SH OPTIONS |
| 49 |
.TP |
| 50 |
.I \-w |
| 51 |
Specifies that the file system should be opened in read-write mode. |
| 52 |
Without this option, the file system is opened in read-only mode. |
| 53 |
.TP |
| 54 |
.I \-n |
| 55 |
Disables metadata checksum verification. This should only be used if |
| 56 |
you believe the metadata to be correct despite the complaints of |
| 57 |
e2fsprogs. |
| 58 |
.TP |
| 59 |
.I \-c |
| 60 |
Specifies that the file system should be opened in catastrophic mode, in |
| 61 |
which the inode and group bitmaps are not read initially. This can be |
| 62 |
useful for file systems with significant corruption, but because of this, |
| 63 |
catastrophic mode forces the file system to be opened read-only. |
| 64 |
.TP |
| 65 |
.I \-i |
| 66 |
Specifies that |
| 67 |
.I device |
| 68 |
represents an ext2 image file created by the |
| 69 |
.B e2image |
| 70 |
program. Since the ext2 image file only contains the superblock, block |
| 71 |
group descriptor, block and inode allocation bitmaps, and |
| 72 |
the inode table, many |
| 73 |
.B debugfs |
| 74 |
commands will not function properly. |
| 75 |
.B Warning: |
| 76 |
no safety checks are in place, and |
| 77 |
.B debugfs |
| 78 |
may fail in interesting ways if commands such as |
| 79 |
.IR ls ", " dump , |
| 80 |
etc. are tried without specifying the |
| 81 |
.I data_source_device |
| 82 |
using the |
| 83 |
.I \-d |
| 84 |
option. |
| 85 |
.B debugfs |
| 86 |
is a debugging tool. It has rough edges! |
| 87 |
.TP |
| 88 |
.I \-d data_source_device |
| 89 |
Used with the |
| 90 |
.I \-i |
| 91 |
option, specifies that |
| 92 |
.I data_source_device |
| 93 |
should be used when reading blocks not found in the ext2 image file. |
| 94 |
This includes data, directory, and indirect blocks. |
| 95 |
.TP |
| 96 |
.I \-b blocksize |
| 97 |
Forces the use of the given block size (in bytes) for the file system, |
| 98 |
rather than detecting the correct block size automatically. (This |
| 99 |
option is rarely needed; it is used primarily when the file system is |
| 100 |
extremely badly damaged/corrupted.) |
| 101 |
.TP |
| 102 |
.I \-s superblock |
| 103 |
Causes the file system superblock to be read from the given block |
| 104 |
number, instead of using the primary superblock (located at an offset of |
| 105 |
1024 bytes from the beginning of the file system). If you specify the |
| 106 |
.I \-s |
| 107 |
option, you must also provide the blocksize of the file system via the |
| 108 |
.I \-b |
| 109 |
option. (This |
| 110 |
option is rarely needed; it is used primarily when the file system is |
| 111 |
extremely badly damaged/corrupted.) |
| 112 |
.TP |
| 113 |
.I \-f cmd_file |
| 114 |
Causes |
| 115 |
.B debugfs |
| 116 |
to read in commands from |
| 117 |
.IR cmd_file , |
| 118 |
and execute them. When |
| 119 |
.B debugfs |
| 120 |
is finished executing those commands, it will exit. |
| 121 |
.TP |
| 122 |
.I \-D |
| 123 |
Causes |
| 124 |
.B debugfs |
| 125 |
to open the device using Direct I/O, bypassing the buffer cache. Note |
| 126 |
that some Linux devices, notably device mapper as of this writing, do |
| 127 |
not support Direct I/O. |
| 128 |
.TP |
| 129 |
.I -R request |
| 130 |
Causes |
| 131 |
.B debugfs |
| 132 |
to execute the single command |
| 133 |
.IR request , |
| 134 |
and then exit. |
| 135 |
.TP |
| 136 |
.I \-V |
| 137 |
print the version number of |
| 138 |
.B debugfs |
| 139 |
and exit. |
| 140 |
.TP |
| 141 |
.BI \-z " undo_file" |
| 142 |
Before overwriting a file system block, write the old contents of the block to |
| 143 |
an undo file. This undo file can be used with |
| 144 |
.BR e2undo (8) |
| 145 |
to restore the old |
| 146 |
contents of the file system should something go wrong. If the empty string is |
| 147 |
passed as the undo_file argument, the undo file will be written to a file named |
| 148 |
debugfs-\fIdevice\fR.e2undo in the directory specified via the |
| 149 |
\fIE2FSPROGS_UNDO_DIR\fR environment variable. |
| 150 |
|
| 151 |
WARNING: The undo file cannot be used to recover from a power or system crash. |
| 152 |
.SH SPECIFYING FILES |
| 153 |
Many |
| 154 |
.B debugfs |
| 155 |
commands take a |
| 156 |
.I filespec |
| 157 |
as an argument to specify an inode (as opposed to a pathname) |
| 158 |
in the file system which is currently opened by |
| 159 |
.BR debugfs . |
| 160 |
The |
| 161 |
.I filespec |
| 162 |
argument may be specified in two forms. The first form is an inode |
| 163 |
number surrounded by angle brackets, e.g., |
| 164 |
.IR <2> . |
| 165 |
The second form is a pathname; if the pathname is prefixed by a forward slash |
| 166 |
('/'), then it is interpreted relative to the root of the file system |
| 167 |
which is currently opened by |
| 168 |
.BR debugfs . |
| 169 |
If not, the pathname is |
| 170 |
interpreted relative to the current working directory as maintained by |
| 171 |
.BR debugfs . |
| 172 |
This may be modified by using the |
| 173 |
.B debugfs |
| 174 |
command |
| 175 |
.IR cd . |
| 176 |
.\" |
| 177 |
.\" |
| 178 |
.\" |
| 179 |
.SH COMMANDS |
| 180 |
This is a list of the commands which |
| 181 |
.B debugfs |
| 182 |
supports. |
| 183 |
.TP |
| 184 |
.BI blocks " filespec" |
| 185 |
Print the blocks used by the inode |
| 186 |
.I filespec |
| 187 |
to stdout. |
| 188 |
.TP |
| 189 |
.BI bmap " [ \-a ] filespec logical_block [physical_block]" |
| 190 |
Print or set the physical block number corresponding to the logical block number |
| 191 |
.I logical_block |
| 192 |
in the inode |
| 193 |
.IR filespec . |
| 194 |
If the |
| 195 |
.I \-a |
| 196 |
flag is specified, try to allocate a block if necessary. |
| 197 |
.TP |
| 198 |
.BI block_dump " '[ \-x ] [\-f filespec] block_num" |
| 199 |
Dump the file system block given by |
| 200 |
.I block_num |
| 201 |
in hex and ASCII format to the console. If the |
| 202 |
.I \-f |
| 203 |
option is specified, the block number is relative to the start of the given |
| 204 |
.BR filespec . |
| 205 |
If the |
| 206 |
.I \-x |
| 207 |
option is specified, the block is interpreted as an extended attribute |
| 208 |
block and printed to show the structure of extended attribute data |
| 209 |
structures. |
| 210 |
.TP |
| 211 |
.BI cat " filespec" |
| 212 |
Dump the contents of the inode |
| 213 |
.I filespec |
| 214 |
to stdout. |
| 215 |
.TP |
| 216 |
.BI cd " filespec" |
| 217 |
Change the current working directory to |
| 218 |
.IR filespec . |
| 219 |
.TP |
| 220 |
.BI chroot " filespec" |
| 221 |
Change the root directory to be the directory |
| 222 |
.IR filespec . |
| 223 |
.TP |
| 224 |
.BI close " [\-a]" |
| 225 |
Close the currently open file system. If the |
| 226 |
.I \-a |
| 227 |
option is specified, write out any changes to the superblock and block |
| 228 |
group descriptors to all of the backup superblocks, not just to the |
| 229 |
master superblock. |
| 230 |
.TP |
| 231 |
.BI clri " filespec" |
| 232 |
Clear the contents of the inode |
| 233 |
.IR filespec . |
| 234 |
.TP |
| 235 |
.BI copy_inode " source_inode destination_inode" |
| 236 |
Copy the contents of the inode structure in |
| 237 |
.I source_inode |
| 238 |
and use it to overwrite the inode structure at |
| 239 |
.IR destination_inode . |
| 240 |
.TP |
| 241 |
.BI dirsearch " filespec filename" |
| 242 |
Search the directory |
| 243 |
.I filespec |
| 244 |
for |
| 245 |
.IR filename . |
| 246 |
.TP |
| 247 |
.BI dirty " [\-clean]" |
| 248 |
Mark the file system as dirty, so that the superblocks will be written on exit. |
| 249 |
Additionally, clear the superblock's valid flag, or set it if |
| 250 |
.I -clean |
| 251 |
is specified. |
| 252 |
.TP |
| 253 |
.BI dump " [\-p] filespec out_file" |
| 254 |
Dump the contents of the inode |
| 255 |
.I filespec |
| 256 |
to the output file |
| 257 |
.IR out_file . |
| 258 |
If the |
| 259 |
.I -p |
| 260 |
option is given set the owner, group and permissions information on |
| 261 |
.I out_file |
| 262 |
to match |
| 263 |
.IR filespec . |
| 264 |
.TP |
| 265 |
.BI dump_mmp " [mmp_block]" |
| 266 |
Display the multiple-mount protection (mmp) field values. If |
| 267 |
.I mmp_block |
| 268 |
is specified then verify and dump the MMP values from the given block |
| 269 |
number, otherwise use the |
| 270 |
.B s_mmp_block |
| 271 |
field in the superblock to locate and use the existing MMP block. |
| 272 |
.TP |
| 273 |
.BI dx_hash " [\-cv] [\-h hash_alg] [\-s hash_seed] filename" |
| 274 |
Calculate the directory hash of |
| 275 |
.IR filename . |
| 276 |
The |
| 277 |
.I \-c |
| 278 |
option will casefold the filename before calculating the hash. The |
| 279 |
.I \-v |
| 280 |
option will make the |
| 281 |
.B dx_hash |
| 282 |
command more verbose and print the hash algorithm and hash seed to |
| 283 |
calculate the hash. |
| 284 |
If a file system is open, use the hash_seed and |
| 285 |
default hash_algorithm used by the file system, although these can be |
| 286 |
overridden by the |
| 287 |
.I \-h |
| 288 |
and |
| 289 |
.I \-s |
| 290 |
options. |
| 291 |
The hash algorithm specified with |
| 292 |
.I \-h |
| 293 |
may be |
| 294 |
.BR legacy , " half_md4" ", or " tea . |
| 295 |
The hash seed specified with |
| 296 |
.I \-s |
| 297 |
must be in UUID format. |
| 298 |
.TP |
| 299 |
.BI dump_extents " [\-n] [\-l] filespec" |
| 300 |
Dump the extent tree of the inode |
| 301 |
.IR filespec . |
| 302 |
The |
| 303 |
.I -n |
| 304 |
flag will cause |
| 305 |
.B dump_extents |
| 306 |
to only display the interior nodes in the extent tree. The |
| 307 |
.I \-l |
| 308 |
flag will cause |
| 309 |
.B dump_extents |
| 310 |
to only display the leaf nodes in the extent tree. |
| 311 |
.IP |
| 312 |
(Please note that the length and range of blocks for the last extent in |
| 313 |
an interior node is an estimate by the extents library functions, and is |
| 314 |
not stored in file system data structures. Hence, the values displayed |
| 315 |
may not necessarily by accurate and does not indicate a problem or |
| 316 |
corruption in the file system.) |
| 317 |
.TP |
| 318 |
.B dump_unused |
| 319 |
Dump unused blocks which contain non-null bytes. |
| 320 |
.TP |
| 321 |
.BI ea_get " [\-f outfile]|[\-xVC] [\-r] filespec attr_name" |
| 322 |
Retrieve the value of the extended attribute |
| 323 |
.I attr_name |
| 324 |
in the file |
| 325 |
.I filespec |
| 326 |
and write it either to stdout or to \fIoutfile\fR. |
| 327 |
.TP |
| 328 |
.BI ea_list " filespec" |
| 329 |
List the extended attributes associated with the file |
| 330 |
.I filespec |
| 331 |
to standard output. |
| 332 |
.TP |
| 333 |
.BI ea_set " [\-f infile] [\-r] filespec attr_name attr_value" |
| 334 |
Set the value of the extended attribute |
| 335 |
.I attr_name |
| 336 |
in the file |
| 337 |
.I filespec |
| 338 |
to the string value |
| 339 |
.I attr_value |
| 340 |
or read it from \fIinfile\fR. |
| 341 |
.TP |
| 342 |
.BI ea_rm " filespec attr_names..." |
| 343 |
Remove the extended attribute |
| 344 |
.I attr_name |
| 345 |
from the file \fIfilespec\fR. |
| 346 |
.TP |
| 347 |
.BI expand_dir " filespec" |
| 348 |
Expand the directory |
| 349 |
.IR filespec . |
| 350 |
.TP |
| 351 |
.BI fallocate " filespec start_block [end_block]" |
| 352 |
Allocate and map uninitialized blocks into \fIfilespec\fR between |
| 353 |
logical block \fIstart_block\fR and \fIend_block\fR, inclusive. If |
| 354 |
\fIend_block\fR is not supplied, this function maps until it runs out |
| 355 |
of free disk blocks or the maximum file size is reached. Existing |
| 356 |
mappings are left alone. |
| 357 |
.TP |
| 358 |
.BI feature " [fs_feature] [\-fs_feature] ..." |
| 359 |
Set or clear various file system features in the superblock. After setting |
| 360 |
or clearing any file system features that were requested, print the current |
| 361 |
state of the file system feature set. |
| 362 |
.TP |
| 363 |
.BI filefrag " [\-dvr] filespec" |
| 364 |
Print the number of contiguous extents in |
| 365 |
.IR filespec . |
| 366 |
If |
| 367 |
.I filespec |
| 368 |
is a directory and the |
| 369 |
.I \-d |
| 370 |
option is not specified, |
| 371 |
.I filefrag |
| 372 |
will print the number of contiguous extents for each file in |
| 373 |
the directory. The |
| 374 |
.I \-v |
| 375 |
option will cause |
| 376 |
.I filefrag |
| 377 |
print a tabular listing of the contiguous extents in the |
| 378 |
file. The |
| 379 |
.I \-r |
| 380 |
option will cause |
| 381 |
.I filefrag |
| 382 |
to do a recursive listing of the directory. |
| 383 |
.TP |
| 384 |
.BI find_free_block " [count [goal]]" |
| 385 |
Find the first |
| 386 |
.I count |
| 387 |
free blocks, starting from |
| 388 |
.I goal |
| 389 |
and allocate it. Also available as |
| 390 |
.BR ffb . |
| 391 |
.TP |
| 392 |
.BI find_free_inode " [dir [mode]]" |
| 393 |
Find a free inode and allocate it. If present, |
| 394 |
.I dir |
| 395 |
specifies the inode number of the directory |
| 396 |
which the inode is to be located. The second |
| 397 |
optional argument |
| 398 |
.I mode |
| 399 |
specifies the permissions of the new inode. (If the directory bit is set |
| 400 |
on the mode, the allocation routine will function differently.) Also |
| 401 |
available as |
| 402 |
.BR ffi . |
| 403 |
.TP |
| 404 |
.BI freeb " block [count]" |
| 405 |
Mark the block number |
| 406 |
.I block |
| 407 |
as not allocated. |
| 408 |
If the optional argument |
| 409 |
.I count |
| 410 |
is present, then |
| 411 |
.I count |
| 412 |
blocks starting at block number |
| 413 |
.I block |
| 414 |
will be marked as not allocated. |
| 415 |
.TP |
| 416 |
.BI freefrag " [\-c chunk_kb]" |
| 417 |
Report free space fragmentation on the currently open file system. |
| 418 |
If the |
| 419 |
.I \-c |
| 420 |
option is specified then the filefrag command will print how many free |
| 421 |
chunks of size |
| 422 |
.I chunk_kb |
| 423 |
can be found in the file system. The chunk size must be a power of two |
| 424 |
and be larger than the file system block size. |
| 425 |
.TP |
| 426 |
.BI freei " filespec [num]" |
| 427 |
Free the inode specified by |
| 428 |
.IR filespec . |
| 429 |
If |
| 430 |
.I num |
| 431 |
is specified, also clear num\-1 inodes after the specified inode. |
| 432 |
.TP |
| 433 |
.BI get_quota " quota_type id" |
| 434 |
Display quota information for given quota type (user, group, or project) and ID. |
| 435 |
.TP |
| 436 |
.B help |
| 437 |
Print a list of commands understood by |
| 438 |
.BR debugfs . |
| 439 |
.TP |
| 440 |
.BI htree_dump " filespec" |
| 441 |
Dump the hash-indexed directory |
| 442 |
.IR filespec , |
| 443 |
showing its tree structure. |
| 444 |
.TP |
| 445 |
.BI icheck " block ..." |
| 446 |
Print a listing of the inodes which use the one or more blocks specified |
| 447 |
on the command line. |
| 448 |
.TP |
| 449 |
.BI inode_dump " [\-b]|[\-e]|[\-x] filespec" |
| 450 |
Print the contents of the inode data structure in hex and ASCII format. |
| 451 |
The |
| 452 |
.I \-b |
| 453 |
option causes the command to only dump the contents of the |
| 454 |
.B i_blocks |
| 455 |
array. The |
| 456 |
.I \-e |
| 457 |
option causes the command to only dump the contents of the extra inode |
| 458 |
space, which is used to store in-line extended attributes. The |
| 459 |
.I \-x |
| 460 |
option causes the command to dump the extra inode space interpreted and |
| 461 |
extended attributes. This is useful to debug corrupted inodes |
| 462 |
containing extended attributes. |
| 463 |
.TP |
| 464 |
.BI imap " filespec" |
| 465 |
Print the location of the inode data structure (in the inode table) |
| 466 |
of the inode |
| 467 |
.IR filespec . |
| 468 |
.TP |
| 469 |
.BI init_filesys " device blocksize" |
| 470 |
Create an ext2 file system on |
| 471 |
.I device |
| 472 |
with device size |
| 473 |
.IR blocksize . |
| 474 |
Note that this does not fully initialize all of the data structures; |
| 475 |
to do this, use the |
| 476 |
.BR mke2fs (8) |
| 477 |
program. This is just a call to the low-level library, which sets up |
| 478 |
the superblock and block descriptors. |
| 479 |
.TP |
| 480 |
.B journal_close |
| 481 |
Close the open journal. |
| 482 |
.TP |
| 483 |
.BI journal_open " [\-c] [\-v ver] [\-f ext_jnl]" |
| 484 |
Opens the journal for reading and writing. Journal checksumming can |
| 485 |
be enabled by supplying \fI\-c\fR; checksum formats 2 and 3 can be |
| 486 |
selected with the \fI\-v\fR option. An external journal can be loaded |
| 487 |
from \fIext_jnl\fR. |
| 488 |
.TP |
| 489 |
.B journal_run |
| 490 |
Replay all transactions in the open journal. |
| 491 |
.TP |
| 492 |
.BI journal_write " [\-b blocks] [\-r revoke] [\-c] file" |
| 493 |
Write a transaction to the open journal. The list of blocks to write |
| 494 |
should be supplied as a comma-separated list in \fIblocks\fR; the |
| 495 |
blocks themselves should be readable from \fIfile\fR. A list of |
| 496 |
blocks to revoke can be supplied as a comma-separated list in |
| 497 |
\fIrevoke\fR. By default, a commit record is written at the end; the |
| 498 |
\fI\-c\fR switch writes an uncommitted transaction. |
| 499 |
.TP |
| 500 |
.BI kill_file " filespec" |
| 501 |
Deallocate the inode |
| 502 |
.I filespec |
| 503 |
and its blocks. Note that this does not remove any directory |
| 504 |
entries (if any) to this inode. See the |
| 505 |
.BR rm (1) |
| 506 |
command if you wish to unlink a file. |
| 507 |
.TP |
| 508 |
.BI lcd " directory" |
| 509 |
Change the current working directory of the |
| 510 |
.B debugfs |
| 511 |
process to |
| 512 |
.I directory |
| 513 |
on the native file system. |
| 514 |
.TP |
| 515 |
.BI list_quota " quota_type" |
| 516 |
Display quota information for given quota type (user, group, or project). |
| 517 |
.TP |
| 518 |
.BI ln " filespec dest_file" |
| 519 |
Create a link named |
| 520 |
.I dest_file |
| 521 |
which is a hard link to |
| 522 |
.IR filespec . |
| 523 |
Note this does not adjust the inode reference counts. |
| 524 |
.TP |
| 525 |
.BI logdump " [\-acsOS] [\-b block] [\-n num_trans ] [\-i filespec] [\-f journal_file] [output_file]" |
| 526 |
Dump the contents of the ext3 journal. By default, dump the journal inode as |
| 527 |
specified in the superblock. However, this can be overridden with the |
| 528 |
.I \-i |
| 529 |
option, which dumps the journal from the internal inode given by |
| 530 |
.IR filespec . |
| 531 |
A regular file containing journal data can be specified using the |
| 532 |
.I \-f |
| 533 |
option. Finally, the |
| 534 |
.I \-s |
| 535 |
option utilizes the backup information in the superblock to locate the |
| 536 |
journal. |
| 537 |
.IP |
| 538 |
The |
| 539 |
.I \-S |
| 540 |
option causes |
| 541 |
.B logdump |
| 542 |
to print the contents of the journal superblock. |
| 543 |
.IP |
| 544 |
The |
| 545 |
.I \-a |
| 546 |
option causes the |
| 547 |
.B logdump |
| 548 |
to print the contents of all of the descriptor blocks. |
| 549 |
The |
| 550 |
.I \-b |
| 551 |
option causes |
| 552 |
.B logdump |
| 553 |
to print all journal records that refer to the specified block. |
| 554 |
The |
| 555 |
.I \-c |
| 556 |
option will print out the contents of all of the data blocks selected by |
| 557 |
the |
| 558 |
.I \-a |
| 559 |
and |
| 560 |
.I \-b |
| 561 |
options. |
| 562 |
.IP |
| 563 |
The |
| 564 |
.I \-O |
| 565 |
option causes logdump to display old (checkpointed) journal entries. |
| 566 |
This can be used to try to track down journal problems even after the |
| 567 |
journal has been replayed. |
| 568 |
.IP |
| 569 |
The |
| 570 |
.I \-n |
| 571 |
option causes |
| 572 |
.B logdump |
| 573 |
to continue past a journal block which is missing a magic number. |
| 574 |
Instead, it will stop only when the entire log is printed or after |
| 575 |
.I num_trans |
| 576 |
transactions. |
| 577 |
.TP |
| 578 |
.BI ls " [\-l] [\-c] [\-d] [\-p] [\-r] filespec" |
| 579 |
Print a listing of the files in the directory |
| 580 |
.IR filespec . |
| 581 |
The |
| 582 |
.I \-c |
| 583 |
flag causes directory block checksums (if present) to be displayed. |
| 584 |
The |
| 585 |
.I \-d |
| 586 |
flag will list deleted entries in the directory. |
| 587 |
The |
| 588 |
.I \-l |
| 589 |
flag will list files using a more verbose format. |
| 590 |
The |
| 591 |
.I \-p |
| 592 |
flag will list the files in a format which is more easily parsable by |
| 593 |
scripts, as well as making it more clear when there are spaces or other |
| 594 |
non-printing characters at the end of filenames. |
| 595 |
The |
| 596 |
.I \-r |
| 597 |
flag will force the printing of the filename, even if it is encrypted. |
| 598 |
.TP |
| 599 |
.BI list_deleted_inodes " [limit]" |
| 600 |
List deleted inodes, optionally limited to those deleted within |
| 601 |
.I limit |
| 602 |
seconds ago. Also available as |
| 603 |
.BR lsdel . |
| 604 |
.IP |
| 605 |
This command was useful for recovering from accidental file deletions |
| 606 |
for ext2 file systems. Unfortunately, it is not useful for this purpose |
| 607 |
if the files were deleted using ext3 or ext4, since the inode's |
| 608 |
data blocks are no longer available after the inode is released. |
| 609 |
.TP |
| 610 |
.BI modify_inode " filespec" |
| 611 |
Modify the contents of the inode structure in the inode |
| 612 |
.IR filespec . |
| 613 |
Also available as |
| 614 |
.BR mi . |
| 615 |
.TP |
| 616 |
.BI mkdir " filespec" |
| 617 |
Make a directory. |
| 618 |
.TP |
| 619 |
.BI mknod " filespec [p|[[c|b] major minor]]" |
| 620 |
Create a special device file (a named pipe, character or block device). |
| 621 |
If a character or block device is to be made, the |
| 622 |
.I major |
| 623 |
and |
| 624 |
.I minor |
| 625 |
device numbers must be specified. |
| 626 |
.TP |
| 627 |
.BI ncheck " [\-c] inode_num ..." |
| 628 |
Take the requested list of inode numbers, and print a listing of pathnames |
| 629 |
to those inodes. The |
| 630 |
.I -c |
| 631 |
flag will enable checking the file type information in the directory |
| 632 |
entry to make sure it matches the inode's type. |
| 633 |
.TP |
| 634 |
.BI open " [\-weficD] [\-b blocksize] [\-d image_filename] [\-s superblock] [\-z undo_file] device" |
| 635 |
Open a file system for editing. The |
| 636 |
.I \-f |
| 637 |
flag forces the file system to be opened even if there are some unknown |
| 638 |
or incompatible file system features which would normally |
| 639 |
prevent the file system from being opened. The |
| 640 |
.I \-e |
| 641 |
flag causes the file system to be opened in exclusive mode. The |
| 642 |
.IR \-b ", " \-c ", " \-d ", " \-i ", " \-s ", " \-w ", and " \-D |
| 643 |
options behave the same as the command-line options to |
| 644 |
.BR debugfs . |
| 645 |
.TP |
| 646 |
.B orphan_inodes |
| 647 |
List the orphan inodes in the file system. |
| 648 |
.TP |
| 649 |
.BI punch " filespec start_blk [end_blk]" |
| 650 |
Delete the blocks in the inode ranging from |
| 651 |
.I start_blk |
| 652 |
to |
| 653 |
.IR end_blk . |
| 654 |
If |
| 655 |
.I end_blk |
| 656 |
is omitted then this command will function as a truncate command; that |
| 657 |
is, all of the blocks starting at |
| 658 |
.I start_blk |
| 659 |
through to the end of the file will be deallocated. |
| 660 |
.TP |
| 661 |
.BI symlink " filespec target" |
| 662 |
Make a symbolic link. |
| 663 |
.TP |
| 664 |
.B pwd |
| 665 |
Print the current working directory. |
| 666 |
.TP |
| 667 |
.B quit |
| 668 |
Quit |
| 669 |
.B debugfs |
| 670 |
.TP |
| 671 |
.BI rdump " directory[...] destination" |
| 672 |
Recursively dump |
| 673 |
.IR directory , |
| 674 |
or multiple |
| 675 |
.IR directories , |
| 676 |
and all its contents (including regular files, symbolic links, and other |
| 677 |
directories) into the named |
| 678 |
.IR destination , |
| 679 |
which should be an existing directory on the native file system. |
| 680 |
.TP |
| 681 |
.BI rm " pathname" |
| 682 |
Unlink |
| 683 |
.IR pathname . |
| 684 |
If this causes the inode pointed to by |
| 685 |
.I pathname |
| 686 |
to have no other references, deallocate the file. This command functions |
| 687 |
as the unlink() system call. |
| 688 |
.TP |
| 689 |
.BI rmdir " filespec" |
| 690 |
Remove the directory |
| 691 |
.IR filespec . |
| 692 |
.TP |
| 693 |
.BI setb " block [count]" |
| 694 |
Mark the block number |
| 695 |
.I block |
| 696 |
as allocated. |
| 697 |
If the optional argument |
| 698 |
.I count |
| 699 |
is present, then |
| 700 |
.I count |
| 701 |
blocks starting at block number |
| 702 |
.I block |
| 703 |
will be marked as allocated. |
| 704 |
.TP |
| 705 |
.BI set_block_group " bgnum field value" |
| 706 |
Modify the block group descriptor specified by |
| 707 |
.I bgnum |
| 708 |
so that the block group descriptor field |
| 709 |
.I field |
| 710 |
has value |
| 711 |
.IR value . |
| 712 |
Also available as |
| 713 |
.BR set_bg . |
| 714 |
.TP |
| 715 |
.BI set_current_time " time" |
| 716 |
Set current time in seconds since Unix epoch to use when setting file system |
| 717 |
fields. |
| 718 |
.TP |
| 719 |
.BI seti " filespec [num]" |
| 720 |
Mark inode |
| 721 |
.I filespec |
| 722 |
as in use in the inode bitmap. If |
| 723 |
.I num |
| 724 |
is specified, also set num\-1 inodes after the specified inode. |
| 725 |
.TP |
| 726 |
.BI set_inode_field " filespec field value" |
| 727 |
Modify the inode specified by |
| 728 |
.I filespec |
| 729 |
so that the inode field |
| 730 |
.I field |
| 731 |
has value |
| 732 |
.IR value . |
| 733 |
The list of valid inode fields which can be set via this command |
| 734 |
can be displayed by using the command: |
| 735 |
.B set_inode_field \-l |
| 736 |
Also available as |
| 737 |
.BR sif . |
| 738 |
.TP |
| 739 |
.BI set_mmp_value " field value" |
| 740 |
Modify the multiple-mount protection (MMP) data so that the MMP field |
| 741 |
.I field |
| 742 |
has value |
| 743 |
.IR value . |
| 744 |
The list of valid MMP fields which can be set via this command |
| 745 |
can be displayed by using the command: |
| 746 |
.B set_mmp_value \-l |
| 747 |
Also available as |
| 748 |
.BR smmp . |
| 749 |
.TP |
| 750 |
.BI set_super_value " field value" |
| 751 |
Set the superblock field |
| 752 |
.I field |
| 753 |
to |
| 754 |
.IR value . |
| 755 |
The list of valid superblock fields which can be set via this command |
| 756 |
can be displayed by using the command: |
| 757 |
.B set_super_value \-l |
| 758 |
Also available as |
| 759 |
.BR ssv . |
| 760 |
.TP |
| 761 |
.B show_debugfs_params |
| 762 |
Display |
| 763 |
.B debugfs |
| 764 |
parameters such as information about currently opened file system. |
| 765 |
.TP |
| 766 |
.BI show_super_stats " [\-h]" |
| 767 |
List the contents of the super block and the block group descriptors. If the |
| 768 |
.I \-h |
| 769 |
flag is given, only print out the superblock contents. Also available as |
| 770 |
.BR stats . |
| 771 |
.TP |
| 772 |
.BI stat " filespec" |
| 773 |
Display the contents of the inode structure of the inode |
| 774 |
.IR filespec . |
| 775 |
.TP |
| 776 |
.B supported_features |
| 777 |
Display file system features supported by this version of |
| 778 |
.BR debugfs . |
| 779 |
.TP |
| 780 |
.BI testb " block [count]" |
| 781 |
Test if the block number |
| 782 |
.I block |
| 783 |
is marked as allocated in the block bitmap. |
| 784 |
If the optional argument |
| 785 |
.I count |
| 786 |
is present, then |
| 787 |
.I count |
| 788 |
blocks starting at block number |
| 789 |
.I block |
| 790 |
will be tested. |
| 791 |
.TP |
| 792 |
.BI testi " filespec" |
| 793 |
Test if the inode |
| 794 |
.I filespec |
| 795 |
is marked as allocated in the inode bitmap. |
| 796 |
.TP |
| 797 |
.BI undel " <inode_number> [pathname]" |
| 798 |
Undelete the specified inode number (which must be surrounded by angle |
| 799 |
brackets) so that it and its blocks are marked in use, and optionally |
| 800 |
link the recovered inode to the specified pathname. The |
| 801 |
.B e2fsck |
| 802 |
command should always be run after using the |
| 803 |
.B undel |
| 804 |
command to recover deleted files. |
| 805 |
.IP |
| 806 |
Note that if you are recovering a large number of deleted files, linking |
| 807 |
the inode to a directory may require the directory to be expanded, which |
| 808 |
could allocate a block that had been used by one of the |
| 809 |
yet-to-be-undeleted files. So it is safer to undelete all of the |
| 810 |
inodes without specifying a destination pathname, and then in a separate |
| 811 |
pass, use the debugfs |
| 812 |
.B link |
| 813 |
command to link the inode to the destination pathname, or use |
| 814 |
.B e2fsck |
| 815 |
to check the file system and link all of the recovered inodes to the |
| 816 |
lost+found directory. |
| 817 |
.TP |
| 818 |
.BI unlink " pathname" |
| 819 |
Remove the link specified by |
| 820 |
.I pathname |
| 821 |
to an inode. Note this does not adjust the inode reference counts. |
| 822 |
.TP |
| 823 |
.BI write " source_file out_file" |
| 824 |
Copy the contents of |
| 825 |
.I source_file |
| 826 |
into a newly-created file in the file system named |
| 827 |
.IR out_file . |
| 828 |
.TP |
| 829 |
.BI zap_block " [\-f filespec] [\-o offset] [\-l length] [\-p pattern] block_num" |
| 830 |
Overwrite the block specified by |
| 831 |
.I block_num |
| 832 |
with zero (NUL) bytes, or if |
| 833 |
.I \-p |
| 834 |
is given use the byte specified by |
| 835 |
.IR pattern . |
| 836 |
If |
| 837 |
.I \-f |
| 838 |
is given then |
| 839 |
.I block_num |
| 840 |
is relative to the start of the file given by |
| 841 |
.IR filespec . |
| 842 |
The |
| 843 |
.I \-o |
| 844 |
and |
| 845 |
.I \-l |
| 846 |
options limit the range of bytes to zap to the specified |
| 847 |
.I offset |
| 848 |
and |
| 849 |
.I length |
| 850 |
relative to the start of the block. |
| 851 |
.TP |
| 852 |
.BI zap_block " [\-f filespec] [\-b bit] block_num" |
| 853 |
Bit-flip portions of the physical |
| 854 |
.IR block_num . |
| 855 |
If |
| 856 |
.I \-f |
| 857 |
is given, then |
| 858 |
.I block_num |
| 859 |
is a logical block relative to the start of |
| 860 |
.IR filespec . |
| 861 |
.SH ENVIRONMENT VARIABLES |
| 862 |
.TP |
| 863 |
.B DEBUGFS_PAGER, PAGER |
| 864 |
The |
| 865 |
.B debugfs |
| 866 |
program always pipes the output of the some commands through a |
| 867 |
pager program. These commands include: |
| 868 |
.IR show_super_stats " (" stats ), |
| 869 |
.IR list_directory " (" ls ), |
| 870 |
.IR show_inode_info " (" stat ), |
| 871 |
.IR list_deleted_inodes " (" lsdel ), |
| 872 |
and |
| 873 |
.IR htree_dump . |
| 874 |
The specific pager can explicitly specified by the |
| 875 |
.B DEBUGFS_PAGER |
| 876 |
environment variable, and if it is not set, by the |
| 877 |
.B PAGER |
| 878 |
environment variable. |
| 879 |
.IP |
| 880 |
Note that since a pager is always used, the |
| 881 |
.BR less (1) |
| 882 |
pager is not particularly appropriate, since it clears the screen before |
| 883 |
displaying the output of the command and clears the output the screen |
| 884 |
when the pager is exited. Many users prefer to use the |
| 885 |
.BR less (1) |
| 886 |
pager for most purposes, which is why the |
| 887 |
.B DEBUGFS_PAGER |
| 888 |
environment variable is available to override the more general |
| 889 |
.B PAGER |
| 890 |
environment variable. |
| 891 |
.SH AUTHOR |
| 892 |
.B debugfs |
| 893 |
was written by Theodore Ts'o <[email protected]>. |
| 894 |
.SH SEE ALSO |
| 895 |
.BR dumpe2fs (8), |
| 896 |
.BR tune2fs (8), |
| 897 |
.BR e2fsck (8), |
| 898 |
.BR mke2fs (8), |
| 899 |
.BR ext4 (5) |