gfs2_edit(8) | System Manager's Manual | gfs2_edit(8) |
gfs2_edit - Display, print or edit GFS2 or GFS internal structures.
gfs2_edit [OPTION]... [DEVICE]
The gfs2_edit command is a tool used to examine, edit or display internal data structures of a GFS2 or GFS file system. The gfs2_edit command can be run interactively, as described below in INTERACTIVE MODE.
Caution: Several options of the gfs2_edit command alter the file system metadata and can cause file system corruption. These options should be used with great care.
You can specify the following well-known locations with the -p option.
sb, superblock - Print the superblock.
root - Print the root directory.
master - Print the master system directory.
jindex - Print the journal index system directory.
per_node - Print the per_node system directory.
inum - Print the system inum file.
statfs - Print the system statfs file.
rindex, rgindex - Print the resource group index system file.
rg X - Print the resource group information for RG X (zero-based).
rgs - Print the resource group information.
quota - Print the contents of the system quota file.
identify - Identify a data block rather than print the block's contents.
size - Print the device size information.
journalX - Print the contents of journal X, where X is a journal number from 0 to <the number of journals in your file system - 1>. Only the journal headers and journal descriptors are dumped. For journal descriptors, this option prints out every file system block number logged in that section of the journal. The actual journaled blocks are not printed.
If you specify a block number rather than a structure name, gfs2_edit will print out a breakdown of the structure for that block. For example: gfs2_edit -p sb will print the superblock, but so does gfs2_edit -p 0x10 and gfs2_edit -p 16.
If you specify -p without a block or structure name, gfs2_edit prints the superblock.
You can specify more than one data structure with a single -p option. For example, gfs2_edit -p inum statfs /dev/sda1 prints the system inum file and the system statfs file on /dev/sda1.
Optionally, you may specify the keyword blocktype to print out the gfs2 block type for the specified block. Valid gfs2 block types are: 0 (Clump), 1 (Superblock), 2 (Resource Group Header), 3 (Resource Group Bitmap), 4 (Dinode), 5 (Indirect Block), 6 (Leaf), 7 (Journaled data), 8 (Log Header), 9 (Log descriptor), 10 (Extended attribute), 11 (Eattr Data), 12 (Log Buffer), 13 (Invalid), and 14 (Quota Change).
Optionally, you may specify the keyword blockalloc with an optional value to assign. If no value is specified, the blockalloc keyword will print the block allocation type for the specified block. Valid block allocation types are: 0 (Free block), 1 (Data block), 2 (Unlinked block), and 3 (Metadata block). If a value from 0 to 3 is specified, the resource group bitmap will be changed to the new value. This may be used, for example, to artificially free or allocate a block in order to test fsck.gfs2's ability to detect and fix the problem.
Optionally, you may specify the keyword blockbits. This option will locate and print the block containing the bitmap corresponding to the specified block.
Optionally, you may specify the keyword blockrg. This option will locate and print the block number of the resource group that holds information about the specified block.
You may also use gfs2_edit to find the next occurrence of a metadata block of a certain type. Valid metadata types are: none (unused metadata clump block), sb (superblock), rg (resource group), rb (rg bitmap), di (disk inode aka dinode), in (indirect block list), lf (directory leaf), jd (journaled data), lh (journal log header), ld (journal log descriptor), ea (extended attribute), ed (ea data block), lb (log buffer), 13 (unused block type 13), qc (quota change). The block AFTER the one specified with -p is the starting point for the search. For example, if you specify gfs2_edit -p rg 12 find rg /dev/your/device, it will find the rg that follows rg 12 (normally, this would be rg 13). Note, however, that since metadata often appears in the journals, it could be a copy of a different RG, inside a journal. Also note that gfs2_edit will only find allocated metadata blocks unless the type specified is none, sb, rg or rb. In other words, if you try to find a disk inode, it will only find an allocated dinode, not a deallocated one.
Optionally, you may specify the keyword field followed by a valid metadata field name. Right now, only the fields in disk inodes and resource groups are allowed. If no value is specified after the field, the value of the field will be printed to stdout. If a value is specified, the field's value will be changed. This may be used, for example, to artificially change the di_size field for an inode in order to test fsck.gfs2's ability to detect and fix the problem.
<rg> is a number from 0 to X - 1, where X is the number of RGs.
<rg> is a number from 0 to X - 1, where X is the number of RGs. If new_value is not specified, the current rg_flags value will be printed but not modified. If new_value is specified, the rg_flags field will be overwritten with the new value.
If you specify a device on the gfs2_edit command line and you specify no options other than -c, gfs2_edit will act as an interactive GFS2 file system editor for the file system you specify. There are three display modes: hex mode, structure mode and pointers mode. You use the m key to switch between the modes, as described below. The modes are as follows:
Lines at the top indicate the currently displayed block in both hex and decimal. If the block contains a GFS2 data structure, the name of that structure will appear in the upper right corner of the display. If the block is a well-known block, such as the superblock or rindex, there will be a line to indicate what it is.
In hex mode, you can edit blocks by pressing <enter> and entering hexadecimal digits to replace the highlighted hex digits. Do NOT precede the numbers with "0x". For example, if you want to change the value at offset 0x60 from a 0x12 to 0xef, position your cursor to offset 0x60, so that the 12 is highlighted, then press <enter> and type in "ef". Press <escape> or <enter> to exit edit mode.
In hex mode, different colors indicate different things. For example, in the default color scheme, the GFS2 data structure will be black, data offsets will be light blue, and actual data (anything after the gfs2 data structure) will be red.
If you use the up arrow key to highlight the block number, then press <enter>, you may then enter a new block number, or any of the well-known block locations listed above (e.g. sb, rindex, inum, rg 17, etc.) and gfs2_edit will jump to the block specified. If you specify a slash character followed by a metadata type, gfs2_edit will search for the next occurrence of that metadata block type, and jump there. It will take you to block 0 if it does not find any more blocks of the specified metadata type.