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,
-
2When 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.– heynnemaNov 4, 2017 at 19:10 -
1Bad 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.
e2fsckfailures are not nearly as bad, as they can be caused by transient problems. These do not require replacing the disk.– MSaltersNov 5, 2017 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!– PranavJul 21, 2019 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.– heynnemaJul 21, 2019 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)– heynnemaJul 21, 2019 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
badblocksdirectly, but rather usesudo e2fsck -ck /dev/sdxn. Checkman badblocksfor more info.– heynnemaNov 4, 2017 at 19:15 -
In this case I want
badblocksto remap badblocks to reserved area, not to feed it's output tofsck. Nov 4, 2017 at 19:39 -
2You didn't get the idea. Every HDD and SSD has
reservedarea. And if disk'sfirmwaredetects 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. Nov 4, 2017 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,
badblocksonly 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.– psusiNov 4, 2017 at 22:35 -
1I had a disk with badblocks and I used
badblockstool to check this disk (without-wor-noptions). TheReallocated sectors countwas growing and I had related messages insyslogfrom the kernel. I cannot find any docs to prove my words, but I'll test one of such disks on Tuesday and report here. Nov 5, 2017 at 0:13

