Linux file systems are generally robust and work very well. But it can happen errors rarely. How can we check and fix these file system errors? Fsck is a check and repair utility for Linux file systems. Fsck can check and repair one or more file system. The file system can be a device or a mount point. If no file system is specified /etc/fstab
entries are checked serially.
Linux文件系统通常很健壮,并且运行良好。 但是很少会发生错误。 我们如何检查和修复这些文件系统错误? Fsck是Linux文件系统的检查和修复实用程序。 Fsck可以检查和修复一个或多个文件系统。 文件系统可以是设备或挂载点。 如果未指定文件系统,则将/etc/fstab
条目/etc/fstab
检查。
列表挂载和文件系统 (List Mounts And File Systems)
First, we will start by listing mounts and partitions. We can use different commands but in this case, we will use the mount
command without any options.
首先,我们将从列出挂载和分区开始。 我们可以使用不同的命令,但是在这种情况下,我们将使用不带任何选项的mount
命令。
$ mount
用Fsck检查设备(Check Device With Fsck)
We will check a block device another name a disk with fsck
我们将使用fsck检查块设备的其他名称的磁盘
$ fsck.xfs /dev/vda1
If you wish to check the consistency of an XFS filesystem or
repair a damaged filesystem, see xfs_repair(8).
Our file system in this example is xfs so there is another tool named xfs_repair.
在此示例中,我们的文件系统是xfs,因此还有另一个名为xfs_repair的工具。
$ sudo fsck.ext4 /dev/vda1
e2fsck 1.43.3 (04-Sep-2016)
/dev/vda1 is mounted.
e2fsck: Cannot continue, aborting.
As we see in this example we can not check the mounted file system. So we need to unmount and check the file system.
如本例所示,我们无法检查已挂载的文件系统。 因此,我们需要卸载并检查文件系统。
$ sudo fsck.ext4 /dev/vdb1
e2fsck 1.43.3 (04-Sep-2016)
/dev/vdb1: clean, 11/65536 files, 8859/261888 blocks
We have check an unmounted file system like above named vdb1. It seems it is clean and no problem
我们已经检查了一个名为vdb1的卸载文件系统。 看起来很干净,没问题
提供文件系统作为参数(Provide File System As Parameter)
We can provide a file system as a parameter like below
我们可以像下面这样提供文件系统作为参数
$ fsck -t ext3 /dev/sa1
支票时接受所有问题 (Accept All Question While Check)
If there are a lot of errors fsck will ask you a lot of questions whether you want to correct the error. And every time we have to press yes to accept. We can provide -y to accept all questions.
如果有很多错误,fsck会问您很多问题,是否要纠正错误。 每次我们必须按是接受。 我们可以提供-y来接受所有问题。
$ fsck -y -t ext3 /dev/sa1
翻译自: https://www.poftut.com/repair-ext2-ex3-ext4-file-system-linux/