Btrfs file system repair skills

Source: Internet
Author: User

Btrfs file system repair skills

Btrfs File System Tools gradually mature with the kernel version advances, but it is inevitable that there will be some accidents in the use process. What should I do if the mounting fails?

If other file systems are abnormal, the first response is, of coursefsckTools ~ However, if you run it on a terminal, you will get the following result:

  • Nothing happened ......
  • If you want to repair the file system, usebtrfs checkSub-commands

Slow! Hitting a wall or calling it decisivelybtrfs checkBefore that, note that btrfs file systems are not like other file systems and are not required in most cases.fsckThis is not working.fsckTo be compatiblefstabNon-0 error infs_passnoSet.

Slow down!btrfs checkIt is a fierce medicine, and it may be counterproductive to use it rashly. So what should we do next?

Mount with the latest kernel

The file system format of Btrfs on the disk has been stabilized, but various kernel and user tools are still being developed. Many errors or problems can be solved by using the new kernel that contains the fix.

Assume that you have guided the Live environment containing the latest kernel in any way, you can first tryrecovery,roOption to mount the btrfs file.

Then observedmesgOrjournalctl -kIs there any btrfs-related kernel oops.

If there is no exception, check the last accessed file and check whether it exists. Because of the COW mechanism of Btrfs, most of the situations should be in place.

If there is only kernel oops, usebtrfs-zero-logTry to fix it.

Remount and check for exceptions

If the read-only mounting is normal and there is no kernel oops in the previous step, you can try the normal read/write mounting.

If you are lucky, there is no problem. It may mean that the mounting exception has been fixed in the new kernel. However, we recommend that you executebtrfs scrub startCommand to check all files and Their checksum.

btrfs scrubIt is a command running in the background, which takes a long time. It takes about 26 minutes to complete this operation on the next ordinary Seagate 500G SATA3 7200 rpm hard disk. Can be used at any timebtrfs scrub statusView the progress.

Note that for non-RAID environments,btrfs scrubOnly file errors can be checked, but the problem cannot be fixed (there are copies of undamaged files in the wood ......), For RAID 1 and other levels, this process can also be automatically repaired using information from the redundant disk, unless-rParameters.

Saving important data

Only the following two cases are required:btrfs rescueCommand, because it is really time-consuming to scan the disk file cluster, but correspondingly, it does not require partition mounting:

  1. When read-only mounting fails at the beginning
  2. Read-Only mounting is successful, but read/write mounting is used.btrfs scrubA large number of errors are prompted, and it is a single disk Environment
Rebuilding a File System

After saving important data, you finally returnbtrfs checkHere, it will try to repair the file system. Note: To avoid misoperation, add--repairIf this option is selected, the repair is performed.

I personally think that if there is not much important data, it is not difficult to restore the data offline. It is better to reformat it ......

Summary and reminders

The robustness of Btrfs file system is good, but the tool set is still developing, and sometimes there are some minor situations that can be addressed through the above repair methods.

In addition, if a hardware problem is thrown out when a mounting exception occurs, you can go to the IRC channel or Wiki page to check whether the problem is caused by a recent toolset. Sometimes, this can save a lot of effort.

For details about the commands described in this article, you can useman -k btrfsView

References:

  • Btrfs Problem FAQ
  • Btrfs FAQ
  • Btrfs Tips

How to install the desktop environment of workora 21 Workstation Cinnamon on the computer of the Btrfs File System

Makefile Analysis of Btrfs in Linux File System

Kconfig Analysis of Btrfs in Linux File System

Application of Btrfs File System in CentOS

Btrfs details: click here
Btrfs: click here

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.