2

When Ubuntu boots up, all is well. But when system is up for more than a few hours, the Hard Disk including root filesystem and swap partition become read-only. The GUI desktop disappears, and some messages like I/O error , Read-only filesystem etc appears and freezes without the power button. When I press power button in such sutuation some more messages popup. I am using a laptop.

Here is the screenshot of one of that times when this occured:

Screenshot when error occurred

I tried to find the cause of problem according this answer and found this:

I booted into Ubuntu 18.04 Live CD.

This is the output of 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

I also checked the return code:

$ echo $?
0

Then I rebooted and started Disks application in live CD. These are the screenshots of HDD SMART data:

HDD SMART data 1

HDD SMART data 2

Then when booted into my Ubuntu 20.04 installtion and noticed, a message like Initramfs unpacking failed: Decoding failed appeared before appearing the boot logo and disappeared within seconds.

I executed sudo grep -i FPDMA /var/log/syslog* on terminal and it gave no output.

I booted into Live CD again and executed sudo e2fsck -fccky /dev/sda5 and it gave following output:

$ 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

It gave 0 return code:

$ echo $?
0

I returned to Ubuntu 20.04 and executed sudo fdisk -l which gave following output:

$ 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

Update: This happens when I do excessive read and write operation on virtual hard disk. (E.g. while using virtual machine)

  • I would guess that 1) your hard drive is full or 2) you have a hardware error. If the hard drive is not full, try booting from a "live" OS and run diagnostics on the hard drive. It is possible that your dev/sda5 device has one or more bad sectors. –  May 25 '20 at 15:35
  • Please do my answer. Edit the output/screenshots into your question. Your HDD may be failing. Start comments to me with @heynnema or I'll miss them. – heynnema May 25 '20 at 15:36
  • @heynnema I have added fsck output. I will add screenshots of HDD SMART data very soon. – Akib Azmain Turja May 25 '20 at 16:59
  • Thanks. Let me know... – heynnema May 25 '20 at 17:01
  • @heynnema I have added all description you wanted. – Akib Azmain Turja May 26 '20 at 11:42
  • Thanks for the screenshots. You're having read/write errors, and possible temp issues. Is this a laptop or desktop computer? Do you have good backups? The HDD may be failing, but we might bad block it. Show me grep -i FPDMA /var/log/syslog*. – heynnema May 26 '20 at 13:15
  • @heynnema Mine is a laptop and I don't have any backups. Your command gave zero output when I run it as root. (It says permission denied without sudo) – Akib Azmain Turja May 26 '20 at 13:31
  • I've added a bad block procedure to my answer. Please do whatever backups you can first. Report back. – heynnema May 26 '20 at 13:39
  • Status please... – heynnema May 28 '20 at 15:03
  • @heynnema I have added the output of other command. – Akib Azmain Turja Jun 01 '20 at 11:43
  • Thanks for the update. Do you have two Linux partitions? Please show me sudo fdisk -l. – heynnema Jun 01 '20 at 12:23
  • @heynnema I have included. I use three linux partition, one for Ubuntu, another for swap and the last one for miscellaneous use. – Akib Azmain Turja Jun 01 '20 at 12:39
  • Ah, we were testing the wrong partition. Please redo my entire answer, now updated to use sda7. Is your misc partition NTFS? – heynnema Jun 01 '20 at 12:52
  • @heynnema My ROOT partition is /dev/sda5 with 33.3G size. My misc partition is btrfs, /dev/sda7 . When I start Windows, it automatically changes partition flag from Linux filesystem to Windows recovery environment of my root partition. I have tried to change the flag. But starting Windows and then rebooting to Ubuntu, I saw the flag is changed again. Your previous answer was correct. – Akib Azmain Turja Jun 01 '20 at 13:03
  • That's bizarre. So how do you boot Ubuntu if its partition is Windows Recovery? Does fsck work on /dev/sda7? If so, does bad blocking work on /dev/sda7? I don't see a swap partition, so you must be using a /swapfile, yes? – heynnema Jun 01 '20 at 13:23
  • @heynnema My swap is 10 G ( /dev/sda3 ) which also has Windows recovery environment flag. Windows just changes flags all partitions to something like Windows recovery environment. /dev/sda7 is still Linux filesystem because I didn't started Windows after creating it. – Akib Azmain Turja Jun 01 '20 at 13:33
  • That's even more bizarre. Is this Windows 10? So to boot Ubuntu, do you have to change these partition flags? You didn't answer my questions regarding sda7. – heynnema Jun 01 '20 at 13:38
  • @heynnema fsck doesn't work on /dev/sda7 as it is btrfs, it says to use btrfs check . Sorry but I can't understand "do you have to change these partition flags?" . – Akib Azmain Turja Jun 01 '20 at 13:46
  • If Windows keeps changing the sda3/sda5 partition flags to Windows Recovery, Ubuntu won't boot, will it? What version Windows? Why did you choose btrfs for sda7? – heynnema Jun 01 '20 at 13:49
  • @heynnema I use Windows 10. Ubuntu boots without any problems. I choose btrfs for its snapshot functionality. – Akib Azmain Turja Jun 01 '20 at 13:59
  • Anyway, keep an eye on the SMART Data for any more read/write errors. – heynnema Jun 01 '20 at 14:19
  • @heynnema I think everything is caused by Ubuntu 20.04 upgrade. More details in chat. – Akib Azmain Turja Jun 03 '20 at 08:18
  • @heynnema Now I know this happens when I do excessive read and write operations on virtual hard disk – Akib Azmain Turja Jul 24 '20 at 09:05
  • What virtual environment are you using, Virtualbox? Can you temporarily create a new virtual hard disk and see if the same r/w operations cause the problem? – heynnema Jul 24 '20 at 13:00
  • @heynnema I use both VirtualBox and QEMU. And this problem occurs while using both of them. I don't think it is a problem with virtual machine, because when I mount virtual hard disk with qemu-nbd, it occurs. This problem occurs rarely when I don't use virtual machine or virtual hard disks. – Akib Azmain Turja Jul 24 '20 at 13:09
  • I agree, that it's probably not a problem with the VM... but something possibly with the VHD. That's why I suggested trying another VHD. – heynnema Jul 24 '20 at 14:14
  • @heynnema Thanks for your instruction, but this problem occurred today after I started my new VM with new VHD, before you commented to create a new VHD. – Akib Azmain Turja Jul 24 '20 at 14:46
  • It sounds like a bad HDD, but I'm not ready to say replace it. It's getting r/w errors, although SMART Data, and the bad blocking isn't showing any bad blocks. And you have the weird partition type changes. Since it's a laptop, there's no easy way to check/re-seat the drive cable. If you have good backups, although it's a lot of extra work for you, you could wipe the drive, lay down a fresh GPT partition table, and reload Windows/Ubuntu and see if anything changes. – heynnema Jul 24 '20 at 14:54
  • @heynnema On windows, there is no problems like this. Although this problem occurs while using VHD, no matter on which partition the VHD is located. Should I install another copy of Ubuntu on different partition of same hard disk and do tests with VHD? I think it's a problem with my current installation. – Akib Azmain Turja Jul 24 '20 at 15:24
  • But you probably don't have a similar VM environment under Windows, do you? You've got a weird problem. Your disk is smallish, and you may not have enough room to install another copy of Ubuntu. To be sure, I'd wipe the disk and start over... OR, if you have good Ubuntu backups, just wipe Ubuntu, reinstall it, and reload data. It's up to you. – heynnema Jul 24 '20 at 15:27
  • @heynnema Please see comment, I edit that comment. (While I was editing, you commented, maybe you haven't read the update) – Akib Azmain Turja Jul 24 '20 at 15:34
  • I read your previous comment. There's a very good chance that there IS something wrong with your current installation. Hence the suggestion to reinstall... or wipe some/all and reinstall. – heynnema Jul 24 '20 at 16:25
  • 1
    @heynnema I agree with you. I think this is caused by upgrade to 20.04 as I described in a previous comment. While upgrading, the process was interrupted when dpkg was installing packages. Then I reinstalled all package downloaded by do-release-upgrade . Maybe this is cause. – Akib Azmain Turja Jul 25 '20 at 05:37
  • I have run into a similar error but on a new laptop with Ubuntu 21.04 and Windows 10 dual boot. I have asked a question here and have also started a bug on launchpad. You can see details here - https://askubuntu.com/questions/1337221/ubuntu-21-04-freezes-with-i-o-errors-fsck-and-smartctl-does-not-show-errors – anoopjohn May 16 '21 at 19:44
  • @anoopjohn Your question look like a duplicate, you should try answer from this question. You should start a bounty on your question so it gets attention. Also I can't help as I no longer use Ubuntu (which contains nonfree blobs or Binary Large Objects) and have switched to Guix which is a totally free (as in freedom) distribution (and I have no such problem in my new distribution). – Akib Azmain Turja May 17 '21 at 08:19

1 Answers1

1

Let's first check your file system...

  • boot to a Ubuntu Live DVD/USB in “Try Ubuntu” mode
  • open a terminal window by pressing Ctrl+Alt+T
  • type sudo fdisk -l
  • identify the /dev/sdXX device name for your "Linux Filesystem"
  • type sudo fsck -f /dev/sda5, replacing sdXX with the number you found earlier
  • repeat the fsck command if there were errors
  • type reboot

Then let's look at the HDD SMART Data...

Start the Disks application, select your HDD, go to the "hamburger" icon and select SMART Data & Tests. Edit your question with screenshot(s) of the SMART Data.

Read/write errors. No NCQ errors.

Bad Block...

Note: do NOT abort a bad block scan!

Note: do NOT bad block a SSD

Note: backup your important files FIRST!

Note: this will take many hours

Note: you may have a pending HDD failure

Boot to a Ubuntu Live DVD/USB in “Try Ubuntu” mode.

In terminal...

sudo fdisk -l # identify all "Linux Filesystem" partitions

sudo e2fsck -fcky /dev/sdXX # read-only test

or

sudo e2fsck -fccky /dev/sda5 # non-destructive read/write test (recommended)

The -k is important, because it saves the previous bad block table, and adds any new bad blocks to that table. Without -k, you loose all of the prior bad block information.

The -fccky parameter...

   -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.

heynnema
  • 70,711