FSCK reports that filesystem still has errors [duplicate]
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?
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).
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
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