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

NAME

6       xfs_repair - repair an XFS filesystem
7

SYNOPSIS

9       xfs_repair  [  -dfLnPv  ]  [  -m maxmem ] [ -c subopt=value ] [ -o sub‐
10       opt[=value] ] [ -t interval ] [ -l logdev ] [ -r rtdev ] device
11       xfs_repair -V
12

DESCRIPTION

14       xfs_repair repairs corrupt or damaged  XFS  filesystems  (see  xfs(5)).
15       The  filesystem  is specified using the device argument which should be
16       the device name of the disk partition or volume containing the filesys‐
17       tem.  If  given  the name of a block device, xfs_repair will attempt to
18       find the raw device associated with the specified block device and will
19       use the raw device instead.
20
21       Regardless, the filesystem to be repaired must be unmounted, otherwise,
22       the resulting filesystem may be inconsistent or corrupt.
23

OPTIONS

25       -f     Specifies that the filesystem image to be processed is stored in
26              a regular file at device (see the mkfs.xfs -d file option). This
27              might happen if an image copy of a filesystem has been copied or
28              written  into  an  ordinary  file.  This option implies that any
29              external log or realtime section is also in an ordinary file.
30
31       -L     Force Log Zeroing.  Forces xfs_repair to zero the log even if it
32              is  dirty  (contains  metadata changes).  When using this option
33              the filesystem will likely appear to be corrupt, and  can  cause
34              the loss of user files and/or data.
35
36       -l logdev
37              Specifies  the device special file where the filesystem's exter‐
38              nal log resides. Only for those filesystems which use an  exter‐
39              nal  log.  See the mkfs.xfs -l option, and refer to xfs(5) for a
40              detailed description of the XFS log.
41
42       -r rtdev
43              Specifies the device special file where the  filesystem's  real‐
44              time  section  resides.  Only  for those filesystems which use a
45              realtime section.  See the mkfs.xfs  -r  option,  and  refer  to
46              xfs(5) for a detailed description of the XFS realtime section.
47
48       -n     No  modify mode. Specifies that xfs_repair should not modify the
49              filesystem but should only scan the filesystem and indicate what
50              repairs would have been made.
51
52       -P     Disable  prefetching  of  inode  and  directory blocks. Use this
53              option if you find xfs_repair gets stuck and  stops  proceeding.
54              Interrupting a stuck xfs_repair is safe.
55
56       -m maxmem
57              Specifies   the   approximate   maximum  amount  of  memory,  in
58              megabytes, to use for xfs_repair.  xfs_repair has its own inter‐
59              nal  block  cache  which  will scale out up to the lesser of the
60              process's virtual address limit or about  75%  of  the  system's
61              physical RAM.  This option overrides these limits.
62
63              NOTE:  These memory limits are only approximate and may use more
64              than the specified limit.
65
66       -c subopt=value
67              Change filesystem parameters. Refer to xfs_admin(8) for informa‐
68              tion on changing filesystem parameters.
69
70       -o subopt[=value]
71              Override what the program might conclude about the filesystem if
72              left to its own devices.
73
74              The suboptions supported are:
75
76                 bhash=bhashsize
77                        overrides the default  buffer  cache  hash  size.  The
78                        total  number of buffer cache entries are limited to 8
79                        times this amount. The default size is set to  use  up
80                        the  remainder  of  75%  of  the system's physical RAM
81                        size.
82
83                 ag_stride=ags_per_concat_unit
84                        This creates additional processing threads to parallel
85                        process  AGs that span multiple concat units. This can
86                        significantly reduce  repair  times  on  concat  based
87                        filesystems.
88
89                 force_geometry
90                        Check  the  filesystem  even  if  geometry information
91                        could not be validated.  Geometry information can  not
92                        be  validated if only a single allocation group exists
93                        and thus we do not have a backup superblock available,
94                        or  if  there  are  two  allocation groups and the two
95                        superblocks do not agree on the  filesystem  geometry.
96                        Only  use  this  option  if you validated the geometry
97                        yourself and know what you are doing.  If In doubt run
98                        in no modify mode first.
99
100       -t  interval
101              Modify  reporting  interval,  specified  in seconds. During long
102              runs xfs_repair outputs its progress every 15 minutes. Reporting
103              is only activated when ag_stride is enabled.
104
105       -v     Verbose  output.   May  be  specified multiple times to increase
106              verbosity.
107
108       -d     Repair dangerously. Allow xfs_repair to repair an XFS filesystem
109              mounted  read  only. This is typically done on a root filesystem
110              from single user mode, immediately followed by a reboot.
111
112       -V     Prints the version number and exits.
113
114   Checks Performed
115       Inconsistencies corrected include the following:
116
117       1.     Inode and inode blockmap (addressing) checks: bad  magic  number
118              in  inode,  bad  magic numbers in inode blockmap blocks, extents
119              out of order, incorrect number  of  records  in  inode  blockmap
120              blocks,  blocks claimed that are not in a legal data area of the
121              filesystem, blocks that are claimed by more than one inode.
122
123       2.     Inode allocation map checks:  bad  magic  number  in  inode  map
124              blocks,  inode state as indicated by map (free or in-use) incon‐
125              sistent with state indicated by the inode, inodes referenced  by
126              the  filesystem  that do not appear in the inode allocation map,
127              inode allocation map referencing blocks that do  not  appear  to
128              contain inodes.
129
130       3.     Size checks: number of blocks claimed by inode inconsistent with
131              inode size, directory size not block  aligned,  inode  size  not
132              consistent with inode format.
133
134       4.     Directory  checks: bad magic numbers in directory blocks, incor‐
135              rect number of entries  in  a  directory  block,  bad  freespace
136              information  in  a  directory  leaf  block, entry pointing to an
137              unallocated (free) or out of range inode,  overlapping  entries,
138              missing  or  incorrect  dot  and  dotdot entries, entries out of
139              hashvalue order, incorrect internal directory  pointers,  direc‐
140              tory type not consistent with inode format and size.
141
142       5.     Pathname  checks: files or directories not referenced by a path‐
143              name starting from the filesystem root, illegal pathname  compo‐
144              nents.
145
146       6.     Link count checks: link counts that do not agree with the number
147              of directory references to the inode.
148
149       7.     Freemap checks: blocks claimed free  by  the  freemap  but  also
150              claimed  by  an  inode,  blocks  unclaimed  by any inode but not
151              appearing in the freemap.
152
153       8.     Super Block checks: total free block and/or  free  i-node  count
154              incorrect,  filesystem geometry inconsistent, secondary and pri‐
155              mary superblocks contradictory.
156
157       Orphaned files and directories (allocated, in-use but unreferenced) are
158       reconnected  by  placing  them  in  the lost+found directory.  The name
159       assigned is the inode number.
160
161   Disk Errors
162       xfs_repair aborts on most disk I/O errors. Therefore, if you are trying
163       to  repair  a  filesystem that was damaged due to a disk drive failure,
164       steps should be taken to ensure that all blocks in the  filesystem  are
165       readable and writable before attempting to use xfs_repair to repair the
166       filesystem. A possible method is using dd(8) to copy the  data  onto  a
167       good disk.
168
169   lost+found
170       The directory lost+found does not have to already exist in the filesys‐
171       tem being repaired.  If the directory does not exist, it  is  automati‐
172       cally  created  if  required.  If it already exists, it will be checked
173       for consistency and if valid  will  be  used  for  additional  orphaned
174       files. Invalid lost+found directories are removed and recreated. Exist‐
175       ing files in a valid lost+found are not removed or renamed.
176
177   Corrupted Superblocks
178       XFS has both primary and secondary superblocks.  xfs_repair uses infor‐
179       mation in the primary superblock to automatically find and validate the
180       primary superblock against the secondary superblocks before proceeding.
181       Should  the  primary be too corrupted to be useful in locating the sec‐
182       ondary superblocks, the program scans the filesystem until it finds and
183       validates  some  secondary  superblocks.  At that point, it generates a
184       primary superblock.
185
186   Quotas
187       If quotas are in use, it is possible that xfs_repair will clear some or
188       all  of  the filesystem quota information.  If so, the program issues a
189       warning just before it terminates.  If all quota information  is  lost,
190       quotas are disabled and the program issues a warning to that effect.
191
192       Note that xfs_repair does not check the validity of quota limits. It is
193       recommended that you check the quota limit information  manually  after
194       xfs_repair.  Also, space usage information is automatically regenerated
195       the next time the filesystem is mounted with quotas turned on,  so  the
196       next quota mount of the filesystem may take some time.
197

DIAGNOSTICS

199       xfs_repair  issues  informative messages as it proceeds indicating what
200       it has found that is abnormal or any  corrective  action  that  it  has
201       taken.   Most  of  the  messages  are completely understandable only to
202       those who are knowledgeable about  the  structure  of  the  filesystem.
203       Some  of  the  more  common messages are explained here.  Note that the
204       language of the messages is slightly different if xfs_repair is run  in
205       no-modify  mode  because  the program is not changing anything on disk.
206       No-modify mode indicates what it would do to repair the  filesystem  if
207       run without the no-modify flag.
208
209       disconnected inode ino, moving to lost+found
210
211              An inode numbered ino was not connected to the filesystem direc‐
212              tory tree and was reconnected to the lost+found  directory.  The
213              inode  is  assigned  the  name  of its inode number (ino).  If a
214              lost+found directory does not exist, it  is  automatically  cre‐
215              ated.
216
217       disconnected dir inode ino, moving to lost+found
218
219              As  above  only  the inode is a directory inode.  If a directory
220              inode is attached to lost+found, all of its  children  (if  any)
221              stay  attached  to the directory and therefore get automatically
222              reconnected when the directory is reconnected.
223
224       imap claims in-use inode ino is free, correcting imap
225
226              The inode allocation map thinks that inode ino is  free  whereas
227              examination  of the inode indicates that the inode may be in use
228              (although it may be  disconnected).   The  program  updates  the
229              inode allocation map.
230
231       imap claims free inode ino is in use, correcting imap
232
233              The inode allocation map thinks that inode ino is in use whereas
234              examination of the inode indicates that the inode is not in  use
235              and therefore is free.  The program updates the inode allocation
236              map.
237
238       resetting inode ino nlinks from x to y
239
240              The program detected a mismatch  between  the  number  of  valid
241              directory entries referencing inode ino and the number of refer‐
242              ences recorded in the inode and corrected the the number in  the
243              inode.
244
245       fork-type fork in ino ino claims used block bno
246
247              Inode  ino  claims  a block bno that is used (claimed) by either
248              another inode or the filesystem itself for metadata storage. The
249              fork-type  is either data or attr indicating whether the problem
250              lies in the portion of the inode that tracks regular data or the
251              portion  of  the inode that stores XFS attributes.  If the inode
252              is a real-time (rt) inode, the message says so.  Any inode  that
253              claims blocks used by the filesystem is deleted.  If two or more
254              inodes claim the same block, they are both deleted.
255
256       fork-type fork in ino ino claims dup extent ...
257
258              Inode ino claims a block in an extent known to be  claimed  more
259              than  once.   The  offset  in the inode, start and length of the
260              extent is given.  The message is slightly different if the inode
261              is  a  real-time  (rt) inode and the extent is therefore a real-
262              time (rt) extent.
263
264       inode ino - bad extent ...
265
266              An extent record in the blockmap of inode ino claims blocks that
267              are  out of the legal range of the filesystem.  The message sup‐
268              plies the start, end, and file offset of the extent.   The  mes‐
269              sage  is  slightly  different  if the extent is a real-time (rt)
270              extent.
271
272       bad fork-type fork in inode ino
273
274              There was something structurally wrong or inconsistent with  the
275              data structures that map offsets to filesystem blocks.
276
277       cleared inode ino
278
279              There  was something wrong with the inode that was uncorrectable
280              so the program freed the inode.  This  usually  happens  because
281              the  inode  claims blocks that are used by something else or the
282              inode itself is badly corrupted. Typically, this message is pre‐
283              ceded by one or more messages indicating why the inode needed to
284              be cleared.
285
286       bad attribute fork in inode ino, clearing attr fork
287
288              There was something wrong with the portion  of  the  inode  that
289              stores  XFS attributes (the attribute fork) so the program reset
290              the attribute fork.  As a result of this, all attributes on that
291              inode are lost.
292
293       correcting nextents for inode ino, was x - counted y
294
295              The  program  found that the number of extents used to store the
296              data in the inode is wrong and corrected the number.   The  mes‐
297              sage  refers  to nextents if the count is wrong on the number of
298              extents used to store attribute information.
299
300       entry name in dir dir_ino not consistent with .. value  (xxxx)  in  dir
301       ino ino, junking entry name in directory inode dir_ino
302
303              The entry name in directory inode dir_ino references a directory
304              inode ino.  However, the .. entry  in  directory  ino  does  not
305              point  back  to  directory  dir_ino,  so the program deletes the
306              entry name in directory inode dir_ino.  If the  directory  inode
307              ino  winds up becoming a disconnected inode as a result of this,
308              it is moved to lost+found later.
309
310       entry name in dir dir_ino references already  connected  dir  ino  ino,
311       junking entry name in directory inode dir_ino
312
313              The  entry name in directory inode dir_ino points to a directory
314              inode ino that is known to be  a  child  of  another  directory.
315              Therefore,  the  entry  is invalid and is deleted.  This message
316              refers to an entry in a small directory.  If this were  a  large
317              directory, the last phrase would read "will clear entry".
318
319       entry references free inode ino in directory dir_ino, will clear entry
320
321              An entry in directory inode dir_ino references an inode ino that
322              is known to be free. The  entry  is  therefore  invalid  and  is
323              deleted.   This  message  refers  to  a large directory.  If the
324              directory were small, the  message  would  read  "junking  entry
325              ...".
326

EXIT STATUS

328       xfs_repair  -n (no modify node) will return a status of 1 if filesystem
329       corruption was detected and 0 if no filesystem corruption was detected.
330       xfs_repair  run  without the -n option will always return a status code
331       of 0.
332

BUGS

334       The filesystem to be checked and  repaired  must  have  been  unmounted
335       cleanly  using  normal  system administration procedures (the umount(8)
336       command or system shutdown), not as a  result  of  a  crash  or  system
337       reset.   If the filesystem has not been unmounted cleanly, mount it and
338       unmount it cleanly before running xfs_repair.
339
340       xfs_repair does not do a thorough job on XFS extended attributes.   The
341       structure  of  the attribute fork will be consistent, but only the con‐
342       tents of attribute forks that will fit into an inode are checked.  This
343       limitation will be fixed in the future.
344
345       The no-modify mode (-n option) is not completely accurate.  It does not
346       catch inconsistencies in the freespace  and  inode  maps,  particularly
347       lost blocks or subtly corrupted maps (trees).
348
349       The  no-modify mode can generate repeated warnings about the same prob‐
350       lems because it cannot fix the problems as they are encountered.
351
352       If a filesystem fails to be repaired, a metadump image can be generated
353       with  xfs_metadump(8)  and  be sent to an XFS maintainer to be analysed
354       and xfs_repair fixed and/or improved.
355

SEE ALSO

357       dd(1), mkfs.xfs(8), umount(8), xfs_admin(8), xfs_metadump(8), xfs(5).
358
359
360
361                                                                 xfs_repair(8)
Impressum