Repair XFS Filesystem

Most of V3next VPS Servers are pre-build using XFS filesystem. It is highly scalable modern filesystem, one of the best ones, on par with EXT4. Historically, XFS was mature and well working well before EXT4 established. These days, there are not a big difference in overall performance between XFS and EXT4, both work well.

Sometimes, XFS volumes are damaged for some reason. This is often happening in VPS environments because of virtual IO block devices, which behave not exactly like their more-guaranteed pure hardware equivalents. Lame write caching, alignment problems, partial writes - that's common problems in VPS HDDs, to name a few. That unavoidable feature of value-priced virtualized environments is not a showstopper, but should be treated seriously.

To make clear what is what:


How to Repair Damaged XFS Filesystem

First step in repairing any filesystem is TO MAKE BACKUP OF ANY DATA CURRENTLY STILL READABLE. It is very important step, because very often repair will make things worse. You may require read-only mount to make things more robust while trying to save your data:

mount -o ro,norecovery device mountpoint

After all data is in safe place, let's start repair. In order to repair damaged XFS volume, xfsutils package is required. It is always present in any modern distro. Actually the commands are very simple.

First, you must attempt to mount and unmount XFS normally. This is done via regular read/write mount such as this:

mount device mountpoint
umount mountpoint

Sometimes the system will become unresponsive after mounting broken filesystem. Additional reboot may be required.

It is required to replay transaction log, if it is still present. Sometimes, XFS will not mount and that is OK, then, proceed to the real repair. Which is actually very simple -

xfs_repair -L device

Repair can crash or stop, or you may want to stop it yourself - that is safe. According to XFS manuals, repair can be started and stopped any time.

Fixing Problems with Boot or Root Filesystem

Fixing boot/root volume can be tricky. The only safe thing come to mind is to remount root as read-only, and then to repair it manually. You MUST NOT attempt to repair filesystem while the system is online.

mount -o ro,remount /

And then proceed with the regular repair. After you mount your root read-only, the system will not function normally, so be prepared to do immediate reboot after this recovery attempt.

If this approach fails, you may also consider booting to rescue ISO, contact V3next Support Team to help you with that.

Success and Failure Outcome Ratio

Sad to say, when XFS starts feeling it needs repair, there are some chances that you will lose the data, because key components of the filesystem are badly damaged already. That is especially true for small volumes, where chances are higher that some fault hit important part of the data. Backup may be your first friend here. However, repairing worth a try.

This website uses cookies to ensure you get the best experience on our website.