1xfs_repair(8) System Manager's Manual xfs_repair(8)
2
3
4
6 xfs_repair - repair an XFS filesystem
7
9 xfs_repair [ -dfLPv ] [ -n | -e ] [ -m maxmem ] [ -c subopt=value ] [
10 -o subopt[=value] ] [ -t interval ] [ -l logdev ] [ -r rtdev ] device
11 xfs_repair -V
12
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
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 ex‐
29 ternal 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. See the DIRTY LOGS section
35 for more information.
36
37 -l logdev
38 Specifies the device special file where the filesystem's exter‐
39 nal log resides. Only for those filesystems which use an exter‐
40 nal log. See the mkfs.xfs -l option, and refer to xfs(5) for a
41 detailed description of the XFS log.
42
43 -r rtdev
44 Specifies the device special file where the filesystem's real‐
45 time section resides. Only for those filesystems which use a re‐
46 altime section. See the mkfs.xfs -r option, and refer to xfs(5)
47 for a detailed description of the XFS realtime section.
48
49 -n No modify mode. Specifies that xfs_repair should not modify the
50 filesystem but should only scan the filesystem and indicate what
51 repairs would have been made. This option cannot be used to‐
52 gether with -e.
53
54 -P Disable prefetching of inode and directory blocks. Use this op‐
55 tion if you find xfs_repair gets stuck and stops proceeding. In‐
56 terrupting a stuck xfs_repair is safe.
57
58 -m maxmem
59 Specifies the approximate maximum amount of memory, in
60 megabytes, to use for xfs_repair. xfs_repair has its own inter‐
61 nal block cache which will scale out up to the lesser of the
62 process's virtual address limit or about 75% of the system's
63 physical RAM. This option overrides these limits.
64
65 NOTE: These memory limits are only approximate and may use more
66 than the specified limit.
67
68 -c subopt=value
69 Change filesystem parameters. Refer to xfs_admin(8) for informa‐
70 tion on changing filesystem parameters.
71
72 -o subopt[=value]
73 Override what the program might conclude about the filesystem if
74 left to its own devices.
75
76 The suboptions supported are:
77
78 bhash=bhashsize
79 overrides the default buffer cache hash size. The to‐
80 tal number of buffer cache entries are limited to 8
81 times this amount. The default size is set to use up
82 the remainder of 75% of the system's physical RAM
83 size.
84
85 ag_stride=ags_per_concat_unit
86 This creates additional processing threads to parallel
87 process AGs that span multiple concat units. This can
88 significantly reduce repair times on concat based
89 filesystems.
90
91 force_geometry
92 Check the filesystem even if geometry information
93 could not be validated. Geometry information can not
94 be validated if only a single allocation group exists
95 and thus we do not have a backup superblock available,
96 or if there are two allocation groups and the two su‐
97 perblocks do not agree on the filesystem geometry.
98 Only use this option if you validated the geometry
99 yourself and know what you are doing. If In doubt run
100 in no modify mode first.
101
102 noquota
103 Don't validate quota counters at all. Quotacheck will
104 be run during the next mount to recalculate all val‐
105 ues.
106
107 -t interval
108 Modify reporting interval, specified in seconds. During long
109 runs xfs_repair outputs its progress every 15 minutes. Reporting
110 is only activated when ag_stride is enabled.
111
112 -v Verbose output. May be specified multiple times to increase
113 verbosity.
114
115 -d Repair dangerously. Allow xfs_repair to repair an XFS filesystem
116 mounted read only. This is typically done on a root filesystem
117 from single user mode, immediately followed by a reboot.
118
119 -e If any metadata corruption was repaired, the status returned is
120 4 instead of the usual 0. This option cannot be used together
121 with -n.
122
123 -V Prints the version number and exits.
124
125 Checks Performed
126 Inconsistencies corrected include the following:
127
128 1. Inode and inode blockmap (addressing) checks: bad magic number
129 in inode, bad magic numbers in inode blockmap blocks, extents
130 out of order, incorrect number of records in inode blockmap
131 blocks, blocks claimed that are not in a legal data area of the
132 filesystem, blocks that are claimed by more than one inode.
133
134 2. Inode allocation map checks: bad magic number in inode map
135 blocks, inode state as indicated by map (free or in-use) incon‐
136 sistent with state indicated by the inode, inodes referenced by
137 the filesystem that do not appear in the inode allocation map,
138 inode allocation map referencing blocks that do not appear to
139 contain inodes.
140
141 3. Size checks: number of blocks claimed by inode inconsistent with
142 inode size, directory size not block aligned, inode size not
143 consistent with inode format.
144
145 4. Directory checks: bad magic numbers in directory blocks, incor‐
146 rect number of entries in a directory block, bad freespace in‐
147 formation in a directory leaf block, entry pointing to an unal‐
148 located (free) or out of range inode, overlapping entries, miss‐
149 ing or incorrect dot and dotdot entries, entries out of hash‐
150 value order, incorrect internal directory pointers, directory
151 type not consistent with inode format and size.
152
153 5. Pathname checks: files or directories not referenced by a path‐
154 name starting from the filesystem root, illegal pathname compo‐
155 nents.
156
157 6. Link count checks: link counts that do not agree with the number
158 of directory references to the inode.
159
160 7. Freemap checks: blocks claimed free by the freemap but also
161 claimed by an inode, blocks unclaimed by any inode but not ap‐
162 pearing in the freemap.
163
164 8. Super Block checks: total free block and/or free i-node count
165 incorrect, filesystem geometry inconsistent, secondary and pri‐
166 mary superblocks contradictory.
167
168 Orphaned files and directories (allocated, in-use but unreferenced) are
169 reconnected by placing them in the lost+found directory. The name as‐
170 signed is the inode number.
171
172 Disk Errors
173 xfs_repair aborts on most disk I/O errors. Therefore, if you are trying
174 to repair a filesystem that was damaged due to a disk drive failure,
175 steps should be taken to ensure that all blocks in the filesystem are
176 readable and writable before attempting to use xfs_repair to repair the
177 filesystem. A possible method is using dd(8) to copy the data onto a
178 good disk.
179
180 lost+found
181 The directory lost+found does not have to already exist in the filesys‐
182 tem being repaired. If the directory does not exist, it is automati‐
183 cally created if required. If it already exists, it will be checked
184 for consistency and if valid will be used for additional orphaned
185 files. Invalid lost+found directories are removed and recreated. Exist‐
186 ing files in a valid lost+found are not removed or renamed.
187
188 Corrupted Superblocks
189 XFS has both primary and secondary superblocks. xfs_repair uses infor‐
190 mation in the primary superblock to automatically find and validate the
191 primary superblock against the secondary superblocks before proceeding.
192 Should the primary be too corrupted to be useful in locating the sec‐
193 ondary superblocks, the program scans the filesystem until it finds and
194 validates some secondary superblocks. At that point, it generates a
195 primary superblock.
196
197 Quotas
198 If quotas are in use, it is possible that xfs_repair will clear some or
199 all of the filesystem quota information. If so, the program issues a
200 warning just before it terminates. If all quota information is lost,
201 quotas are disabled and the program issues a warning to that effect.
202
203 Note that xfs_repair does not check the validity of quota limits. It is
204 recommended that you check the quota limit information manually after
205 xfs_repair. Also, space usage information is automatically regenerated
206 the next time the filesystem is mounted with quotas turned on, so the
207 next quota mount of the filesystem may take some time.
208
210 xfs_repair issues informative messages as it proceeds indicating what
211 it has found that is abnormal or any corrective action that it has
212 taken. Most of the messages are completely understandable only to
213 those who are knowledgeable about the structure of the filesystem.
214 Some of the more common messages are explained here. Note that the
215 language of the messages is slightly different if xfs_repair is run in
216 no-modify mode because the program is not changing anything on disk.
217 No-modify mode indicates what it would do to repair the filesystem if
218 run without the no-modify flag.
219
220 disconnected inode ino, moving to lost+found
221
222 An inode numbered ino was not connected to the filesystem direc‐
223 tory tree and was reconnected to the lost+found directory. The
224 inode is assigned the name of its inode number (ino). If a
225 lost+found directory does not exist, it is automatically cre‐
226 ated.
227
228 disconnected dir inode ino, moving to lost+found
229
230 As above only the inode is a directory inode. If a directory
231 inode is attached to lost+found, all of its children (if any)
232 stay attached to the directory and therefore get automatically
233 reconnected when the directory is reconnected.
234
235 imap claims in-use inode ino is free, correcting imap
236
237 The inode allocation map thinks that inode ino is free whereas
238 examination of the inode indicates that the inode may be in use
239 (although it may be disconnected). The program updates the in‐
240 ode allocation map.
241
242 imap claims free inode ino is in use, correcting imap
243
244 The inode allocation map thinks that inode ino is in use whereas
245 examination of the inode indicates that the inode is not in use
246 and therefore is free. The program updates the inode allocation
247 map.
248
249 resetting inode ino nlinks from x to y
250
251 The program detected a mismatch between the number of valid di‐
252 rectory entries referencing inode ino and the number of refer‐
253 ences recorded in the inode and corrected the the number in the
254 inode.
255
256 fork-type fork in ino ino claims used block bno
257
258 Inode ino claims a block bno that is used (claimed) by either
259 another inode or the filesystem itself for metadata storage. The
260 fork-type is either data or attr indicating whether the problem
261 lies in the portion of the inode that tracks regular data or the
262 portion of the inode that stores XFS attributes. If the inode
263 is a real-time (rt) inode, the message says so. Any inode that
264 claims blocks used by the filesystem is deleted. If two or more
265 inodes claim the same block, they are both deleted.
266
267 fork-type fork in ino ino claims dup extent ...
268
269 Inode ino claims a block in an extent known to be claimed more
270 than once. The offset in the inode, start and length of the ex‐
271 tent is given. The message is slightly different if the inode
272 is a real-time (rt) inode and the extent is therefore a real-
273 time (rt) extent.
274
275 inode ino - bad extent ...
276
277 An extent record in the blockmap of inode ino claims blocks that
278 are out of the legal range of the filesystem. The message sup‐
279 plies the start, end, and file offset of the extent. The mes‐
280 sage is slightly different if the extent is a real-time (rt) ex‐
281 tent.
282
283 bad fork-type fork in inode ino
284
285 There was something structurally wrong or inconsistent with the
286 data structures that map offsets to filesystem blocks.
287
288 cleared inode ino
289
290 There was something wrong with the inode that was uncorrectable
291 so the program freed the inode. This usually happens because
292 the inode claims blocks that are used by something else or the
293 inode itself is badly corrupted. Typically, this message is pre‐
294 ceded by one or more messages indicating why the inode needed to
295 be cleared.
296
297 bad attribute fork in inode ino, clearing attr fork
298
299 There was something wrong with the portion of the inode that
300 stores XFS attributes (the attribute fork) so the program reset
301 the attribute fork. As a result of this, all attributes on that
302 inode are lost.
303
304 correcting nextents for inode ino, was x - counted y
305
306 The program found that the number of extents used to store the
307 data in the inode is wrong and corrected the number. The mes‐
308 sage refers to nextents if the count is wrong on the number of
309 extents used to store attribute information.
310
311 entry name in dir dir_ino not consistent with .. value (xxxx) in dir
312 ino ino, junking entry name in directory inode dir_ino
313
314 The entry name in directory inode dir_ino references a directory
315 inode ino. However, the .. entry in directory ino does not
316 point back to directory dir_ino, so the program deletes the en‐
317 try name in directory inode dir_ino. If the directory inode ino
318 winds up becoming a disconnected inode as a result of this, it
319 is moved to lost+found later.
320
321 entry name in dir dir_ino references already connected dir ino ino,
322 junking entry name in directory inode dir_ino
323
324 The entry name in directory inode dir_ino points to a directory
325 inode ino that is known to be a child of another directory.
326 Therefore, the entry is invalid and is deleted. This message
327 refers to an entry in a small directory. If this were a large
328 directory, the last phrase would read "will clear entry".
329
330 entry references free inode ino in directory dir_ino, will clear entry
331
332 An entry in directory inode dir_ino references an inode ino that
333 is known to be free. The entry is therefore invalid and is
334 deleted. This message refers to a large directory. If the di‐
335 rectory were small, the message would read "junking entry ...".
336
338 xfs_repair -n (no modify mode) will return a status of 1 if filesystem
339 corruption was detected and 0 if no filesystem corruption was detected.
340 xfs_repair run without the -n option will always return a status code
341 of 0 if it completes without problems, unless the flag -e is used. If
342 it is used, then status 4 is reported when any issue with the filesys‐
343 tem was found, but could be fixed. If a runtime error is encountered
344 during operation, it will return a status of 1. In this case, xfs_re‐
345 pair should be restarted. If xfs_repair is unable to proceed due to a
346 dirty log, it will return a status of 2. See below.
347
349 Due to the design of the XFS log, a dirty log can only be replayed by
350 the kernel, on a machine having the same CPU architecture as the ma‐
351 chine which was writing to the log. xfs_repair cannot replay a dirty
352 log and will exit with a status code of 2 when it detects a dirty log.
353
354 In this situation, the log can be replayed by mounting and immediately
355 unmounting the filesystem on the same class of machine that crashed.
356 Please make sure that the machine's hardware is reliable before replay‐
357 ing to avoid compounding the problems.
358
359 If mounting fails, the log can be erased by running xfs_repair with the
360 -L option. All metadata updates in progress at the time of the crash
361 will be lost, which may cause significant filesystem damage. This
362 should only be used as a last resort.
363
365 The filesystem to be checked and repaired must have been unmounted
366 cleanly using normal system administration procedures (the umount(8)
367 command or system shutdown), not as a result of a crash or system re‐
368 set. If the filesystem has not been unmounted cleanly, mount it and
369 unmount it cleanly before running xfs_repair.
370
371 xfs_repair does not do a thorough job on XFS extended attributes. The
372 structure of the attribute fork will be consistent, but only the con‐
373 tents of attribute forks that will fit into an inode are checked. This
374 limitation will be fixed in the future.
375
376 The no-modify mode (-n option) is not completely accurate. It does not
377 catch inconsistencies in the freespace and inode maps, particularly
378 lost blocks or subtly corrupted maps (trees).
379
380 The no-modify mode can generate repeated warnings about the same prob‐
381 lems because it cannot fix the problems as they are encountered.
382
383 If a filesystem fails to be repaired, a metadump image can be generated
384 with xfs_metadump(8) and be sent to an XFS maintainer to be analysed
385 and xfs_repair fixed and/or improved.
386
388 dd(1), mkfs.xfs(8), umount(8), xfs_admin(8), xfs_metadump(8), xfs(5).
389
390
391
392 xfs_repair(8)