1

Following is my partition table,

mercurial@providence:~$ sudo fdisk -l
Disk /dev/sda: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: ST9500420AS     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc8000000

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048    206847    204800   100M  7 HPFS/NTFS/exFAT
/dev/sda2          206848 170128349 169921502    81G  7 HPFS/NTFS/exFAT
/dev/sda3       170144408 337927335 167782928    80G  7 HPFS/NTFS/exFAT
/dev/sda4       337930238 976769023 638838786 304.6G  f W95 Ext'd (LBA)
/dev/sda5       337930240 727652351 389722112 185.9G 83 Linux
/dev/sda6       727654400 968382463 240728064 114.8G 83 Linux
/dev/sda7       968384512 976769023   8384512     4G 82 Linux swap / Solaris

I have two Linux distro installed one is on /dev/sda5 and another one (Debian) is on /dev/sda6.

When when i was booting Debian from /dev/sda6 power went off. When i rebooted and tried to boot into Debian, it won't boot. and giving me some errors.

Later i tried booting in Other Linux, /dev/sda5 the system booted fine but kept giving me this error.

mercurial@providence:~$ sudo dmesg | grep ata
...
[   40.300376] print_req_error: I/O error, dev sda, sector 727654456 flags 0
[   40.302000] Buffer I/O error on dev sda6, logical block 7, async page read
[   40.303663] ata1: EH complete
[   40.740148] Adding 4192252k swap on /dev/sda7.  Priority:-2 extents:1 across:4192252k FS
[   44.577187] ata1.00: exception Emask 0x0 SAct 0x678000 SErr 0x0 action 0x0
[   44.579899] ata1.00: irq_stat 0x40000008
[   44.582976] ata1.00: failed command: READ FPDMA QUEUED
[   44.585847] ata1.00: cmd 60/00:a8:00:20:5f/01:00:2b:00:00/40 tag 21 ncq dma 131072 in
                        res 41/40:00:38:20:5f/00:01:2b:00:00/00 Emask 0x409 (media error) <F>
[   44.591895] ata1.00: status: { DRDY ERR }
[   44.594937] ata1.00: error: { UNC }
[   44.655930] ata1.00: configured for UDMA/133
[   44.655977] sd 0:0:0:0: [sda] tag#21 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[   44.655982] sd 0:0:0:0: [sda] tag#21 Sense Key : Medium Error [current] 
[   44.655985] sd 0:0:0:0: [sda] tag#21 Add. Sense: Unrecovered read error - auto reallocate failed
[   44.655990] sd 0:0:0:0: [sda] tag#21 CDB: Read(10) 28 00 2b 5f 20 00 00 01 00 00
[   44.655993] print_req_error: I/O error, dev sda, sector 727654456 flags 0
...

My harddrive is comparitively healty.

mercurial@providence:~$ sudo  smartctl -a /dev/sda
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-5.2.0-kali2-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Momentus 7200.4
Device Model:     ST9500420AS
Serial Number:    5VJ954YE
LU WWN Device Id: 5 000c50 02eacc16b
Firmware Version: D005SDM1
User Capacity:    500,107,862,016 bytes [500 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    7200 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:    Wed Oct  9 11:05:53 2019 EDT
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
See vendor-specific Attribute list for marginal Attributes.

General SMART Values:
Offline data collection status:  (0x82) Offline data collection activity
                    was completed without error.
                    Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed
                    without error or no self-test has ever 
                    been run.
Total time to complete Offline 
data collection:        (    0) seconds.
Offline data collection
capabilities:            (0x7b) SMART execute Offline immediate.
                    Auto Offline data collection on/off support.
                    Suspend Offline collection upon new
                    command.
                    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:    (   2) minutes.
Extended self-test routine
recommended polling time:    ( 106) minutes.
Conveyance self-test routine
recommended polling time:    (   3) minutes.
SCT capabilities:          (0x103f) 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   097   089   006    Pre-fail  Always       -       176927878
  3 Spin_Up_Time            0x0003   100   098   085    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   094   094   020    Old_age   Always       -       6416
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   078   060   030    Pre-fail  Always       -       78548952961
  9 Power_On_Hours          0x0032   064   064   000    Old_age   Always       -       31923
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   094   037   020    Old_age   Always       -       6304
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   001   001   000    Old_age   Always       -       1256
188 Command_Timeout         0x0032   099   095   000    Old_age   Always       -       4295037805
189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0022   060   036   045    Old_age   Always   In_the_past 40 (157 57 40 32 0)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       1140
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       1094
193 Load_Cycle_Count        0x0032   001   001   000    Old_age   Always       -       245233
194 Temperature_Celsius     0x0022   040   064   000    Old_age   Always       -       40 (0 15 0 0 0)
195 Hardware_ECC_Recovered  0x001a   044   024   000    Old_age   Always       -       176927878
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       -       1
240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      -       31560 (96 61 0)
241 Total_LBAs_Written      0x0000   100   253   000    Old_age   Offline      -       144327995
242 Total_LBAs_Read         0x0000   100   253   000    Old_age   Offline      -       25265341
254 Free_Fall_Sensor        0x0032   001   001   000    Old_age   Always       -       88

SMART Error Log Version: 1
ATA Error Count: 978 (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 978 occurred at disk power-on lifetime: 31923 hours (1330 days + 3 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 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  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 ff ff ff 4f 00      00:06:53.760  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:53.759  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:53.759  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:53.758  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:53.758  READ FPDMA QUEUED

Error 977 occurred at disk power-on lifetime: 31923 hours (1330 days + 3 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 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  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 ff ff ff 4f 00      00:06:51.007  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:51.007  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:51.007  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:51.006  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:51.006  READ FPDMA QUEUED

Error 976 occurred at disk power-on lifetime: 31923 hours (1330 days + 3 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 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  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 ff ff ff 4f 00      00:06:48.218  READ FPDMA QUEUED
  61 00 38 ff ff ff 4f 00      00:06:48.217  WRITE FPDMA QUEUED
  27 00 00 00 00 00 e0 00      00:06:48.217  READ NATIVE MAX ADDRESS EXT [OBS-ACS-3]
  ec 00 00 00 00 00 a0 00      00:06:48.215  IDENTIFY DEVICE
  ef 03 46 00 00 00 a0 00      00:06:48.215  SET FEATURES [Set transfer mode]

Error 975 occurred at disk power-on lifetime: 31923 hours (1330 days + 3 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 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  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 ff ff ff 4f 00      00:06:45.262  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:45.256  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:45.246  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:45.242  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:06:45.235  READ FPDMA QUEUED

Error 974 occurred at disk power-on lifetime: 31923 hours (1330 days + 3 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 ff ff ff 0f  Error: UNC at LBA = 0x0fffffff = 268435455

  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 20 ff ff ff 4f 00      00:01:35.260  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:01:35.253  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:01:35.249  READ FPDMA QUEUED
  60 00 08 ff ff ff 4f 00      00:01:35.249  READ FPDMA QUEUED
  60 00 18 ff ff ff 4f 00      00:01:35.247  READ FPDMA QUEUED

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%     11388         -
# 2  Short offline       Completed without error       00%     10594         -
# 3  Short offline       Completed without error       00%      9649         -
# 4  Short offline       Completed without error       00%      9203         -
# 5  Short offline       Completed without error       00%      8696         -
# 6  Short offline       Completed without error       00%      7998         -
# 7  Short offline       Completed without error       00%      7611         -
# 8  Short offline       Completed without error       00%      7116         -
# 9  Short offline       Completed without error       00%      6753         -
#10  Short offline       Aborted by host               40%      6540         -
#11  Extended offline    Completed without error       00%      6512         -
#12  Short offline       Completed without error       00%      6499         -
#13  Short offline       Completed: read failure       90%      6496         577789318
#14  Short offline       Completed without error       00%      6296         -
#15  Short offline       Completed without error       00%      6182         -
#16  Short offline       Aborted by host               90%      5832         -
#17  Short offline       Completed without error       00%      4715         -
#18  Short offline       Completed without error       00%      4704         -
#19  Short offline       Completed without error       00%      4291         -
#20  Short offline       Completed without error       00%      4252         -
#21  Short offline       Completed without error       00%      4008         -
1 of 1 failed self-tests are outdated by newer successful extended offline self-test #11

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.

I am getting new battery today! Other than that, what else can i do?

EDIT

I ran some more tests and they resulted positive!

mercurial@providence:~$ sudo smartctl -H /dev/sda6
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-5.2.0-kali2-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
Please note the following marginal Attributes:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
190 Airflow_Temperature_Cel 0x0022   053   036   045    Old_age   Always   In_the_past 47 (157 57 48 46 0)

mercurial@providence:~$ sudo badblocks -v /dev/sda6 > badsectors.txt
Checking blocks 0 to 120364031
Checking for bad blocks (read-only test): done                                                 
Pass completed, 4 bad blocks found. (4/0/0 errors)

As you can see there were 4 BadBlocks found...

2 Answers 2

1

Bad news - your harddrive is NOT comparitively healty. Well, it is more healthy compared to completely dead drive, but it is damaged. Both the Linux kernel messages and S.M.A.R.T. logs confirm errors reading certain areas of the disk:

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   097   089   006    Pre-fail  Always       -       176927878
  7 Seek_Error_Rate         0x000f   078   060   030    Pre-fail  Always       -       78548952961
187 Reported_Uncorrect      0x0032   001   001   000    Old_age   Always       -       1256

I would recommend creating (and verifying) immediate backup (or few of them) of all important data (on all partitions!) before proceeding to use this machine - preferably by manually backing up most important data first, and then the less important data.

Doing more activity on that disk (including trying to assess the extent of damage) is likely to produce even more damage.

After you are sure you've backed up all data you care about, you can use badblocks(8) to assess the extent of the damage.

If the disk is under warranty, you might get a replacement (be sure to destroy all confidential data first if needed, by using manufacturer low level format program for example). If not under warranty, I would recommend buying new disk.

If those are not an option, you may try to use badblocks -w to force the disk to try to reallocate the damaged sectors (or expert mode of fdisk(8) to create smaller partition in undamaged area of the disk), but even when it works the disk is likely to develop more problems in the future (so you probably shouldn't put any irreplaceable data on it).

Note that this will destroy the data and you will need to reinstall OSs and data on all damaged partitions. (there is also badblocks -n which will only mangle the files that are damaged and leave the rest of system as-is, but IMHO one-time clean reinstall is preferred to perpetual uncertainty if any error you get is due to damaged system files or something else)

1
  • I ran some tests and they resulted in 4 badblocks, when i am trying to add those badblocks to HDD list, i am not able to access them.
    – Mercurial
    Oct 9, 2019 at 13:45
1

Running a SMARTCTL check to get harddisk health,

mercurial@providence:~$ sudo smartctl -H /dev/sda6
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-5.2.0-kali2-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
Please note the following marginal Attributes:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
190 Airflow_Temperature_Cel 0x0022   053   036   045    Old_age   Always   In_the_past 47 (157 57 48 46 0)

Looking for badsectors in our faulty partition,

mercurial@providence:~$ sudo badblocks -v /dev/sda6 > badsectors.txt
Checking blocks 0 to 120364031
Checking for bad blocks (read-only test): done                                                 
Pass completed, 4 bad blocks found. (4/0/0 errors)

This resulted in following badblocks list, badsectors.txt

28
29
30
31

Dry run the partition table,

sudo mkfs.ext4 -n /dev/sda6

Do the MAGIC, i.e. fixing your lost partition,

sudo e2fsck -f -b 32768 -y /dev/sda6

Mark the bad blocks you just found,

mercurial@providence:~$ sudo e2fsck -l badsectors.txt /dev/sda6
e2fsck 1.45.4 (23-Sep-2019)
Debian: Updating bad block inode.
Pass 1: Checking inodes, blocks, and sizes
Programming error?  block #28 claimed for no reason in process_bad_block.
Programming error?  block #29 claimed for no reason in process_bad_block.
Programming error?  block #30 claimed for no reason in process_bad_block.
Programming error?  block #31 claimed for no reason in process_bad_block.
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong for group #0 (22671, counted=22675).
Fix<y>? yes
Free blocks count wrong (18013090, counted=18013094).
Fix<y>? yes

Debian: ***** FILE SYSTEM WAS MODIFIED *****
Debian: 912529/7528448 files (0.6% non-contiguous), 12077914/30091008 blocks

And voila! you have successfully recovered your partition with your data!

2
  • Good work! Note however that whatever data was on those blocks is now lost/corrupted. On the bright side only 4 bad block does not sound that bad. Also, depending on the nature of the damage, disk might not be as reliable as before, so backup often would be a good strategy. (well, it is ALWAYS a good strategy) Oct 9, 2019 at 16:28
  • Thanks for pointing me in right direction, and yes I already moved all my data to external HDDs (2x2TB External Power + 1x1TB Portable). If you could recommend me a good Local Storage Server what would that be? @MatijaNalis
    – Mercurial
    Oct 9, 2019 at 16:36

Not the answer you're looking for? Browse other questions tagged .