1

I have some problems with my laptop hdd, due to a lack of electricity during a critical update.

Since then, I have been able to reboot with little to no further issues, but recently, possibly due to another major update or something worsening with the hdd (no clue, really...), my machine became not bootable by hdd alone (well, I didn't try using Windows, actually, but not with Ubuntu which is basically the sole OS I use on it), so I had to use a Ubuntu USB pendrive to make it work.

I have followed many online tutorials on how to deal with it and finally installed smartmontools with little benefit, as using smartctl to find reallocated sectors as some online resource didn't give any result.

I had much better luck following another tutorial and using sudo badblocks -sv -b 512 /dev/sdb: after a long scan, I got out of it:

618997769one, 1:58:10 elapsed. (1/0/0 errors)
618997770one, 1:58:13 elapsed. (2/0/0 errors)
618997771one, 1:58:16 elapsed. (3/0/0 errors)
618997772one, 1:58:20 elapsed. (4/0/0 errors)
618997773one, 1:58:23 elapsed. (5/0/0 errors)
618997774one, 1:58:26 elapsed. (6/0/0 errors)
618997775one, 1:58:30 elapsed. (7/0/0 errors)
618997776one, 1:58:33 elapsed. (8/0/0 errors)
618997777one, 1:58:36 elapsed. (9/0/0 errors)
618997778one, 1:58:39 elapsed. (10/0/0 errors)
618997779one, 1:58:42 elapsed. (11/0/0 errors)
618997780one, 1:58:45 elapsed. (12/0/0 errors)
618997781one, 1:58:49 elapsed. (13/0/0 errors)
618997782one, 1:58:52 elapsed. (14/0/0 errors)
618997783one, 1:58:56 elapsed. (15/0/0 errors)
618997784one, 1:58:59 elapsed. (16/0/0 errors)
618997785one, 1:59:02 elapsed. (17/0/0 errors)
618997786one, 1:59:05 elapsed. (18/0/0 errors)
618997787one, 1:59:08 elapsed. (19/0/0 errors)
618997788one, 1:59:12 elapsed. (20/0/0 errors)
618997789one, 1:59:15 elapsed. (21/0/0 errors)
618997790one, 1:59:18 elapsed. (22/0/0 errors)
618997791one, 1:59:21 elapsed. (23/0/0 errors)
618997792one, 1:59:25 elapsed. (24/0/0 errors)
618997793one, 1:59:28 elapsed. (25/0/0 errors)
618997794one, 1:59:31 elapsed. (26/0/0 errors)
618997795one, 1:59:35 elapsed. (27/0/0 errors)
618997796one, 1:59:38 elapsed. (28/0/0 errors)
618997797one, 1:59:41 elapsed. (29/0/0 errors)
618997798one, 1:59:44 elapsed. (30/0/0 errors)
618997799one, 1:59:47 elapsed. (31/0/0 errors)
618997800one, 1:59:50 elapsed. (32/0/0 errors)
618997801one, 1:59:53 elapsed. (33/0/0 errors)
618997802one, 1:59:57 elapsed. (34/0/0 errors)
618997803one, 2:00:00 elapsed. (35/0/0 errors)
618997804one, 2:00:03 elapsed. (36/0/0 errors)
618997805one, 2:00:07 elapsed. (37/0/0 errors)
618997806one, 2:00:10 elapsed. (38/0/0 errors)
618997807one, 2:00:13 elapsed. (39/0/0 errors)
618997808one, 2:00:16 elapsed. (40/0/0 errors)
618997809one, 2:00:19 elapsed. (41/0/0 errors)
618997810one, 2:00:23 elapsed. (42/0/0 errors)
618997811one, 2:00:26 elapsed. (43/0/0 errors)
618997812one, 2:00:29 elapsed. (44/0/0 errors)
618997813one, 2:00:32 elapsed. (45/0/0 errors)
618997814one, 2:00:35 elapsed. (46/0/0 errors)
618997815one, 2:00:38 elapsed. (47/0/0 errors)
618997816one, 2:00:41 elapsed. (48/0/0 errors)
618997817one, 2:00:45 elapsed. (49/0/0 errors)
618997818one, 2:00:48 elapsed. (50/0/0 errors)
618997819one, 2:00:51 elapsed. (51/0/0 errors)
618997820one, 2:00:55 elapsed. (52/0/0 errors)
618997821one, 2:00:58 elapsed. (53/0/0 errors)
618997822one, 2:01:01 elapsed. (54/0/0 errors)
618997823one, 2:01:04 elapsed. (55/0/0 errors)
618997824one, 2:01:07 elapsed. (56/0/0 errors)
618997825one, 2:01:10 elapsed. (57/0/0 errors)
618997826one, 2:01:14 elapsed. (58/0/0 errors)
618997827one, 2:01:17 elapsed. (59/0/0 errors)
618997828one, 2:01:20 elapsed. (60/0/0 errors)
618997829one, 2:01:23 elapsed. (61/0/0 errors)
618997830one, 2:01:26 elapsed. (62/0/0 errors)
618997831one, 2:01:30 elapsed. (63/0/0 errors)
done                                                 
Pass completed, 64 bad blocks found. (64/0/0 errors)

Which at least was rather informative about whether I had something wrong and, in case, where it was. Still no clue about why numbers are followed by "one", so feel free to tell me that part too.

At this point I tried what I found suggested the most, which was going for a fixing strike:

sudo hdparm --write-sector --yes-i-know-what-i-am-doing 618997831 /dev/sdb

A shame that even trying with one or other different version, it only gave me back:

write-sector: bad/missing sector value

And here I am kinda lost: any tip, the more education/informative the better, would be highly appreciated.

Thanks in advance for your kind attention and just ask if I forgot some critical detail :)

Edit: Oh, thanks a lot @David!

That indeed helped, but now that sdb seems ok, I got this from sda, still using sudo badblocks -sv -b 512 /dev/sda:

Checking blocks 0 to 625142447
Checking for bad blocks (read-only test):   0.00% done, 0:00 elapsed. (0/0/0 err545995272one, 1:26:12 elapsed. (0/0/0 errors)
545995273one, 1:26:15 elapsed. (1/0/0 errors)
545995274one, 1:26:18 elapsed. (2/0/0 errors)
545995275one, 1:26:21 elapsed. (3/0/0 errors)
545995276one, 1:26:25 elapsed. (4/0/0 errors)
545995277one, 1:26:28 elapsed. (5/0/0 errors)
545995278one, 1:26:31 elapsed. (6/0/0 errors)
545995279one, 1:26:35 elapsed. (7/0/0 errors)
545995280one, 1:26:39 elapsed. (8/0/0 errors)
545995281one, 1:26:43 elapsed. (9/0/0 errors)
545995282one, 1:26:47 elapsed. (10/0/0 errors)
545995283one, 1:26:55 elapsed. (11/0/0 errors)
545995284one, 1:27:00 elapsed. (12/0/0 errors)
545995285one, 1:27:06 elapsed. (13/0/0 errors)
545995286one, 1:27:11 elapsed. (14/0/0 errors)
545995287one, 1:27:17 elapsed. (15/0/0 errors)
545995288one, 1:27:21 elapsed. (16/0/0 errors)
545995289one, 1:27:25 elapsed. (17/0/0 errors)
545995290one, 1:27:29 elapsed. (18/0/0 errors)
545995291one, 1:27:35 elapsed. (19/0/0 errors)
545995292one, 1:27:39 elapsed. (20/0/0 errors)
545995293one, 1:27:46 elapsed. (21/0/0 errors)
545995294one, 1:27:49 elapsed. (22/0/0 errors)
545995295one, 1:27:53 elapsed. (23/0/0 errors)
545995296one, 1:27:56 elapsed. (24/0/0 errors)
545995297one, 1:27:59 elapsed. (25/0/0 errors)
545995298one, 1:28:02 elapsed. (26/0/0 errors)
545995299one, 1:28:06 elapsed. (27/0/0 errors)
545995300one, 1:28:09 elapsed. (28/0/0 errors)
545995301one, 1:28:12 elapsed. (29/0/0 errors)
545995302one, 1:28:16 elapsed. (30/0/0 errors)
545995303one, 1:28:19 elapsed. (31/0/0 errors)
545995304one, 1:28:22 elapsed. (32/0/0 errors)
545995305one, 1:28:28 elapsed. (33/0/0 errors)
545995306one, 1:28:31 elapsed. (34/0/0 errors)
545995312one, 1:28:38 elapsed. (35/0/0 errors)
545995313one, 1:28:42 elapsed. (36/0/0 errors)
545995320one, 1:28:49 elapsed. (37/0/0 errors)
545995328one, 1:28:58 elapsed. (38/0/0 errors)
545995329one, 1:29:02 elapsed. (39/0/0 errors)
545995336one, 1:29:06 elapsed. (40/0/0 errors)
545995337one, 1:29:10 elapsed. (41/0/0 errors)
545995338one, 1:29:13 elapsed. (42/0/0 errors)
618997768one, 1:45:58 elapsed. (43/0/0 errors)
618997769one, 1:46:02 elapsed. (44/0/0 errors)
618997770one, 1:46:05 elapsed. (45/0/0 errors)
618997771one, 1:46:08 elapsed. (46/0/0 errors)
618997772one, 1:46:11 elapsed. (47/0/0 errors)
618997773one, 1:46:14 elapsed. (48/0/0 errors)
618997774one, 1:46:18 elapsed. (49/0/0 errors)
618997775one, 1:46:21 elapsed. (50/0/0 errors)
618997792one, 1:46:24 elapsed. (51/0/0 errors)
618997793one, 1:46:28 elapsed. (52/0/0 errors)
618997794one, 1:46:31 elapsed. (53/0/0 errors)
618997795one, 1:46:34 elapsed. (54/0/0 errors)
618997796one, 1:46:38 elapsed. (55/0/0 errors)
618997797one, 1:46:41 elapsed. (56/0/0 errors)
618997798one, 1:46:44 elapsed. (57/0/0 errors)
618997799one, 1:46:48 elapsed. (58/0/0 errors)
618997808one, 1:46:51 elapsed. (59/0/0 errors)
618997809one, 1:46:55 elapsed. (60/0/0 errors)
618997810one, 1:46:58 elapsed. (61/0/0 errors)
618997811one, 1:47:01 elapsed. (62/0/0 errors)
618997812one, 1:47:05 elapsed. (63/0/0 errors)
618997813one, 1:47:08 elapsed. (64/0/0 errors)
618997814one, 1:47:11 elapsed. (65/0/0 errors)
618997815one, 1:47:14 elapsed. (66/0/0 errors)
618997816one, 1:47:18 elapsed. (67/0/0 errors)
618997817one, 1:47:21 elapsed. (68/0/0 errors)
618997818one, 1:47:24 elapsed. (69/0/0 errors)
618997819one, 1:47:27 elapsed. (70/0/0 errors)
618997820one, 1:47:30 elapsed. (71/0/0 errors)
done                                                 
Pass completed, 72 bad blocks found. (72/0/0 errors)

I assume that I will have to use hdparm again, correct? Is there any smart way to automate instead of launching the command 72 times? I could make a Python script to concatenate them with ";", but if there is a smart way, just let me know.

Thanks for your support so far :)

David Foerster
  • 36,264
  • 56
  • 94
  • 147
Ajna
  • 13
  • 5
  • 1
    Possible duplicate of Mark bad sectors on hard drive without formating as this seems to be what you ultimately want to achieve. You should still get a new drive as soon as possible though because this one is likely to fail in the very near future. – David Foerster Mar 29 '16 at 23:06
  • Not sure, as I also had to fix a bit of stuff with e2fsck. Not sure if the hdd is falling on me: might be wishful thinking, but despite being rather old, it only got this problem during a critical system update flawed by the electricity going off.

    Any way to test the hdd a bit better and see if it is about to die?

    – Ajna Mar 31 '16 at 00:16
  • https://askubuntu.com/questions/539184/how-do-i-check-the-integrity-of-a-storage-medium-hard-disk-or-flash-drive – David Foerster Mar 31 '16 at 11:16

3 Answers3

0

Your hdparm command is wrong. Please refer to the manual (highlight by me):

--write-sector

Writes zeros to the specified sector number. VERY DANGEROUS. The sector number must be given (base10) after this option. hdparm will issue a low-level write (completely bypassing the usual block layer read/write mechanisms) to the specified sector. This can be used to force a drive to repair a bad sector (media error).

The correct command for your purpose seems to be

sudo hdparm --write-sector 618997831 --yes-i-know-what-i-am-doing /dev/sdb

Edit: Since you have now extended your question to not just one bad block but all detected bad blocks, I flagged this question as a duplicate of one that deals with the more general problem of getting the disk drive controller to re-assign bad blocks with spare reserve blocks.

David Foerster
  • 36,264
  • 56
  • 94
  • 147
  • Updated description with the news, but in the meantime thanks again for your precious support! – Ajna Mar 29 '16 at 22:49
  • Oh, sorry, I didn't remember I could do that already. I just complied more than gladly, thanks again! – Ajna Apr 03 '16 at 02:24
0

You can use dd to write all 72 sectors at once:

sudo dd if=/dev/zero of=/dev/sda bs=512 seek=545995273 count=72

As for whether the drive is physically dieing or not, check the SMART stats, but with that many bad sectors, I would suspect it is more than just the power fail, which tends to only corrupt one. After the write, if the SMART stats say you have a bunch of reallocated sectors, then they are physically damaged and you should replace the drive.

psusi
  • 37,551
  • A shame I wrote a script in Python to give me the list of commands to fix all the sector; any tip for where I get the most updated SMART stats? – Ajna Apr 03 '16 at 02:26
  • @Ajna, from the gnome disks utility or smartctl – psusi Apr 03 '16 at 12:57
-2

You can run sudo fsck /dev/sdband that should fix what ever bad sectors you have. If you lost power during an update you may want to try to update again so run sudo apt-get update then sudo apt-get upgrade

  • Can I update again while booting from USB? And I still think that won't fix my damaged hdd sectors. – Ajna Mar 28 '16 at 17:46
  • I'd give it a try, you can also run badblocks -svn /dev/sdb , once it's finished boot into your main OS and try to run the update again – TheStarvingGeek Mar 28 '16 at 17:50
  • 1
    -1 A plain fsck will not scan for or fix bad sectors. Some file-system-specific checkers can do that (through badblocks) with a special option, but even they will not "fix" the blocks but flag it as unusable for the file system. – David Foerster Mar 28 '16 at 19:07
  • if you use the -y or -a options it will, and thats only if you don't want to review it before you fix it – TheStarvingGeek Mar 28 '16 at 19:14
  • 1
    The -y and -a options do not result in a block check of the underlying device. Please refer to the manual page of fsck(8) for details. What you mean may be the -c option of e2fsck(8) (alias fsck.ext4). – David Foerster Mar 29 '16 at 22:55