Ubuntu 20.04 无法写入硬盘并冻结,显示“I/O 错误”

Ubuntu 20.04 无法写入硬盘并冻结,显示“I/O 错误”

当 Ubuntu 启动时,一切都很好。但是当系统运行超过几个小时时,包括根文件系统和交换分区在内的硬盘将变为只读。GUI 桌面消失,出现一些消息,如等I/O errorRead-only filesystem并且没有电源按钮时会冻结。当我在这种情况下按下电源按钮时,会弹出更多消息。我正在使用笔记本电脑。

以下是发生这种情况时的屏幕截图:

发生错误时的屏幕截图

我尝试根据以下方法找到问题的原因这个答案并发现了这一点:

我启动了 Ubuntu 18.04 Live CD。

这是输出fsck -f /dev/sdXX

$ sudo fsck -f /dev/sda5
fsck from util-linux 2.31.1
e2fsck 1.44.1 (24-Mar-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda5: 567831/2187264 files (0.4% non-contiguous), 6372147/8728576 blocks

我还检查了返回代码:

$ echo $?
0

然后我重新启动并启动 Live CD 中的磁盘应用程序。这些是 HDD SMART 数据的屏幕截图:

硬盘 SMART 数据 1

硬盘 SMART 数据 2

然后,当我启动到我的 Ubuntu 20.04 安装并注意到时,Initramfs unpacking failed: Decoding failed在出现启动徽标之前出现了一条类似的消息,并在几秒钟内消失。

我在终端上执行sudo grep -i FPDMA /var/log/syslog*,但没有任何输出。

我再次启动 Live CD 并执行sudo e2fsck -fccky /dev/sda5,它给出了以下输出:

$ sudo e2fsck -fccky /dev/sda5
e2fsck 1.44.1 (24-Mar-2018)
Checking for bad blocks (non-destructive read-write test)
Testing with random pattern: done                                                 
/dev/sda5: Updating bad block inode.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/sda5: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda5: 591731/2187264 files (0.4% non-contiguous), 6484554/8728576 blocks

它给出了0返回代码:

$ echo $?
0

我返回到 Ubuntu 20.04 并执行sudo fdisk -l,得到以下输出:

$ sudo fdisk -l
Disk /dev/loop0: 9.7 MiB, 9510912 bytes, 18576 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 28.92 MiB, 30306304 bytes, 59192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop2: 91.32 MiB, 95748096 bytes, 187008 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop3: 93.94 MiB, 98484224 bytes, 192352 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop4: 54.66 MiB, 57294848 bytes, 111904 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop5: 54.97 MiB, 57618432 bytes, 112536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop6: 140.68 MiB, 147496960 bytes, 288080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop7: 140.68 MiB, 147501056 bytes, 288088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: ST500LM012 HN-M5
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: A85852AC-BAD1-11E9-B49D-FE4A252694FC

Device         Start       End   Sectors   Size Type
/dev/sda1       2048 843642879 843640832 402.3G Microsoft basic data
/dev/sda2  843642880 844990463   1347584   658M Windows recovery environment
/dev/sda3  844990464 865961983  20971520    10G Windows recovery environment
/dev/sda4  865961984 872089599   6127616   2.9G Microsoft basic data
/dev/sda5  904894464 974723071  69828608  33.3G Windows recovery environment
/dev/sda6  974723072 976771071   2048000  1000M EFI System
/dev/sda7  872089600 904894463  32804864  15.7G Linux filesystem

Partition table entries are not in disk order.




Disk /dev/loop8: 160.16 MiB, 167931904 bytes, 327992 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop9: 255.58 MiB, 267980800 bytes, 523400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop10: 4.2 MiB, 4403200 bytes, 8600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop11: 2.45 MiB, 2555904 bytes, 4992 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop12: 14.77 MiB, 15466496 bytes, 30208 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop13: 276 KiB, 282624 bytes, 552 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop14: 956 KiB, 978944 bytes, 1912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop15: 956 KiB, 978944 bytes, 1912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop16: 3.66 MiB, 3825664 bytes, 7472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop17: 2.17 MiB, 2273280 bytes, 4440 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop18: 62.9 MiB, 65105920 bytes, 127160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop19: 34.55 MiB, 36216832 bytes, 70736 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

更新:当我在虚拟硬盘上进行过多的读写操作时,就会发生这种情况。(例如在使用虚拟机时)

答案1

让我们首先检查您的文件系统...

  • 以“试用 Ubuntu”模式启动 Ubuntu Live DVD/USB
  • terminalCtrl+ Alt+打开窗口T
  • 类型sudo fdisk -l
  • 识别“Linux 文件系统”的 /dev/sdXX 设备名称
  • 输入sudo fsck -f /dev/sda5,替换sdXX为您之前找到的数字
  • fsck如果有错误则重复命令
  • 类型reboot

然后我们来看看HDD SMART数据...

启动Disks应用程序,选择您的硬盘,转到“汉堡包”图标并选择智能数据与测试. 使用 SMART 数据的屏幕截图编辑您的问题。

读/写错误。无 NCQ 错误。

坏块...

注意:不要中止坏块扫描!

注意:不要对 SSD 造成坏块

注意:请先备份您的重要文件!

注意:这将花费很多小时

注意:您可能面临硬盘故障

在“尝试 Ubuntu”模式下启动 Ubuntu Live DVD/USB。

terminal...

sudo fdisk -l# 识别所有“Linux 文件系统”分区

sudo e2fsck -fcky /dev/sdXX# 只读测试

或者

sudo e2fsck -fccky /dev/sda5# 非破坏性读写测试(受到推崇的)

-k 很重要,因为它会保存之前的坏块表,并将任何新的坏块添加到该表中。如果没有 -k,您将丢失所有之前的坏块信息。

-fccky 参数...

   -f    Force checking even if the file system seems clean.

   -c    This option causes e2fsck to use badblocks(8) program to do
         a read-only scan of the device in order to find any bad blocks.
         If any bad blocks are found, they are added to the bad block
         inode to prevent them from being allocated to a file or direc‐
         tory.  If this option is specified twice, then the bad block scan
         will be done using a non-destructive read-write test.

   -k    When combined with the -c option, any existing bad blocks in the
         bad blocks list are preserved, and any new bad blocks found by
         running badblocks(8) will be added to the existing bad blocks
         list.

   -y    Assume an answer of `yes' to all questions; allows e2fsck to be
         used non-interactively. This option may not be specified at the
         same time as the -n or -p options.

相关内容