解决 Linux 报错 Input/output error 硬件坏道只读修复
排查 Linux 复制或访问特定文件报 Input/output error (EIO),分析 smartctl 坏道检测、ddrescue 数据抢救与更换硬盘。
问题现象
读取特定文件或备份数据时中断:
cp: error reading '/data/backup.tar.gz': Input/output error
系统日志记录 I/O error, dev sda, sector 12456789。
触发根因
- 机械硬盘或 SSD 出现了物理坏道(Bad Sector),底层固件重试读取超时放弃;
- SATA 数据线老化或接触不良导致传输 CRC 校验错误骤增。
解决步骤
使用 smartctl 检查磁盘健康度与重映射扇区数
查看 SMART 属性:
sudo smartctl -a /dev/sda | grep -E 'Reallocated_Sector|Current_Pending'
使用 ddrescue 尽可能抢救抢读健康数据
在只读模式下将完好区块抢救出来:
sudo ddrescue -d -r 3 /dev/sda1 /mnt/new_disk/rescued.img /mnt/new_disk/rescue.log
验证确认
更换新磁盘并恢复镜像:
新盘数据完整导入,无任何 I/O 读取失败阻断。


