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?
2 Answers
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,
Select S.M.A.R.T. via the button at (1) and check the overall assessment at (2).
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,

- 46,324
- 5
- 88
- 152
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

- 316
- 1
- 5
-
Best not to run
badblocks
directly, but rather usesudo e2fsck -ck /dev/sdxn
. Checkman badblocks
for more info. – heynnema Nov 04 '17 at 19:15 -
In this case I want
badblocks
to remap badblocks to reserved area, not to feed it's output tofsck
. – Evgeniy Yanuk Nov 04 '17 at 19:39 -
-
2You didn't get the idea. Every HDD and SSD has
reserved
area. And if disk'sfirmware
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 04 '17 at 19:54 -
+1 I see your point :-) Do you know that badblocks will trigger the process to remap a bad sector to one from the reserved area? – sudodus Nov 04 '17 at 21:31
-
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 04 '17 at 22:35 -
1I had a disk with badblocks and I used
badblocks
tool to check this disk (without-w
or-n
options). TheReallocated sectors count
was growing and I had related messages insyslog
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 05 '17 at 00:13 -
The error message may also mean that the filesystem layout was constructed for a larger disk (which may happen when you start learning by playing as root) and now the operating system tries to read what isn't there. For this particular case it looks like sda1 may be placed incorrectly. – Thorbjørn Ravn Andersen Nov 05 '17 at 00:25
sudo e2fsck -cfk /dev/sdxn
... BUT I'd check the SMART info first. – heynnema Nov 04 '17 at 19:10e2fsck
failures are not nearly as bad, as they can be caused by transient problems. These do not require replacing the disk. – MSalters Nov 05 '17 at 14:27sudo e2fsck -fccky /dev/sdXX
# non-destructive read/write test (recommended) – heynnema Jul 21 '19 at 14:03fsck
... not a bad block scan... but again, please start a new question so that I can fully answer it for you. Describe any details you have there. – heynnema Jul 21 '19 at 17:50e2fsck
orfsck
when it is unmounted, and the root file system of a running operating system is mounted. So yes, you should do it from a live Ubuntu system. -- But as heynnema wrote, please start a new question. You can link to it from here in order to help us find it. Good luck :-) – sudodus Jul 21 '19 at 19:45