1gfs2_edit(8) System Manager's Manual gfs2_edit(8)
2
3
4
6 gfs2_edit - Display, print or edit GFS2 or GFS internal structures.
7
8
10 gfs2_edit [OPTION]... [DEVICE]
11
12
14 The gfs2_edit command is a tool used to examine, edit or display inter‐
15 nal data structures of a GFS2 or GFS file system. The gfs2_edit com‐
16 mand can be run interactively, as described below in INTERACTIVE MODE.
17
18 Caution: Several options of the gfs2_edit command alter the file system
19 metadata and can cause file system corruption. These options should be
20 used with great care.
21
22
24 -p [struct | block] [blocktype] [blockalloc [val]] [blockbits]
25 [blockrg] [find sb|rg|rb|di|in|lf|jd|lh|ld|ea|ed|lb|13|qc] [field
26 <field> [val]]
27 Print a gfs2 data structure in human-readable format to stdout.
28 You can enter either a block number or a data structure name.
29 Block numbers may be specified in hex (e.g., 0x10) or decimal
30 (e.g., 16).
31
32 You can specify the following well-known locations with the -p
33 option.
34
35 sb, superblock - Print the superblock.
36
37 root - Print the root directory.
38
39 master - Print the master system directory.
40
41 jindex - Print the journal index system directory.
42
43 per_node - Print the per_node system directory.
44
45 inum - Print the system inum file.
46
47 statfs - Print the system statfs file.
48
49 rindex, rgindex - Print the resource group index system file.
50
51 rg X - Print the resource group information for RG X (zero-
52 based).
53
54 rgs - Print the resource group information.
55
56 quota - Print the contents of the system quota file.
57
58 identify - Identify a data block rather than print the block's
59 contents.
60
61 size - Print the device size information.
62
63 journalX - Print the contents of journal X, where X is a journal
64 number from 0 to <the number of journals in your file system -
65 1>. Only the journal headers and journal descriptors are
66 dumped. For journal descriptors, this option prints out every
67 file system block number logged in that section of the journal.
68 The actual journaled blocks are not printed.
69
70 If you specify a block number rather than a structure name,
71 gfs2_edit will print out a breakdown of the structure for that
72 block. For example: gfs2_edit -p sb will print the superblock,
73 but so does gfs2_edit -p 0x10 and gfs2_edit -p 16.
74
75 If you specify -p without a block or structure name, gfs2_edit
76 prints the superblock.
77
78 You can specify more than one data structure with a single -p
79 option. For example, gfs2_edit -p inum statfs /dev/sda1 prints
80 the system inum file and the system statfs file on /dev/sda1.
81
82 Optionally, you may specify the keyword blocktype to print out
83 the gfs2 block type for the specified block. Valid gfs2 block
84 types are: 0 (Clump), 1 (Superblock), 2 (Resource Group Header),
85 3 (Resource Group Bitmap), 4 (Dinode), 5 (Indirect Block), 6
86 (Leaf), 7 (Journaled data), 8 (Log Header), 9 (Log descriptor),
87 10 (Extended attribute), 11 (Eattr Data), 12 (Log Buffer), 13
88 (Invalid), and 14 (Quota Change).
89
90 Optionally, you may specify the keyword blockalloc with an
91 optional value to assign. If no value is specified, the block‐
92 alloc keyword will print the block allocation type for the spec‐
93 ified block. Valid block allocation types are: 0 (Free block),
94 1 (Data block), 2 (Unlinked block), and 3 (Metadata block). If
95 a value from 0 to 3 is specified, the resource group bitmap will
96 be changed to the new value. This may be used, for example, to
97 artificially free or allocate a block in order to test
98 fsck.gfs2's ability to detect and fix the problem.
99
100 Optionally, you may specify the keyword blockbits. This option
101 will locate and print the block containing the bitmap corre‐
102 sponding to the specified block.
103
104 Optionally, you may specify the keyword blockrg. This option
105 will locate and print the block number of the resource group
106 that holds information about the specified block.
107
108 You may also use gfs2_edit to find the next occurrence of a
109 metadata block of a certain type. Valid metadata types are:
110 none (unused metadata clump block), sb (superblock), rg
111 (resource group), rb (rg bitmap), di (disk inode aka dinode), in
112 (indirect block list), lf (directory leaf), jd (journaled data),
113 lh (journal log header), ld (journal log descriptor), ea
114 (extended attribute), ed (ea data block), lb (log buffer), 13
115 (unused block type 13), qc (quota change). The block AFTER the
116 one specified with -p is the starting point for the search. For
117 example, if you specify gfs2_edit -p rg 12 find rg
118 /dev/your/device, it will find the rg that follows rg 12 (nor‐
119 mally, this would be rg 13). Note, however, that since metadata
120 often appears in the journals, it could be a copy of a different
121 RG, inside a journal. Also note that gfs2_edit will only find
122 allocated metadata blocks unless the type specified is none, sb,
123 rg or rb. In other words, if you try to find a disk inode, it
124 will only find an allocated dinode, not a deallocated one.
125
126 Optionally, you may specify the keyword field followed by a
127 valid metadata field name. Right now, only the fields in disk
128 inodes and resource groups are allowed. If no value is speci‐
129 fied after the field, the value of the field will be printed to
130 stdout. If a value is specified, the field's value will be
131 changed. This may be used, for example, to artificially change
132 the di_size field for an inode in order to test fsck.gfs2's
133 ability to detect and fix the problem.
134
135
136 -s [structure | block]
137 Specify a starting block for interactive mode. Any of the well-
138 known locations found in the -p option may be specified. If you
139 want to start on a particular resource group, specify it in
140 quotes, e.g. -s "rg 3"
141
142 -h, -help, -usage
143 Print help information.
144
145 -c [0 | 1]
146 Use alternate color scheme for interactive mode: 0=normal (dark
147 colors on white background), or 1 (light colors on black back‐
148 ground).
149
150 -V Print program version information only.
151
152 -x Print in hex mode.
153
154 -z <0-9>
155 Compress metadata with gzip compression level 1 to 9 (default
156 9). 0 means no compression at all.
157
158 rg <rg> <device>
159 Print the contents of Resource Group <rg> on <device>.
160
161 <rg> is a number from 0 to X - 1, where X is the number of RGs.
162
163 rgcount <device>
164 Print the number of Resource Groups in the file system on
165 <device>.
166
167 rgflags <rg> [new_value] <device>
168 Print and/or modify the rg_flags value of Resource Group <rg> on
169 <device>.
170
171 <rg> is a number from 0 to X - 1, where X is the number of RGs.
172 If new_value is not specified, the current rg_flags value will
173 be printed but not modified. If new_value is specified, the
174 rg_flags field will be overwritten with the new value.
175
176 printsavedmeta <filename.gz>
177 Print off a list of blocks from <filename.gz> that were saved
178 with the savemeta option.
179
180 savemeta <device> <filename.gz>
181 Save off the GFS2 metadata (not user data) for the file system
182 on the specified device to a file given by <filename>. You can
183 use this option to analyze file system problems without reveal‐
184 ing sensitive information that may be contained in the files.
185 This option works quickly by using the system bitmap blocks in
186 the resource groups to determine the location of all the meta‐
187 data. If there is corruption in the bitmaps, resource groups or
188 rindex file, this method may fail and you may need to use the
189 savemetaslow option. The destination file is compressed using
190 gzip unless -z 0 is specified.
191
192 savemetaslow <device> <filename.gz>
193 Save off GFS2 metadata, as with the savemeta option, examining
194 every block in the file system for metadata. This option is
195 less prone to failure due to file system corruption than the
196 savemeta option, but it is extremely slow. The destination file
197 is compressed using gzip unless -z 0 is specified.
198
199 savergs <device> <filename.gz>
200 Save off only the GFS2 resource group metadata for the file sys‐
201 tem on the specified device to a file given by <filename>. The
202 destination file is compressed using gzip unless -z 0 is speci‐
203 fied.
204
205 restoremeta <filename> <dest device>
206 Take a compressed or uncompressed file created with the savemeta
207 option and restores its contents on top of the specified desti‐
208 nation device. WARNING: When you use this option, the file sys‐
209 tem and all data on the destination device is destroyed. Since
210 only metadata (but no data) is restored, every file in the
211 resulting file system is likely to be corrupt. The ONLY purpose
212 of this option is to examine and debug file system problems by
213 restoring and examining the state of the saved metadata. If the
214 destination file system is the same size or larger than the
215 source file system where the metadata was saved, the resulting
216 file system will be the same size as the source. If the desti‐
217 nation device is smaller than the source file system, gfs2_edit
218 will restore as much as it can, then quit, leaving you with a
219 file system that probably will not mount, but from which you
220 might still be able to figure out what is wrong with the source
221 file system.
222
223
225 If you specify a device on the gfs2_edit command line and you specify
226 no options other than -c, gfs2_edit will act as an interactive GFS2
227 file system editor for the file system you specify. There are three
228 display modes: hex mode, structure mode and pointers mode. You use the
229 m key to switch between the modes, as described below. The modes are
230 as follows:
231
232 Hex mode (default)
233 Display or edit blocks of the file system in hexadecimal and
234 ascii.
235
236 Lines at the top indicate the currently displayed block in both
237 hex and decimal. If the block contains a GFS2 data structure,
238 the name of that structure will appear in the upper right corner
239 of the display. If the block is a well-known block, such as the
240 superblock or rindex, there will be a line to indicate what it
241 is.
242
243 In hex mode, you can edit blocks by pressing <enter> and enter‐
244 ing hexadecimal digits to replace the highlighted hex digits.
245 Do NOT precede the numbers with "0x". For example, if you want
246 to change the value at offset 0x60 from a 0x12 to 0xef, position
247 your cursor to offset 0x60, so that the 12 is highlighted, then
248 press <enter> and type in "ef". Press <escape> or <enter> to
249 exit edit mode.
250
251 In hex mode, different colors indicate different things. For
252 example, in the default color scheme, the GFS2 data structure
253 will be black, data offsets will be light blue, and actual data
254 (anything after the gfs2 data structure) will be red.
255
256
257 Structure mode
258 Decode the file system block into its GFS2 structure and display
259 the values of that structure. This mode is most useful for
260 jumping around the file system. For example, you can use the
261 arrow keys to position down to a pointer and press J to jump to
262 that block.
263
264
265 Pointers mode
266 Display any additional information appearing on the block. For
267 example, if an inode has block pointers, this will display them
268 and allow you to scroll through them. You can also position to
269 one of them and press J to jump to that block.
270
271
273 q or <esc>
274 The q or <escape> keys are used to exit gfs2_edit.
275
276
277 <arrow/movement keys> up, down, right, left, pg-up, pg-down, home, end
278 The arrow keys are used to highlight an area of the display.
279 The J key may be used to jump to the block that is highlighted.
280
281
282 m - Mode switch
283 The m key is used to switch between the three display modes.
284 The initial mode is hex mode. Pressing the m key once switches
285 to structure mode. Pressing it a second time switches from
286 structure mode to pointers mode. Pressing it a third time takes
287 you back to hex mode again.
288
289
290 j - Jump to block
291 The j key jumps to the block number that is currently high‐
292 lighted. In hex mode, hitting J will work when any byte of the
293 pointer is highlighted.
294
295
296 g - Goto block
297 The g key asks for a block number, then jumps there. Note that
298 in many cases, you can also arrow up so that the current block
299 number is highlighted, then press <enter> to enter a block num‐
300 ber to jump to.
301
302
303 h - Help display
304 The h key causes the interactive help display to be shown.
305
306
307 e - Extended mode
308 The e key causes gfs2_edit to switch to extended ("pointers")
309 mode.
310
311
312 c - Color scheme
313 The c key causes gfs2_edit to switch to its alternate color
314 scheme.
315
316
317 f - Forward block
318 The f key causes you to scroll forward one block. This does not
319 affect the "jump" status. In other words, if you use the f key
320 to move forward several blocks, pressing <backspace> will not
321 roll you back up.
322
323
324 <enter> - Edit value
325 The <enter> key causes you to go from display mode to edit mode.
326 If you are in hex mode and you hit enter, you can type new hex
327 values at the cursor's current location. Note: pressing <enter>
328 in structure mode allows you to enter a new value, with the fol‐
329 lowing restrictions: For gfs2 disk inodes and resource groups,
330 it will actually change the value on disk. However, inode num‐
331 bers may not be changed. For all other structures, the values
332 entered are ignored.
333
334 If you use the up arrow key to highlight the block number, then
335 press <enter>, you may then enter a new block number, or any of
336 the well-known block locations listed above (e.g. sb, rindex,
337 inum, rg 17, etc.) and gfs2_edit will jump to the block speci‐
338 fied. If you specify a slash character followed by a metadata
339 type, gfs2_edit will search for the next occurrence of that
340 metadata block type, and jump there. It will take you to block
341 0 if it does not find any more blocks of the specified metadata
342 type.
343
344
345 <home> If you are in pointers mode, this takes you back to the starts
346 of the pointers you are viewing. Otherwise it takes you back to
347 the superblock.
348
349
350 <backspace>
351 This takes you back to the block you were displaying before a
352 jump.
353
354
355 <space>
356 This takes you forward to the block you were displaying when you
357 hit <backspace>.
358
359
361 gfs2_edit /dev/roth_vg/roth_lv
362 Display and optionally edit the file system on
363 /dev/roth_vg/roth_lv
364
365
366 gfs2_edit -p sb /dev/vg0/lvol0
367 Print the superblock of the gfs2 file system located on
368 /dev/vg0/lvol0.
369
370
371 gfs2_edit -p identify 2746 2748 /dev/sda2
372 Print out what kind of blocks are at block numbers 2746 and 2748
373 on device /dev/sda2.
374
375
376 gfs2_edit -p rindex /dev/sda1
377 Print the resource group index system file located on device
378 /dev/sda1.
379
380
381 gfs2_edit savemeta /dev/sda1 /tmp/our_fs.gz
382 Save off all metadata (but no user data) to file /tmp/our_fs.gz
383
384
385 gfs2_edit -p root /dev/my_vg/my_lv
386 Print the contents of the root directory in /dev/my_vg/my_lv.
387
388
389 gfs2-edit -x -p 0x3f7a /dev/sda1
390 Print the contents of block 16250 of /dev/sda1 in hex.
391
392
393 gfs2_edit -p 12345 /dev/sdc2
394 Print the gfs2 data structure at block 12345.
395
396
397 gfs2_edit rgcount /dev/sdb1
398 Print how many Resource Groups exist for /dev/sdb1.
399
400
401 gfs2_edit -p rg 17 /dev/sdb1
402 Print the contents of the eighteenth Resource Group on
403 /dev/sdb1.
404
405
406 gfs2_edit rgflags 3 /dev/sdb1
407 Print the rg_flags value for the fourth Resource Group on
408 /dev/sdb1.
409
410
411 gfs2_edit rgflags 3 8 /dev/sdb1
412 Set the GFS2_RGF_NOALLOC flag on for the fourth Resource Group
413 on /dev/sdb1.
414
415
416 gfs2_edit -p 25 blockalloc /dev/roth_vg/roth_lv
417 Print the block allocation type of block 25. May produce this
418 output: 3 (Metadata)
419
420
421 gfs2_edit -p 25 blockalloc 1 /dev/roth_vg/roth_lv
422 Change the block allocation type of block 25 to data. May pro‐
423 duce this output: 1
424
425
426 gfs2_edit -p 25 blocktype /dev/roth_vg/roth_lv
427 Print the metadata block type of block 25. May produce this
428 output: 4 (Block 25 is type 4: Dinode)
429
430
431 gfs2_edit -p 25 field di_size /dev/roth_vg/roth_lv
432 Print the di_size field of block 25. May produce this output:
433 134217728
434
435
436 gfs2_edit -x -p 25 field di_size /dev/roth_vg/roth_lv
437 Print the di_size field of block 25, in hexadecimal. May pro‐
438 duce this output: 0x8000000
439
440
441 gfs2_edit -p 25 field di_size 0x4000 /dev/roth_vg/roth_lv
442 Change the di_size field of block 25 to the hexadecimal value
443 0x4000. May produce this output: 16384
444
446 The directory code does not work well. It might be confused
447 by directory "sentinel" entries.
448
449
450
451 gfs2_edit(8)