如何在Linux中修复Ext2,Ex3,Ext4文件系统?

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
List Mounts And File Systems
List Mounts And File Systems
列表挂载和文件系统

用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
LEARN MORE  How To Use Linux df Command with Examples?
了解更多如何通过示例使用Linux df命令?

翻译自: https://www.poftut.com/repair-ext2-ex3-ext4-file-system-linux/

对于命令 "sudo ext4fix",我没有找到确切的相关命令。然而,根据给出的引用信息,我们可以使用 "fsck.ext4" 命令来修复 ext4 文件系统。这个命令用于检查和修复文件系统的错误。 引用 提到了一个名为 "xfs_repair" 的工具,但它是用于修复 XFS 文件系统的,而不是 ext4 文件系统。 如果你的文件系统是已挂载的,根据引用,你需要先卸载文件系统,然后使用 "fsck.ext4" 命令来检查和修复文件系统。示例命令如下: ``` $ sudo umount /dev/vda1 $ sudo fsck.ext4 /dev/vda1 ``` 请注意,你需要将示例命令的 "/dev/vda1" 替换为你自己的文件系统设备。 希望这能帮助到你!如果还有其他问题,请随时提问。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [如何在Linux修复Ext2Ex3Ext4文件系统?](https://blog.csdn.net/cunjiu9486/article/details/109072883)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [linux sudo apt-get用法详解](https://blog.csdn.net/weixin_30935961/article/details/117295158)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值