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 coursefsck
Tools ~ However, if you run it on a terminal, you will get the following result:
- Nothing happened ......
- If you want to repair the file system, use
btrfs check
Sub-commands
Slow! Hitting a wall or calling it decisivelybtrfs check
Before that, note that btrfs file systems are not like other file systems and are not required in most cases.fsck
This is not working.fsck
To be compatiblefstab
Non-0 error infs_passno
Set.
Slow down!btrfs check
It 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,ro
Option to mount the btrfs file.
Then observedmesg
Orjournalctl -k
Is 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-log
Try 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 start
Command to check all files and Their checksum.
btrfs scrub
It 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 status
View the progress.
Note that for non-RAID environments,btrfs scrub
Only 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-r
Parameters.
Saving important data
Only the following two cases are required:btrfs rescue
Command, because it is really time-consuming to scan the disk file cluster, but correspondingly, it does not require partition mounting:
- When read-only mounting fails at the beginning
- Read-Only mounting is successful, but read/write mounting is used.
btrfs scrub
A large number of errors are prompted, and it is a single disk Environment
Rebuilding a File System
After saving important data, you finally returnbtrfs check
Here, it will try to repair the file system. Note: To avoid misoperation, add--repair
If 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 btrfs
View
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: