有时我的 Linux 系统无法启动并出现文件系统错误。我可以通过启动 LiveCD 并运行以下命令来“修复”它们:
sudo fsck -y /dev/sda1
该命令表示它找到了坏块并修复了它们,然后系统将重新启动。这种情况持续发生是否表示硬件故障,还是有其他问题?
我注意到当我运行时:
sudo fsck -y /dev/sda
我收到这些错误:
fsck from util-linux 2.34 [/usr/sbin/fsck.ext2 (1) -- /dev/sda] fsck.ext2 /dev/sda e2fsck 1.45.5 (07-Jan-2020) ext2fs_open2: Bad magic number in super-block fsck.ext2: Superblock invalid, trying backup blocks... fsck.ext2: Bad magic number in super-block while trying to open /dev/sda
The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device> or
e2fsck -b 32768 <device>
Found a dos partition table in /dev/sda
这是因为对整个磁盘而不是仅对一个分区运行 fsck 是无效的,还是我的驱动器上有损坏的东西?我在互联网上看到很多地方都提供了对整个磁盘运行 fsck 的说明。我的磁盘只有一个分区,一个 Linux ext4 分区。
grep -i FPDMA /var/log/syslog* 的结果是:
adam>grep -i FPDMA /var/log/syslog*
/var/log/syslog:Sep 21 13:40:19 adam-gregs-better-computer kernel: [ 728.921941] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:40:19 adam-gregs-better-computer kernel: [ 729.213899] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:40:20 adam-gregs-better-computer kernel: [ 729.373884] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:42:40 adam-gregs-better-computer kernel: [ 870.000879] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:42:40 adam-gregs-better-computer kernel: [ 870.000904] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:43:05 adam-gregs-better-computer kernel: [ 895.312734] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:43:05 adam-gregs-better-computer kernel: [ 895.312760] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:43:06 adam-gregs-better-computer kernel: [ 895.476760] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:43:06 adam-gregs-better-computer kernel: [ 895.640724] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:43:49 adam-gregs-better-computer kernel: [ 938.924872] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:43:49 adam-gregs-better-computer kernel: [ 938.924901] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:43:49 adam-gregs-better-computer kernel: [ 938.924924] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:43:49 adam-gregs-better-computer kernel: [ 938.924945] ata3.00: failed command: WRITE FPDMA QUEUED
/var/log/syslog:Sep 21 13:43:53 adam-gregs-better-computer kernel: [ 942.878558] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:43:53 adam-gregs-better-computer kernel: [ 942.878583] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog.1:Sep 18 08:30:43 adam-gregs-better-computer kernel: [ 33.579255] ata3.00: failed command: READ FPDMA QUEUED
答案1
首先回答你的最后一个问题,这fsck
是文件系统检查,而不是磁盘检查。当然,你可以检查整个磁盘,但fsck
会分别检查并可能修复每个文件系统,也可能同时进行。
每次运行时遇到坏块fsck
确实表明硬件出现故障。坏块的内容被复制到可用的好块,然后该块被标记为“坏”,这意味着文件系统软件将不再使用它。因此,磁盘上的坏块数量似乎在增加。您可能需要验证您是否有正确的备份。
答案2
文件系统检查
让我们(再次)修复您的文件系统...
- 以“试用 Ubuntu”模式启动 Ubuntu Live DVD/USB
terminal
按Ctrl+ Alt+打开窗口T- 类型
sudo fdisk -l
- 识别“Linux 文件系统”的 /dev/sdXX 设备名称
- 输入
sudo fsck -f /dev/sda1
,替换sdXX
为您之前找到的数字 fsck
如果有错误则重复命令- 类型
reboot
坏块和 SMART 数据
这智能数据表示通常情况下是 HDD 出现故障。但是,我们的 SSD 并不太旧。我们首先来看一下如何解决 NCQ 错误。
笔记:确定 SSD 的制造商和型号,然后访问其网站以检查更新的固件。
笔记:保留良好的备份,以防 SSD 出现故障。
NCQ 错误
grep -i FPDMA /var/log/syslog*
/var/log/syslog:Sep 21 13:40:19 adam-gregs-better-computer kernel: [ 728.921941] ata3.00: failed command: READ FPDMA QUEUED
/var/log/syslog:Sep 21 13:40:19 adam-gregs-better-computer kernel: [ 729.213899] ata3.00: failed command: READ FPDMA QUEUED
本机命令队列 (NCQ) 是串行 ATA 协议的扩展,允许硬盘驱动器内部优化接收的读写命令的执行顺序。
编辑sudo -H gedit /etc/default/grub
并更改以下行以包含此额外参数。然后执行sudo update-grub
将更改写入磁盘。重新启动。监控挂起/等,并观察grep -i FPDMA /var/log/syslog*
或dmesg
是否有持续的错误消息。
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash libata.force=noncq"