1gfs2_edit(8)                System Manager's Manual               gfs2_edit(8)
2
3
4

NAME

6       gfs2_edit - Display, print or edit GFS2 or GFS internal structures.
7
8

SYNOPSIS

10       gfs2_edit [OPTION]... [DEVICE]
11
12

DESCRIPTION

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

OPTIONS

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
155       rg <rg> <device>
156              Print the contents of Resource Group <rg> on <device>.
157
158              <rg> is a number from 0 to X - 1, where X is the number of RGs.
159
160       rgcount <device>
161              Print the number of  Resource  Groups  in  the  file  system  on
162              <device>.
163
164       rgflags <rg> [new_value] <device>
165              Print and/or modify the rg_flags value of Resource Group <rg> on
166              <device>.
167
168              <rg> is a number from 0 to X - 1, where X is the number of  RGs.
169              If  new_value  is not specified, the current rg_flags value will
170              be printed but not modified.  If  new_value  is  specified,  the
171              rg_flags field will be overwritten with the new value.
172
173       printsavedmeta <filename>
174              Print  off a list of blocks from <filename> that were saved with
175              the savemeta option.
176
177       savemeta <device> <filename>
178              Save off the GFS2 metadata (not user data) for the  file  system
179              on  the specified device to a file given by <filename>.  You can
180              use this option to analyze file system problems without  reveal‐
181              ing  sensitive  information  that may be contained in the files.
182              This option works quickly by using the system bitmap  blocks  in
183              the  resource  groups to determine the location of all the meta‐
184              data.  If there is corruption in the bitmaps, resource groups or
185              rindex  file,  this  method may fail and you may need to use the
186              savemetaslow option.  The destination file  is  not  compressed.
187              You  may want to compress it with a program such as bzip2 before
188              sending it for analysis.
189
190       savemetaslow <device> <filename>
191              Save off GFS2 metadata, as with the savemeta  option,  examining
192              every  block  in  the  file system for metadata.  This option is
193              less prone to failure due to file  system  corruption  than  the
194              savemeta option, but it is extremely slow.
195
196       savergs <device> <filename>
197              Save off only the GFS2 resource group metadata for the file sys‐
198              tem on the specified device to a file given by <filename>.
199
200       restoremeta <filename> <dest device>
201              Take a file created with the savemeta option  and  restores  its
202              contents  on  top of the specified destination device.  WARNING:
203              When you use this option, the file system and all  data  on  the
204              destination  device  is  destroyed.  Since only metadata (but no
205              data) is restored, every file in the resulting  file  system  is
206              likely  to  be  corrupt.   The ONLY purpose of this option is to
207              examine and debug file system problems by restoring and  examin‐
208              ing  the  state  of the saved metadata.  If the destination file
209              system is the same size or larger than the  source  file  system
210              where  the metadata was saved, the resulting file system will be
211              the same size as the  source.   If  the  destination  device  is
212              smaller  than  the source file system, gfs2_edit will restore as
213              much as it can, then quit, leaving you with a file  system  that
214              probably  will not mount, but from which you might still be able
215              to figure out what is wrong with the source file system.
216
217

INTERACTIVE MODE

219       If you specify a device on the gfs2_edit command line and  you  specify
220       no  options  other  than  -c, gfs2_edit will act as an interactive GFS2
221       file system editor for the file system you specify.   There  are  three
222       display modes: hex mode, structure mode and pointers mode.  You use the
223       m key to switch between the modes, as described below.  The  modes  are
224       as follows:
225
226       Hex mode (default)
227              Display  or  edit  blocks  of the file system in hexadecimal and
228              ascii.
229
230              Lines at the top indicate the currently displayed block in  both
231              hex  and  decimal.  If the block contains a GFS2 data structure,
232              the name of that structure will appear in the upper right corner
233              of the display.  If the block is a well-known block, such as the
234              superblock or rindex, there will be a line to indicate  what  it
235              is.
236
237              In  hex mode, you can edit blocks by pressing <enter> and enter‐
238              ing hexadecimal digits to replace the  highlighted  hex  digits.
239              Do  NOT precede the numbers with "0x".  For example, if you want
240              to change the value at offset 0x60 from a 0x12 to 0xef, position
241              your  cursor to offset 0x60, so that the 12 is highlighted, then
242              press <enter> and type in "ef".  Press <escape>  or  <enter>  to
243              exit edit mode.
244
245              In  hex  mode,  different colors indicate different things.  For
246              example, in the default color scheme, the  GFS2  data  structure
247              will  be black, data offsets will be light blue, and actual data
248              (anything after the gfs2 data structure) will be red.
249
250
251       Structure mode
252              Decode the file system block into its GFS2 structure and display
253              the  values  of  that  structure.   This mode is most useful for
254              jumping around the file system.  For example, you  can  use  the
255              arrow  keys to position down to a pointer and press J to jump to
256              that block.
257
258
259       Pointers mode
260              Display any additional information appearing on the block.   For
261              example,  if an inode has block pointers, this will display them
262              and allow you to scroll through them.  You can also position  to
263              one of them and press J to jump to that block.
264
265

Interactive mode command keys:

267       q or <esc>
268              The q or <escape> keys are used to exit gfs2_edit.
269
270
271       <arrow/movement keys> up, down, right, left, pg-up, pg-down, home, end
272              The  arrow  keys  are  used to highlight an area of the display.
273              The J key may be used to jump to the block that is highlighted.
274
275
276       m - Mode switch
277              The m key is used to switch between  the  three  display  modes.
278              The  initial mode is hex mode.  Pressing the m key once switches
279              to structure mode.  Pressing it  a  second  time  switches  from
280              structure mode to pointers mode.  Pressing it a third time takes
281              you back to hex mode again.
282
283
284       j - Jump to block
285              The j key jumps to the block  number  that  is  currently  high‐
286              lighted.   In hex mode, hitting J will work when any byte of the
287              pointer is highlighted.
288
289
290       g - Goto block
291              The g key asks for a block number, then jumps there.  Note  that
292              in  many  cases, you can also arrow up so that the current block
293              number is highlighted, then press <enter> to enter a block  num‐
294              ber to jump to.
295
296
297       h - Help display
298              The h key causes the interactive help display to be shown.
299
300
301       e - Extended mode
302              The  e  key  causes gfs2_edit to switch to extended ("pointers")
303              mode.
304
305
306       c - Color scheme
307              The c key causes gfs2_edit to  switch  to  its  alternate  color
308              scheme.
309
310
311       f - Forward block
312              The f key causes you to scroll forward one block.  This does not
313              affect the "jump" status.  In other words, if you use the f  key
314              to  move  forward  several blocks, pressing <backspace> will not
315              roll you back up.
316
317
318       <enter> - Edit value
319              The <enter> key causes you to go from display mode to edit mode.
320              If  you  are in hex mode and you hit enter, you can type new hex
321              values at the cursor's current location.  Note: pressing <enter>
322              in structure mode allows you to enter a new value, with the fol‐
323              lowing restrictions:  For gfs2 disk inodes and resource  groups,
324              it  will  actually change the value on disk. However, inode num‐
325              bers may not be changed.  For all other structures,  the  values
326              entered are ignored.
327
328              If  you use the up arrow key to highlight the block number, then
329              press <enter>, you may then enter a new block number, or any  of
330              the  well-known  block  locations listed above (e.g. sb, rindex,
331              inum, rg 17, etc.) and gfs2_edit will jump to the  block  speci‐
332              fied.   If  you specify a slash character followed by a metadata
333              type, gfs2_edit will search for  the  next  occurrence  of  that
334              metadata  block type, and jump there.  It will take you to block
335              0 if it does not find any more blocks of the specified  metadata
336              type.
337
338
339       <home> If  you  are in pointers mode, this takes you back to the starts
340              of the pointers you are viewing.  Otherwise it takes you back to
341              the superblock.
342
343
344       <backspace>
345              This  takes  you  back to the block you were displaying before a
346              jump.
347
348
349       <space>
350              This takes you forward to the block you were displaying when you
351              hit <backspace>.
352
353

EXAMPLES

355       gfs2_edit /dev/roth_vg/roth_lv
356              Display    and    optionally    edit    the   file   system   on
357              /dev/roth_vg/roth_lv
358
359
360       gfs2_edit -p sb /dev/vg0/lvol0
361              Print  the  superblock  of  the  gfs2  file  system  located  on
362              /dev/vg0/lvol0.
363
364
365       gfs2_edit -p identify 2746 2748 /dev/sda2
366              Print out what kind of blocks are at block numbers 2746 and 2748
367              on device /dev/sda2.
368
369
370       gfs2_edit -p rindex /dev/sda1
371              Print the resource group index system  file  located  on  device
372              /dev/sda1.
373
374
375       gfs2_edit savemeta /dev/sda1 /tmp/our_fs
376              Save off all metadata (but no user data) to file /tmp/our_fs.
377
378
379       gfs2_edit -p root /dev/my_vg/my_lv
380              Print the contents of the root directory in /dev/my_vg/my_lv.
381
382
383       gfs2-edit -x -p 0x3f7a /dev/sda1
384              Print the contents of block 16250 of /dev/sda1 in hex.
385
386
387       gfs2_edit -p 12345 /dev/sdc2
388              Print the gfs2 data structure at block 12345.
389
390
391       gfs2_edit rgcount /dev/sdb1
392              Print how many Resource Groups exist for /dev/sdb1.
393
394
395       gfs2_edit -p rg 17 /dev/sdb1
396              Print   the   contents  of  the  eighteenth  Resource  Group  on
397              /dev/sdb1.
398
399
400       gfs2_edit rgflags 3 /dev/sdb1
401              Print the rg_flags  value  for  the  fourth  Resource  Group  on
402              /dev/sdb1.
403
404
405       gfs2_edit rgflags 3 8 /dev/sdb1
406              Set  the  GFS2_RGF_NOALLOC flag on for the fourth Resource Group
407              on /dev/sdb1.
408
409
410       gfs2_edit -p 25 blockalloc /dev/roth_vg/roth_lv
411              Print the block allocation type of block 25.  May  produce  this
412              output: 3 (Metadata)
413
414
415       gfs2_edit -p 25 blockalloc 1 /dev/roth_vg/roth_lv
416              Change  the block allocation type of block 25 to data.  May pro‐
417              duce this output: 1
418
419
420       gfs2_edit -p 25 blocktype /dev/roth_vg/roth_lv
421              Print the metadata block type of block  25.   May  produce  this
422              output: 4 (Block 25 is type 4: Dinode)
423
424
425       gfs2_edit -p 25 field di_size /dev/roth_vg/roth_lv
426              Print  the  di_size field of block 25.  May produce this output:
427              134217728
428
429
430       gfs2_edit -x -p 25 field di_size /dev/roth_vg/roth_lv
431              Print the di_size field of block 25, in hexidecimal.   May  pro‐
432              duce this output: 0x8000000
433
434
435       gfs2_edit -p 25 field di_size 0x4000 /dev/roth_vg/roth_lv
436              Change  the  di_size  field of block 25 to the hexidecimal value
437              0x4000.  May produce this output: 16384
438

KNOWN BUGS

440       The directory code does not work well.  It might be confused
441              by directory "sentinel" entries.
442
443
444
445                                                                  gfs2_edit(8)
Impressum