I'm learning a little about fsck on the fly, but what I am finding so far doesn't seem to do very much when I apply it. What would be the next step from this prompt to repair the errors I am having when booting?

fsck reports that filesystem still has errors - manual fsck required


S.M.A.R.T. information of HDD and SSD

Check the S.M.A.R.T. information. It is easy using Disks alias gnome-disks according to this link,

Reformating hard drive after malware damaged boot sector - scroll down to 'Maybe the disk hardware is damaged'

Select S.M.A.R.T. via the button at (1) and check the overall assessment at (2).

enter image description here

Run fsck on an ext4 file system

When I use fsck on an ext4 file system I boot from another drive and unmount the file system.

sudo e2fsck -f /dev/sdxn

where x is the device letter and n is the partition number, in your case /dev/sda1 according to the screenshot.

Sometimes it helps to run this command twice. Sometimes the file system is damaged beyond repair.

Sometimes there are bad sectors (hardware defects on the drive). Then you can mark the bad sectors (and make the system avoid them) with the following command

sudo e2fsck -cfk /dev/sdxn

See the manual

man e2fsck

for more details, and the following link for more tips about repairing file systems,

Repair the partition table and file system of a pendrive

  • 2
    When bad blocking a drive, it's best to add new bad blocks to the existing bad block table with sudo e2fsck -cfk /dev/sdxn... BUT I'd check the SMART info first. – heynnema Nov 4 '17 at 19:10
  • 1
    Bad blocks on a modern (21st century) disk are a sign of imminent demise. The idea of a bad block list has become pretty meaningless. Replace the disk instead. e2fsck failures are not nearly as bad, as they can be caused by transient problems. These do not require replacing the disk. – MSalters Nov 5 '17 at 14:27
  • @heynnema Does this work on "read-only filesystem"? I have live Ubuntu up and running. Any commad I type will "check" error, I don't think it's repairing anything! – Prabesh bhattarai Jul 21 '19 at 12:06
  • @PrabeshBhattarai It's a little unclear what your question/problem is. Please start a new question, and give me as much detail as possible. Thanks. – heynnema Jul 21 '19 at 13:56
  • Update to an old question... I'll update my previous comment to include a read/write bad block test... as bad blocks only get remapped on a write... sudo e2fsck -fccky /dev/sdXX # non-destructive read/write test (recommended) – heynnema Jul 21 '19 at 14:03

I'm afraid that your HDD has badblocks or it is defunct. Do you see this message: blk_update_request: I/O error, dev sda, sector 2048? It means that it is impossible to read this sector from physical device.

You need to boot from a LiveCD and check you drive with:

$ sudo smartctl -HA /dev/sda

and check the line SMART overall-health self-assessment test result: PASSED and the line Reallocated_Sector_Ct should contain 0 in RAW_VALUE field.

If SMART self test is PASSED you can try to 'remap' badblocks with badblocks tool:

$ sudo badblocks -svo ~/msg.log /dev/sda

and run fsck after:

$ sudo fsck -a /dev/sda1

If SMART self test is FAILED you need to replace your HDD.

PS: All these steps you should do from LiveCD session. And you have to replace /dev/sda to your drive.

Update [11.11.2017]: So I've checked one of my old HHDs with badblocks and I've got these messages in my syslog:

Nov 10 13:46:55 router kernel: [  121.339691] ata2.01: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
Nov 10 13:46:55 router kernel: [  121.339702] ata2.01: BMDMA stat 0x64
Nov 10 13:46:55 router kernel: [  121.339711] ata2.01: failed command: READ DMA
Nov 10 13:46:55 router kernel: [  121.339726] ata2.01: cmd c8/00:08:58:64:00/00:00:00:00:00/f0 tag 0 dma 4096 in
Nov 10 13:46:55 router kernel: [  121.339726]          res 51/40:00:5b:64:00/00:00:00:00:00/f0 Emask 0x9 (media error)
Nov 10 13:46:55 router kernel: [  121.339733] ata2.01: status: { DRDY ERR }
Nov 10 13:46:55 router kernel: [  121.339738] ata2.01: error: { UNC }
Nov 10 13:46:55 router kernel: [  121.364282] ata2.00: configured for UDMA/100
Nov 10 13:46:55 router kernel: [  121.380287] ata2.01: configured for UDMA/100
Nov 10 13:46:55 router kernel: [  121.380327] sd 1:0:1:0: [sdb] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
Nov 10 13:46:55 router kernel: [  121.380337] sd 1:0:1:0: [sdb] tag#0 Sense Key : Medium Error [current] [descriptor] 
Nov 10 13:46:55 router kernel: [  121.380346] sd 1:0:1:0: [sdb] tag#0 Add. Sense: Unrecovered read error - auto reallocate failed
Nov 10 13:46:55 router kernel: [  121.380355] sd 1:0:1:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 64 58 00 00 08 00
Nov 10 13:46:55 router kernel: [  121.380361] blk_update_request: I/O error, dev sdb, sector 25691
Nov 10 13:46:55 router kernel: [  121.380369] Buffer I/O error on dev sdb, logical block 3211, async page read
Nov 10 13:46:55 router kernel: [  121.380410] ata2: EH complete

So, all messages about I/O errors came from the kernel. The most interesting thing I found is in this line:

Nov 10 13:46:55 router kernel: [  121.380346] sd 1:0:1:0: [sdb] tag#0 Add. Sense: Unrecovered read error - auto reallocate failed

As I understand it's a decoded message from disk's firmware. It seems that the firmware found an read error and tried to reallocate the sector and failed with it. Consequently, in our case badblocks was doing nothing except reading all the sectors and we could replace it with dd if=/dev/sdX of=/dev/null.

And now I'm totally agried with sudodus. The most appropriate solution is:

sudo e2fsck -cfk /dev/sdxn
  • Best not to run badblocks directly, but rather use sudo e2fsck -ck /dev/sdxn. Check man badblocks for more info. – heynnema Nov 4 '17 at 19:15
  • In this case I want badblocks to remap badblocks to reserved area, not to feed it's output to fsck. – Evgeniy Yanuk Nov 4 '17 at 19:39
  • 2
    You didn't get the idea. Every HDD and SSD has reserved area. And if disk's firmware detects failed attempt to write to a sector it can remap this sector to one from reserved area. So when you'd try to access this sector you'd get data from remapped one. So nobody knows about this sector besides the firmware. Maybe this article will clear the topic. – Evgeniy Yanuk Nov 4 '17 at 19:54
  • 1
    @sudodus, writing to the bad sector will either correct it ( in the case where the data just got scrambled, possibly due to sudden power loss ), or cause it to be reallocated from the spare pool. Unless you use the -w switch, badblocks only tries to read from the disk. Even if you do that, I'm not sure if it will try to write to a block that it can't read first. – psusi Nov 4 '17 at 22:35
  • 1
    I had a disk with badblocks and I used badblocks tool to check this disk (without -w or -n options). The Reallocated sectors count was growing and I had related messages in syslog from the kernel. I cannot find any docs to prove my words, but I'll test one of such disks on Tuesday and report here. – Evgeniy Yanuk Nov 5 '17 at 0:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.