大网数据广告活动
服务器运维问答

Recovering a file with bad blocks in the middle

· 52CE 我爱测

A large file on our ext4 file system may have picked up a bad block in the middle. Copying the file to another drive results in an input/output error part way through. Data beyond the bad sectors still seems ok though. We don't h…

问题原文

原帖链接 · Chris C. · CC BY-SA 3.0

A large file on our ext4 file system may have picked up a bad block in the middle. Copying the file to another drive results in an input/output error part way through. Data beyond the bad sectors still seems ok though.

We don't have a backup of this file since it was recently created, so I'm looking for a way of copying the entire readable portion of the file while skipping bad sectors.

I've read other sites which suggest ways of recovering entire hard drives with bad blocks but they don't say much about recovering any files which span the bad blocks.

Thanks.

社区高分解答

原帖链接 · the-wabbit · CC BY-SA 3.0

It should be noted that the file system will only be reading "blocks" off the disk (typically 4k) but corruption on hard disks would typically concern "sectors" (512 Bytes on non-ADF-disks).

If a single sector in a block is unreadable, the entire block is considered invalid by the filesystem and the contents are not returned upon request, so actually trying to copy the file might not give you the best results regarding the amount of recoverable data.

Instead, you could look into either using dd with the conv=noerror option and the default block size of 512 bytes or even ddrescue to copy the entire partition containing the file system and copy the file off afterwards.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-03-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。