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 The correctness of the crc32c checksum implementation will be tested
127 before examining the filesystem. If the test fails, the program will
128 abort.
129
130 Inconsistencies corrected include the following:
131
132 1. Inode and inode blockmap (addressing) checks: bad magic number
133 in inode, bad magic numbers in inode blockmap blocks, extents
134 out of order, incorrect number of records in inode blockmap
135 blocks, blocks claimed that are not in a legal data area of the
136 filesystem, blocks that are claimed by more than one inode.
137
138 2. Inode allocation map checks: bad magic number in inode map
139 blocks, inode state as indicated by map (free or in-use) incon‐
140 sistent with state indicated by the inode, inodes referenced by
141 the filesystem that do not appear in the inode allocation map,
142 inode allocation map referencing blocks that do not appear to
143 contain inodes.
144
145 3. Size checks: number of blocks claimed by inode inconsistent with
146 inode size, directory size not block aligned, inode size not
147 consistent with inode format.
148
149 4. Directory checks: bad magic numbers in directory blocks, incor‐
150 rect number of entries in a directory block, bad freespace in‐
151 formation in a directory leaf block, entry pointing to an unal‐
152 located (free) or out of range inode, overlapping entries, miss‐
153 ing or incorrect dot and dotdot entries, entries out of hash‐
154 value order, incorrect internal directory pointers, directory
155 type not consistent with inode format and size.
156
157 5. Pathname checks: files or directories not referenced by a path‐
158 name starting from the filesystem root, illegal pathname compo‐
159 nents.
160
161 6. Link count checks: link counts that do not agree with the number
162 of directory references to the inode.
163
164 7. Freemap checks: blocks claimed free by the freemap but also
165 claimed by an inode, blocks unclaimed by any inode but not ap‐
166 pearing in the freemap.
167
168 8. Super Block checks: total free block and/or free i-node count
169 incorrect, filesystem geometry inconsistent, secondary and pri‐
170 mary superblocks contradictory.
171
172 Orphaned files and directories (allocated, in-use but unreferenced) are
173 reconnected by placing them in the lost+found directory. The name as‐
174 signed is the inode number.
175
176 Disk Errors
177 xfs_repair aborts on most disk I/O errors. Therefore, if you are trying
178 to repair a filesystem that was damaged due to a disk drive failure,
179 steps should be taken to ensure that all blocks in the filesystem are
180 readable and writable before attempting to use xfs_repair to repair the
181 filesystem. A possible method is using dd(8) to copy the data onto a
182 good disk.
183
184 lost+found
185 The directory lost+found does not have to already exist in the filesys‐
186 tem being repaired. If the directory does not exist, it is automati‐
187 cally created if required. If it already exists, it will be checked
188 for consistency and if valid will be used for additional orphaned
189 files. Invalid lost+found directories are removed and recreated. Exist‐
190 ing files in a valid lost+found are not removed or renamed.
191
192 Corrupted Superblocks
193 XFS has both primary and secondary superblocks. xfs_repair uses infor‐
194 mation in the primary superblock to automatically find and validate the
195 primary superblock against the secondary superblocks before proceeding.
196 Should the primary be too corrupted to be useful in locating the sec‐
197 ondary superblocks, the program scans the filesystem until it finds and
198 validates some secondary superblocks. At that point, it generates a
199 primary superblock.
200
201 Quotas
202 If quotas are in use, it is possible that xfs_repair will clear some or
203 all of the filesystem quota information. If so, the program issues a
204 warning just before it terminates. If all quota information is lost,
205 quotas are disabled and the program issues a warning to that effect.
206
207 Note that xfs_repair does not check the validity of quota limits. It is
208 recommended that you check the quota limit information manually after
209 xfs_repair. Also, space usage information is automatically regenerated
210 the next time the filesystem is mounted with quotas turned on, so the
211 next quota mount of the filesystem may take some time.
212
214 xfs_repair issues informative messages as it proceeds indicating what
215 it has found that is abnormal or any corrective action that it has
216 taken. Most of the messages are completely understandable only to
217 those who are knowledgeable about the structure of the filesystem.
218 Some of the more common messages are explained here. Note that the
219 language of the messages is slightly different if xfs_repair is run in
220 no-modify mode because the program is not changing anything on disk.
221 No-modify mode indicates what it would do to repair the filesystem if
222 run without the no-modify flag.
223
224 disconnected inode ino, moving to lost+found
225
226 An inode numbered ino was not connected to the filesystem direc‐
227 tory tree and was reconnected to the lost+found directory. The
228 inode is assigned the name of its inode number (ino). If a
229 lost+found directory does not exist, it is automatically cre‐
230 ated.
231
232 disconnected dir inode ino, moving to lost+found
233
234 As above only the inode is a directory inode. If a directory
235 inode is attached to lost+found, all of its children (if any)
236 stay attached to the directory and therefore get automatically
237 reconnected when the directory is reconnected.
238
239 imap claims in-use inode ino is free, correcting imap
240
241 The inode allocation map thinks that inode ino is free whereas
242 examination of the inode indicates that the inode may be in use
243 (although it may be disconnected). The program updates the in‐
244 ode allocation map.
245
246 imap claims free inode ino is in use, correcting imap
247
248 The inode allocation map thinks that inode ino is in use whereas
249 examination of the inode indicates that the inode is not in use
250 and therefore is free. The program updates the inode allocation
251 map.
252
253 resetting inode ino nlinks from x to y
254
255 The program detected a mismatch between the number of valid di‐
256 rectory entries referencing inode ino and the number of refer‐
257 ences recorded in the inode and corrected the the number in the
258 inode.
259
260 fork-type fork in ino ino claims used block bno
261
262 Inode ino claims a block bno that is used (claimed) by either
263 another inode or the filesystem itself for metadata storage. The
264 fork-type is either data or attr indicating whether the problem
265 lies in the portion of the inode that tracks regular data or the
266 portion of the inode that stores XFS attributes. If the inode
267 is a real-time (rt) inode, the message says so. Any inode that
268 claims blocks used by the filesystem is deleted. If two or more
269 inodes claim the same block, they are both deleted.
270
271 fork-type fork in ino ino claims dup extent ...
272
273 Inode ino claims a block in an extent known to be claimed more
274 than once. The offset in the inode, start and length of the ex‐
275 tent is given. The message is slightly different if the inode
276 is a real-time (rt) inode and the extent is therefore a real-
277 time (rt) extent.
278
279 inode ino - bad extent ...
280
281 An extent record in the blockmap of inode ino claims blocks that
282 are out of the legal range of the filesystem. The message sup‐
283 plies the start, end, and file offset of the extent. The mes‐
284 sage is slightly different if the extent is a real-time (rt) ex‐
285 tent.
286
287 bad fork-type fork in inode ino
288
289 There was something structurally wrong or inconsistent with the
290 data structures that map offsets to filesystem blocks.
291
292 cleared inode ino
293
294 There was something wrong with the inode that was uncorrectable
295 so the program freed the inode. This usually happens because
296 the inode claims blocks that are used by something else or the
297 inode itself is badly corrupted. Typically, this message is pre‐
298 ceded by one or more messages indicating why the inode needed to
299 be cleared.
300
301 bad attribute fork in inode ino, clearing attr fork
302
303 There was something wrong with the portion of the inode that
304 stores XFS attributes (the attribute fork) so the program reset
305 the attribute fork. As a result of this, all attributes on that
306 inode are lost.
307
308 correcting nextents for inode ino, was x - counted y
309
310 The program found that the number of extents used to store the
311 data in the inode is wrong and corrected the number. The mes‐
312 sage refers to nextents if the count is wrong on the number of
313 extents used to store attribute information.
314
315 entry name in dir dir_ino not consistent with .. value (xxxx) in dir
316 ino ino, junking entry name in directory inode dir_ino
317
318 The entry name in directory inode dir_ino references a directory
319 inode ino. However, the .. entry in directory ino does not
320 point back to directory dir_ino, so the program deletes the en‐
321 try name in directory inode dir_ino. If the directory inode ino
322 winds up becoming a disconnected inode as a result of this, it
323 is moved to lost+found later.
324
325 entry name in dir dir_ino references already connected dir ino ino,
326 junking entry name in directory inode dir_ino
327
328 The entry name in directory inode dir_ino points to a directory
329 inode ino that is known to be a child of another directory.
330 Therefore, the entry is invalid and is deleted. This message
331 refers to an entry in a small directory. If this were a large
332 directory, the last phrase would read "will clear entry".
333
334 entry references free inode ino in directory dir_ino, will clear entry
335
336 An entry in directory inode dir_ino references an inode ino that
337 is known to be free. The entry is therefore invalid and is
338 deleted. This message refers to a large directory. If the di‐
339 rectory were small, the message would read "junking entry ...".
340
342 xfs_repair -n (no modify mode) will return a status of 1 if filesystem
343 corruption was detected and 0 if no filesystem corruption was detected.
344 xfs_repair run without the -n option will always return a status code
345 of 0 if it completes without problems, unless the flag -e is used. If
346 it is used, then status 4 is reported when any issue with the filesys‐
347 tem was found, but could be fixed. If a runtime error is encountered
348 during operation, it will return a status of 1. In this case, xfs_re‐
349 pair should be restarted. If xfs_repair is unable to proceed due to a
350 dirty log, it will return a status of 2. See below.
351
353 Due to the design of the XFS log, a dirty log can only be replayed by
354 the kernel, on a machine having the same CPU architecture as the ma‐
355 chine which was writing to the log. xfs_repair cannot replay a dirty
356 log and will exit with a status code of 2 when it detects a dirty log.
357
358 In this situation, the log can be replayed by mounting and immediately
359 unmounting the filesystem on the same class of machine that crashed.
360 Please make sure that the machine's hardware is reliable before replay‐
361 ing to avoid compounding the problems.
362
363 If mounting fails, the log can be erased by running xfs_repair with the
364 -L option. All metadata updates in progress at the time of the crash
365 will be lost, which may cause significant filesystem damage. This
366 should only be used as a last resort.
367
369 The filesystem to be checked and repaired must have been unmounted
370 cleanly using normal system administration procedures (the umount(8)
371 command or system shutdown), not as a result of a crash or system re‐
372 set. If the filesystem has not been unmounted cleanly, mount it and
373 unmount it cleanly before running xfs_repair.
374
375 xfs_repair does not do a thorough job on XFS extended attributes. The
376 structure of the attribute fork will be consistent, but only the con‐
377 tents of attribute forks that will fit into an inode are checked. This
378 limitation will be fixed in the future.
379
380 The no-modify mode (-n option) is not completely accurate. It does not
381 catch inconsistencies in the freespace and inode maps, particularly
382 lost blocks or subtly corrupted maps (trees).
383
384 The no-modify mode can generate repeated warnings about the same prob‐
385 lems because it cannot fix the problems as they are encountered.
386
387 If a filesystem fails to be repaired, a metadump image can be generated
388 with xfs_metadump(8) and be sent to an XFS maintainer to be analysed
389 and xfs_repair fixed and/or improved.
390
392 dd(1), mkfs.xfs(8), umount(8), xfs_admin(8), xfs_metadump(8), xfs(5).
393
394
395
396 xfs_repair(8)