1xfs_repair(8) System Manager's Manual xfs_repair(8)
2
3
4
6 xfs_repair - repair an XFS filesystem
7
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
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
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 ihash=ihashsize
77 overrides the default inode cache hash size. The total
78 number of inode cache entries are limited to 8 times
79 this amount. The default ihashsize is 1024 (for a
80 total of 8192 entries).
81
82 bhash=bhashsize
83 overrides the default buffer cache hash size. The
84 total number of buffer cache entries are limited to 8
85 times this amount. The default size is set to use up
86 the remainder of 75% of the system's physical RAM
87 size.
88
89 ag_stride=ags_per_concat_unit
90 This creates additional processing threads to parallel
91 process AGs that span multiple concat units. This can
92 significantly reduce repair times on concat based
93 filesystems.
94
95 force_geometry
96 Check the filesystem even if geometry information
97 could not be validated. Geometry information can not
98 be validated if only a single allocation group and
99 exist and thus we do not have a backup superblock
100 available, or if there are two allocation groups and
101 the two superblocks do not agree on the filesystem
102 geometry. Only use this option if you validated the
103 geometry yourself and know what you are doing. If In
104 doubt run in no modify mode first.
105
106 -t interval
107 Modify reporting interval. During long runs xfs_repair outputs
108 its progress every 15 minutes. Reporting is only activated when
109 ag_stride is enabled.
110
111 -v Verbose output.
112
113 -d Repair dangerously. Allow xfs_repair to repair an XFS filesystem
114 mounted read only. This is typically done on a root fileystem
115 from single user mode, immediately followed by a reboot.
116
117 -V Prints out the current version number and exits.
118
119 Checks Performed
120 Inconsistencies corrected include the following:
121
122 1. Inode and inode blockmap (addressing) checks: bad magic number
123 in inode, bad magic numbers in inode blockmap blocks, extents
124 out of order, incorrect number of records in inode blockmap
125 blocks, blocks claimed that are not in a legal data area of the
126 filesystem, blocks that are claimed by more than one inode.
127
128 2. Inode allocation map checks: bad magic number in inode map
129 blocks, inode state as indicated by map (free or in-use) incon‐
130 sistent with state indicated by the inode, inodes referenced by
131 the filesystem that do not appear in the inode allocation map,
132 inode allocation map referencing blocks that do not appear to
133 contain inodes.
134
135 3. Size checks: number of blocks claimed by inode inconsistent with
136 inode size, directory size not block aligned, inode size not
137 consistent with inode format.
138
139 4. Directory checks: bad magic numbers in directory blocks, incor‐
140 rect number of entries in a directory block, bad freespace
141 information in a directory leaf block, entry pointing to an
142 unallocated (free) or out of range inode, overlapping entries,
143 missing or incorrect dot and dotdot entries, entries out of
144 hashvalue order, incorrect internal directory pointers, direc‐
145 tory type not consistent with inode format and size.
146
147 5. Pathname checks: files or directories not referenced by a path‐
148 name starting from the filesystem root, illegal pathname compo‐
149 nents.
150
151 6. Link count checks: link counts that do not agree with the number
152 of directory references to the inode.
153
154 7. Freemap checks: blocks claimed free by the freemap but also
155 claimed by an inode, blocks unclaimed by any inode but not
156 appearing in the freemap.
157
158 8. Super Block checks: total free block and/or free i-node count
159 incorrect, filesystem geometry inconsistent, secondary and pri‐
160 mary superblocks contradictory.
161
162 Orphaned files and directories (allocated, in-use but unreferenced) are
163 reconnected by placing them in the lost+found directory. The name
164 assigned is the inode number.
165
166 Disk Errors
167 xfs_repair aborts on most disk I/O errors. Therefore, if you are trying
168 to repair a filesystem that was damaged due to a disk drive failure,
169 steps should be taken to ensure that all blocks in the filesystem are
170 readable and writeable before attempting to use xfs_repair to repair
171 the filesystem. A possible method is using dd(8) to copy the data onto
172 a good disk.
173
174 lost+found
175 The directory lost+found does not have to already exist in the filesys‐
176 tem being repaired. If the directory does not exist, it is automati‐
177 cally created if required. If it already exists, it will be checked
178 for consistency and if valid will be used for additional orphaned
179 files. Invalid lost+found directories are removed and recreated. Exist‐
180 ing files in a valid lost+found are not removed or renamed.
181
182 Corrupted Superblocks
183 XFS has both primary and secondary superblocks. xfs_repair uses infor‐
184 mation in the primary superblock to automatically find and validate the
185 primary superblock against the secondary superblocks before proceeding.
186 Should the primary be too corrupted to be useful in locating the sec‐
187 ondary superblocks, the program scans the filesystem until it finds and
188 validates some secondary superblocks. At that point, it generates a
189 primary superblock.
190
191 Quotas
192 If quotas are in use, it is possible that xfs_repair will clear some or
193 all of the filesystem quota information. If so, the program issues a
194 warning just before it terminates. If all quota information is lost,
195 quotas are disabled and the program issues a warning to that effect.
196
197 Note that xfs_repair does not check the validity of quota limits. It is
198 recommended that you check the quota limit information manually after
199 xfs_repair. Also, space usage information is automatically regenerated
200 the next time the filesystem is mounted with quotas turned on, so the
201 next quota mount of the filesystem may take some time.
202
204 xfs_repair issues informative messages as it proceeds indicating what
205 it has found that is abnormal or any corrective action that it has
206 taken. Most of the messages are completely understandable only to
207 those who are knowledgeable about the structure of the filesystem.
208 Some of the more common messages are explained here. Note that the
209 language of the messages is slightly different if xfs_repair is run in
210 no-modify mode because the program is not changing anything on disk.
211 No-modify mode indicates what it would do to repair the filesystem if
212 run without the no-modify flag.
213
214 disconnected inode ino, moving to lost+found
215
216 An inode numbered ino was not connected to the filesystem direc‐
217 tory tree and was reconnected to the lost+found directory. The
218 inode is assigned the name of its inode number (ino). If a
219 lost+found directory does not exist, it is automatically cre‐
220 ated.
221
222 disconnected dir inode ino, moving to lost+found
223
224 As above only the inode is a directory inode. If a directory
225 inode is attached to lost+found, all of its children (if any)
226 stay attached to the directory and therefore get automatically
227 reconnected when the directory is reconnected.
228
229 imap claims in-use inode ino is free, correcting imap
230
231 The inode allocation map thinks that inode ino is free whereas
232 examination of the inode indicates that the inode may be in use
233 (although it may be disconnected). The program updates the
234 inode allocation map.
235
236 imap claims free inode ino is in use, correcting imap
237
238 The inode allocation map thinks that inode ino is in use whereas
239 examination of the inode indicates that the inode is not in use
240 and therefore is free. The program updates the inode allocation
241 map.
242
243 resetting inode ino nlinks from x to y
244
245 The program detected a mismatch between the number of valid
246 directory entries referencing inode ino and the number of refer‐
247 ences recorded in the inode and corrected the the number in the
248 inode.
249
250 fork-type fork in ino ino claims used block bno
251
252 Inode ino claims a block bno that is used (claimed) by either
253 another inode or the filesystem itself for metadata storage. The
254 fork-type is either data or attr indicating whether the problem
255 lies in the portion of the inode that tracks regular data or the
256 portion of the inode that stores XFS attributes. If the inode
257 is a real-time (rt) inode, the message says so. Any inode that
258 claims blocks used by the filesystem is deleted. If two or more
259 inodes claim the same block, they are both deleted.
260
261 fork-type fork in ino ino claims dup extent ...
262
263 Inode ino claims a block in an extent known to be claimed more
264 than once. The offset in the inode, start and length of the
265 extent is given. The message is slightly different if the inode
266 is a real-time (rt) inode and the extent is therefore a real-
267 time (rt) extent.
268
269 inode ino - bad extent ...
270
271 An extent record in the blockmap of inode ino claims blocks that
272 are out of the legal range of the filesystem. The message sup‐
273 plies the start, end, and file offset of the extent. The mes‐
274 sage is slightly different if the extent is a real-time (rt)
275 extent.
276
277 bad fork-type fork in inode ino
278
279 There was something structurally wrong or inconsistent with the
280 data structures that map offsets to filesystem blocks.
281
282 cleared inode ino
283
284 There was something wrong with the inode that was uncorrectable
285 so the program freed the inode. This usually happens because
286 the inode claims blocks that are used by something else or the
287 inode itself is badly corrupted. Typically, this message is pre‐
288 ceded by one or more messages indicating why the inode needed to
289 be cleared.
290
291 bad attribute fork in inode ino, clearing attr fork
292
293 There was something wrong with the portion of the inode that
294 stores XFS attributes (the attribute fork) so the program reset
295 the attribute fork. As a result of this, all attributes on that
296 inode are lost.
297
298 correcting nextents for inode ino, was x - counted y
299
300 The program found that the number of extents used to store the
301 data in the inode is wrong and corrected the number. The mes‐
302 sage refers to nextents if the count is wrong on the number of
303 extents used to store attribute information.
304
305 entry name in dir dir_ino not consistent with .. value (xxxx) in dir
306 ino ino, junking entry name in directory inode dir_ino
307
308 The entry name in directory inode dir_ino references a directory
309 inode ino. However, the .. entry in directory ino does not
310 point back to directory dir_ino, so the program deletes the
311 entry name in directory inode dir_ino. If the directory inode
312 ino winds up becoming a disconnected inode as a result of this,
313 it is moved to lost+found later.
314
315 entry name in dir dir_ino references already connected dir ino ino,
316 junking entry name in directory inode dir_ino
317
318 The entry name in directory inode dir_ino points to a directory
319 inode ino that is known to be a child of another directory.
320 Therefore, the entry is invalid and is deleted. This message
321 refers to an entry in a small directory. If this were a large
322 directory, the last phrase would read "will clear entry".
323
324 entry references free inode ino in directory dir_ino, will clear entry
325
326 An entry in directory inode dir_ino references an inode ino that
327 is known to be free. The entry is therefore invalid and is
328 deleted. This message refers to a large directory. If the
329 directory were small, the message would read "junking entry
330 ...".
331
333 xfs_repair -n (no modify node) will return a status of 1 if filesystem
334 corruption was detected and 0 if no filesystem corruption was detected.
335 xfs_repair run without the -n option will always return a status code
336 of 0.
337
339 The filesystem to be checked and repaired must have been unmounted
340 cleanly using normal system administration procedures (the umount(8)
341 command or system shutdown), not as a result of a crash or system
342 reset. If the filesystem has not been unmounted cleanly, mount it and
343 unmount it cleanly before running xfs_repair.
344
345 xfs_repair does not do a thorough job on XFS extended attributes. The
346 structure of the attribute fork will be consistent, but only the con‐
347 tents of attribute forks that will fit into an inode are checked. This
348 limitation will be fixed in the future.
349
350 The no-modify mode (-n option) is not completely accurate. It does not
351 catch inconsistencies in the freespace and inode maps, particularly
352 lost blocks or subtly corrupted maps (trees).
353
354 The no-modify mode can generate repeated warnings about the same prob‐
355 lems because it cannot fix the problems as they are encountered.
356
357 If a filesystem fails to be repaired, a metadump image can be generated
358 with xfs_metadump(8) and be sent to an XFS maintainer to be analysed
359 and xfs_repair fixed and/or improved.
360
362 dd(1), mkfs.xfs(8), umount(8), xfs_admin(8), xfs_check(8), xfs_metad‐
363 ump(8), xfs(5).
364
365
366
367 xfs_repair(8)