You are not logged in.

#1 2017-02-25 11:59:46

krumelmonster
Member
Registered: 2015-04-27
Posts: 12

Bad Blocks

Hi Arch BBS.

Since a recent freeze, I'm getting these whenever I start firefox and my sytem becomes hardly usable:

blk_update_request: I/O error, dev sda, sector 243538880
ata1: EH complete
ata1.00: exception Emask 0x0 SAct 0x40 SErr 0x0 action 0x0
ata1.00: irq_stat 0x40000008
ata1.00: failed command: READ FPDMA QUEUED
ata1.00: cmd 60/08:30:c0:1b:84/00:00:0e:00:00/40 tag 6 ncq dma 4096 in
         res 41/40:08:c0:1b:84/00:00:0e:00:00/00 Emask 0x409 (media error) <F>
ata1.00: status: { DRDY ERR }
ata1.00: error: { UNC }
ata1.00: configured for UDMA/133
sd 0:0:0:0: [sda] tag#6 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
sd 0:0:0:0: [sda] tag#6 Sense Key : 0x3 [current] 
sd 0:0:0:0: [sda] tag#6 ASC=0x11 ASCQ=0x4 
sd 0:0:0:0: [sda] tag#6 CDB: opcode=0x28 28 00 0e 84 1b c0 00 00 08 00
blk_update_request: I/O error, dev sda, sector 243538880

The smartctl self-test reports

Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   095   094   006    Pre-fail  Always       -       187944316
  3 Spin_Up_Time            0x0003   099   099   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   098   098   020    Old_age   Always       -       2284
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       1
  7 Seek_Error_Rate         0x000f   077   060   030    Pre-fail  Always       -       51459460
  9 Power_On_Hours          0x0032   096   096   000    Old_age   Always       -       3702
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   098   037   020    Old_age   Always       -       2275
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   001   001   000    Old_age   Always       -       220
188 Command_Timeout         0x0032   100   098   000    Old_age   Always       -       8590066330
189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0022   067   053   045    Old_age   Always       -       33 (Min/Max 28/34)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       548
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       55
193 Load_Cycle_Count        0x0032   016   016   000    Old_age   Always       -       168064
194 Temperature_Celsius     0x0022   033   047   000    Old_age   Always       -       33 (0 11 0 0 0)
195 Hardware_ECC_Recovered  0x001a   057   049   000    Old_age   Always       -       187944316
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       1
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       1
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
254 Free_Fall_Sensor        0x0032   100   100   000    Old_age   Always       -       0
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short captive       Completed: read failure       90%      3688         243538880
# 2  Short offline       Completed: read failure       90%      3688         243538880

Can I fix this without a replacement hdd? Ideally without having to overwrite the whole disk like with badblocks?

Offline

#2 2017-02-25 12:20:49

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: Bad Blocks

Well, the Offline_Uncorrectable count is only at 1, for now. Also, the drive isn't too old. So all might not be lost.

For starters, I would suggest that you change the SATA cable and run an extended self test and post the results. Also, unless you don't care about the data on the drive, take a backup of everything before doing anything else.

Offline

#3 2017-02-25 12:49:19

mich41
Member
Registered: 2012-06-22
Posts: 796

Re: Bad Blocks

For a quick fix you can rewrite only sector 243538880 with dd and run read-only badblocks or SMART self-test to see if there are no other immediate issues. Of course if the disk is failing mechanically it may keep causing problems in the future, so keep an eye on it.

The problem with this approach is that some random 512B of data will be replaced with zeros and it would be nice to know what they were before overwriting. Maybe run

find /usr ~/.mozilla -exec dd if={} of=/dev/null status=none \;

Hopefully this will locate the broken file so you can fix it.

x33a wrote:

SATA cable

Not really. Cables can cause CRC or 8b10b errors on the SATA link, but not internal medium errors.

Offline

#4 2017-02-25 13:51:02

frostschutz
Member
Registered: 2013-11-15
Posts: 1,417

Re: Bad Blocks

krumelmonster wrote:

Can I fix this without a replacement hdd?

No. Get your data off there asap. (If you don't have a backup, ddrescue)

krumelmonster wrote:

Ideally without having to overwrite the whole disk like with badblocks?

That's the only way to determine the extent of the damage but the result will be the same... that disk is a goner.

Last edited by frostschutz (2017-02-25 13:52:08)

Offline

#5 2017-02-25 14:18:20

krumelmonster
Member
Registered: 2015-04-27
Posts: 12

Re: Bad Blocks

Thank you both very much.

x33a, I ran the long test yesterday and I backuped my important stuff

smartctl 6.5 2016-05-07 r4318 [i686-linux-4.9.8-1-ARCH] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Momentus 5400.6
Device Model:     ST9160314AS

Firmware Version: 0002SDM1
User Capacity:    160.041.885.696 bytes [160 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    5400 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS T13/1699-D revision 4
SATA Version is:  SATA 2.6, 3.0 Gb/s
Local Time is:    Sat Feb 25 04:09:20 2017 CET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00)	Offline data collection activity
					was never started.
					Auto Offline Data Collection: Disabled.
Self-test execution status:      ( 121)	The previous self-test completed having
					the read element of the test failed.
Total time to complete Offline 
data collection: 		(    0) seconds.
Offline data collection
capabilities: 			 (0x73) SMART execute Offline immediate.
					Auto Offline data collection on/off support.
					Suspend Offline collection upon new
					command.
					No Offline surface scan supported.
					Self-test supported.
					Conveyance Self-test supported.
					Selective Self-test supported.
SMART capabilities:            (0x0003)	Saves SMART data before entering
					power-saving mode.
					Supports SMART auto save timer.
Error logging capability:        (0x01)	Error logging supported.
					General Purpose Logging supported.
Short self-test routine 
recommended polling time: 	 (   1) minutes.
Extended self-test routine
recommended polling time: 	 (  50) minutes.
Conveyance self-test routine
recommended polling time: 	 (   2) minutes.
SCT capabilities: 	       (0x103b)	SCT Status supported.
					SCT Error Recovery Control supported.
					SCT Feature Control supported.
					SCT Data Table supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   095   094   006    Pre-fail  Always       -       187944316
  3 Spin_Up_Time            0x0003   099   099   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   098   098   020    Old_age   Always       -       2284
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       1
  7 Seek_Error_Rate         0x000f   077   060   030    Pre-fail  Always       -       51459460
  9 Power_On_Hours          0x0032   096   096   000    Old_age   Always       -       3702
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   098   037   020    Old_age   Always       -       2275
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   001   001   000    Old_age   Always       -       220
188 Command_Timeout         0x0032   100   098   000    Old_age   Always       -       8590066330
189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0022   067   053   045    Old_age   Always       -       33 (Min/Max 28/34)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       548
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       55
193 Load_Cycle_Count        0x0032   016   016   000    Old_age   Always       -       168064
194 Temperature_Celsius     0x0022   033   047   000    Old_age   Always       -       33 (0 11 0 0 0)
195 Hardware_ECC_Recovered  0x001a   057   049   000    Old_age   Always       -       187944316
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       1
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       1
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
254 Free_Fall_Sensor        0x0032   100   100   000    Old_age   Always       -       0

SMART Error Log Version: 1
ATA Error Count: 218 (device log contains only the most recent five errors)
	CR = Command Register [HEX]
	FR = Features Register [HEX]
	SC = Sector Count Register [HEX]
	SN = Sector Number Register [HEX]
	CL = Cylinder Low Register [HEX]
	CH = Cylinder High Register [HEX]
	DH = Device/Head Register [HEX]
	DC = Device Command Register [HEX]
	ER = Error register [HEX]
	ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.

Error 218 occurred at disk power-on lifetime: 3688 hours (153 days + 16 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  04 51 00 00 00 00 00  Error: ABRT

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  b0 d4 00 81 4f c2 00 00      01:07:15.073  SMART EXECUTE OFF-LINE IMMEDIATE
  b0 d0 01 00 4f c2 00 00      01:07:14.886  SMART READ DATA
  ec 00 01 00 00 00 00 00      01:07:14.855  IDENTIFY DEVICE
  ec 00 01 00 00 00 00 00      01:07:14.854  IDENTIFY DEVICE
  60 00 10 ff ff ff 4f 00      01:07:13.107  READ FPDMA QUEUED

Error 217 occurred at disk power-on lifetime: 3688 hours (153 days + 16 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 00 c0 1b 84 0e  Error: UNC at LBA = 0x0e841bc0 = 243538880

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  60 00 08 a8 14 c9 46 00      00:34:16.660  READ FPDMA QUEUED
  60 00 08 80 4f c9 46 00      00:34:16.647  READ FPDMA QUEUED
  60 00 08 08 07 c9 46 00      00:34:16.642  READ FPDMA QUEUED
  60 00 08 c0 25 c9 46 00      00:34:16.634  READ FPDMA QUEUED
  60 00 08 08 65 c9 46 00      00:34:16.623  READ FPDMA QUEUED

Error 216 occurred at disk power-on lifetime: 3688 hours (153 days + 16 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 00 c0 1b 84 0e  Error: WP at LBA = 0x0e841bc0 = 243538880

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  61 00 08 50 0c 49 46 00      00:34:13.911  WRITE FPDMA QUEUED
  60 00 08 50 03 c9 46 00      00:34:13.910  READ FPDMA QUEUED
  60 00 08 28 02 c9 46 00      00:34:13.889  READ FPDMA QUEUED
  60 00 08 c0 1b 84 4e 00      00:34:13.888  READ FPDMA QUEUED
  61 00 08 90 0c 48 46 00      00:34:13.888  WRITE FPDMA QUEUED

Error 215 occurred at disk power-on lifetime: 3688 hours (153 days + 16 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 00 c0 1b 84 0e  Error: WP at LBA = 0x0e841bc0 = 243538880

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  61 00 08 48 01 48 46 00      00:34:11.004  WRITE FPDMA QUEUED
  60 00 08 c0 1b 84 4e 00      00:34:11.003  READ FPDMA QUEUED
  61 00 08 30 40 ad 42 00      00:34:11.002  WRITE FPDMA QUEUED
  61 00 08 38 00 08 41 00      00:34:11.002  WRITE FPDMA QUEUED
  ea 00 00 00 00 00 a0 00      00:34:11.001  FLUSH CACHE EXT

Error 214 occurred at disk power-on lifetime: 3688 hours (153 days + 16 hours)
  When the command that caused the error occurred, the device was active or idle.

  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  40 51 00 c0 1b 84 0e  Error: WP at LBA = 0x0e841bc0 = 243538880

  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  61 00 08 80 3e 56 40 00      00:34:08.349  WRITE FPDMA QUEUED
  60 00 08 c0 1b 84 4e 00      00:34:08.348  READ FPDMA QUEUED
  61 00 08 68 0d 0c 49 00      00:34:08.347  WRITE FPDMA QUEUED
  ea 00 00 00 00 00 a0 00      00:34:08.347  FLUSH CACHE EXT
  27 00 00 00 00 00 e0 00      00:34:08.346  READ NATIVE MAX ADDRESS EXT [OBS-ACS-3]

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed: read failure       90%      3689         243538880
# 2  Short captive       Completed: read failure       90%      3688         243538880
# 3  Short offline       Completed: read failure       90%      3688         243538880

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

mich41, I think I found the file:

$ LANG=C find ~/.mozilla -type f -exec dd if={} of=/dev/null status=none \;
dd: error reading '[...].default/places.sqlite-wal': Input/output error

I think I could just delete that file, it would be "automatically cleaned up the next time the database is opened" anyways.
I backed it up using

$ dd if=[...].default/places.sqlite-wal of=places.sqlite-wal iflag=direct conv=noerror,sync

Will

$ rm [...].default/places.sqlite-wal

fix my problem or should I

# dd bs=512 seek=243538880 count=1 if=/dev/null of=/dev/sda

first?

Last edited by krumelmonster (2017-02-25 14:19:24)

Offline

#6 2017-02-25 14:41:23

mich41
Member
Registered: 2012-06-22
Posts: 796

Re: Bad Blocks

Fixing the bad sector requires overwriting it and deleting a file actually leaves its data intact on disk, so dd is needed. I think you got the parameters right, but for peace of mind run it once with swapped if and of to see if you get read error - you don't want to accidentally overwrite some other sector wink And use /dev/zero instead of /dev/null.

Don't delete this file before overwriting, something else may be put in its place and damaged by dd.

The file "places.sqlite" stores the annotations, bookmarks, favorite icons, input history, keywords, and browsing history (a record of visited pages).

So that's what's at stake. WAL corruption may cause problems with the main places.sqlite database on the next FF startup. Backup both files before starting FF if you care about them, delete both files if FF complains about corruption or fails to start and you can live without this history.

As for the SMART test, it was pretty obvious that it will stop with read failure smile Re-run it now and see if there are no other problems. And monitor Current_Pending_Sector for some time, it should be zero or otherwise there are new bad blocks coming up.

Last edited by mich41 (2017-02-25 14:59:04)

Offline

#7 2017-02-25 15:03:15

krumelmonster
Member
Registered: 2015-04-27
Posts: 12

Re: Bad Blocks

Surprisingly, swapping if and of doesn't give me a read error (I didn't clear the block yet so it really is a surprise)

# dd bs=512 seek=243538880 count=1 of=/dev/zero if=/dev/sda
1+0 records in
1+0 records out
512 bytes copied, 0.000315752 s, 1.6 MB/s

Are you sure that 243538880 is the broken block?

Offline

#8 2017-02-25 15:31:01

mich41
Member
Registered: 2012-06-22
Posts: 796

Re: Bad Blocks

Oops, you need to change "seek" to "skip" when reading. That's why I always recommend utmost paranoia when dding into disks - it's easy to screw something up.

For writing you need seek, otoh. Writing with skip and without seek would kill the partition table.

As for the sector number, I took it from the first line of your dmesg error. I'm 100% sure you can just copy-paste it from dmesg to dd's seek parameter and all will be good, but I recommend checking it anyway.

Offline

#9 2017-02-25 18:04:01

krumelmonster
Member
Registered: 2015-04-27
Posts: 12

Re: Bad Blocks

*Ohnoes*
I messed up, I did

# dd bs=512 skip=243538880 count=1 if=/dev/zero of=/dev/sda

I will get in big trouble once I reboot, right? What can I do?

Also, I can't write the broken sektor (wasn't this to expect?)

dd bs=512 seek=243538880 count=1 if=/dev/zero of=/dev/sda
dd: error writing '/dev/sda': Input/output error
1+0 records in
0+0 records out
0 bytes copied, 2.6887 s, 0.0 kB/s

Edit: I need this machine tomorrow, I'll be on IRC to hopefully get this fixed today with some more realtime help

Last edited by krumelmonster (2017-02-25 18:09:53)

Offline

#10 2017-02-25 18:51:26

mich41
Member
Registered: 2012-06-22
Posts: 796

Re: Bad Blocks

You need to recreate the partition table to match existing partitions and reinstall bootloader.

First of all, ASAP save the output of the following commands to some external disk:

grep . /sys/block/sda/sda*/start
grep . /sys/block/sda/sda*/size
mount
dmesg |grep sda:

The first two give the starting sector and size of each partition, mount should tell filesystem types.

The last line hopefully will show which logical partitions (numbers 5 or more) are contained in which extended partitions. I know no better way to extract this information besides either this or analyzing output of the first two commands.

GPT or MBR?

Maybe make a live CD/USB if you don't have one.

BTW, I think a good general strategy for MBR is:

1. create an empty sparse file of the same size as the disk (truncate --size=758974873894 fakedisk)
2. recreate partitions on the fake disk
3. copy only the first sector of the fake disk to sda
4. losetup -r -P /dev/loop0 /dev/sda
5. check if partitions on /dev/loop0 are OK
6. if not, losetup -d /dev/loop0 and back to 2

This way you avoid the risk of partitioning program modifying anything outside of the first sector. This will happen if you have extended partitions or accidentally get it to format the newly created partitions.

Last edited by mich41 (2017-02-25 19:25:41)

Offline

Board footer

Powered by FluxBB