2

My HD had a few corrupted files so I wanted to check all the sectors and have the HD controllers mark the failing one.

Following the advices from this answer, I have run a badblocks on my external HD. From the answer, this command force checking of all sectors [...] If you have fully processed your disk this way, the disk controller should have replaced all bad blocks by working ones and the reallocated count will be increased in the SMART log.

I run this command sudo badblocks -svvn -c 262144 /dev/sdd

The result is Pass completed, 103 bad blocks found. (103/0/0 errors)

I did a sudo smartctl --all /dev/sdd before and after the badblocks and there are a few difference but not in the Reallocated_Sector_Ct even though badblocks found 103 read errors. After badblocks I still get the same output as before it :

  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always    -       0

The difference are only:
1- between the Raw_Read_Error_Rate:

Before badblocks:
    1 Raw_Read_Error_Rate   0x002f   196   196   051    Pre-fail  Always    -       429
After badblocks:
    1 Raw_Read_Error_Rate   0x002f   191   189   051    Pre-fail  Always    -       1221

2- between the Current_Pending_Sector : but here, the raw value increased after badblocks which doesn't makes sense to me as Pending are sectors which might be reallocated in case the next write fails. If bad sectors were found, the number should have decrease... or am I missing something?

Before badblocks:
    197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always    -       16
After badblocks:
    197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always    -       24

My main question is: Is the disk controller of my HD now aware of the sectors that are bad and won't used them anymore or did the badblocks simply informed me without having any effect on the way my HD will work in the future?


Edit3:

ubuntu@ubuntu:~$ sudo e2fsck -fccky /dev/sdd
e2fsck 1.45.5 (07-Jan-2020)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/sdd

The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device> or e2fsck -b 32768 <device>

Found a dos partition table in /dev/sdd

Edit 2:

ubuntu@ubuntu:~$ lsusb
Bus 002 Device 004: ID 0bda:0138 Realtek Semiconductor Corp. RTS5138 Card Reader Controller
Bus 002 Device 003: ID 13fe:3123 Kingston Technology Company Inc. Verbatim STORE N GO 4GB
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 0c45:6473 Microdia
Bus 001 Device 006: ID 0cf3:e004 Qualcomm Atheros Communications
Bus 001 Device 003: ID 04f2:0976 Chicony Electronics Co., Ltd
Bus 001 Device 007: ID 1058:0730 Western Digital Technologies, Inc. My Passport Essential (WDBACY)
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Edit: I am not sure how to do the grep -i FPDMA /var/log/syslog* and couldn't find any info on the web so I simply paste the command in a terminal but nothing happend: enter image description here

As for the Disks SMART Data & Tests, the menu is grayed out:

enter image description here

MagTun
  • 155
  • At the link you gave, the primary answer suggested the use of the badblocks command. If you man badblocks you'll see a note that it shouldn't be used directly, and gives alternate instructions. I just added the correct way to bad block as an answer in that link. Edit your question and show me grep -i FPDMA /var/log/syslog*, and show me a complete screenshot of the Disks SMART Data & Tests data window, which is scrollable, and may require two screenshots. – heynnema Apr 26 '21 at 16:05
  • The disk controller has no knowledge of bad blocks on the disk. The disk, and the bad block table located on disk, is how the disk knows about bad blocks. – heynnema Apr 26 '21 at 16:10
  • Because you used badblocks instead of the proper e2fsck command, you may have overwritten the original bad block table on disk, and lost all prior knowledge of bad blocks that existed at manufacture time, or any prior bad blocking. – heynnema Apr 26 '21 at 16:12
  • @heynnema thanks for your help! I edited my question with a printscreen of the two tests but I wasn't able to run then. I didn't know about this bad block table, thanks for explaining it! So the original bad block table on disk is probably deleted (which probably explains the increase in Current_Pending_Sector) but I still don't understand why badblock didn't add the bad blocks it found to the Reallocated_Sector_Ct – MagTun Apr 26 '21 at 19:17
  • It won't move from current_pending_sectors to reallocated_sector_ct until the block is actually proven to be bad. The grep command was searching for a specific error in syslog. The Disks app isn't finding that your disk has SMART. Install gsmartcontrol, which will also install smartmontools, and then run one/both to see if they can detect SMART data. – heynnema Apr 26 '21 at 20:00
  • @heynnema, thanks you for your help. I don't have access to the buggy HD for the moment, I will get back to you as soon as I will get it. – MagTun Apr 28 '21 at 18:23
  • @heynnema I have install gsmartcontrol but I don't understand which command I should do to see if they can detect SMART data on my HDD (https://gsmartcontrol.sourceforge.io/home/index.php/Documentation doesn't explain it clearly). I have already run sudo smartctl --all /dev/sdd so I am not sure which command you mean. – MagTun Apr 30 '21 at 11:13
  • In anycase, here are the links to the full report of the two sudo smartctl --all /dev/sdd I did before and after running thesudo badblocks -svvn -c 262144 /dev/sdd command: https://pastebin.com/mjGP3T8U and https://pastebin.com/g6SpJQq4 – MagTun Apr 30 '21 at 11:20
  • Is this drive connected to a USB3 port, or a SATA port? If USB3, edit your question and show me lsusb. Start comments to me with @heynnema or I may miss them. – heynnema Apr 30 '21 at 13:39
  • @heynnema, thanks so much for your help! Yes it is an external HD connected via USB (the HD supports USB3 but not the computer). I added the full result of lsusb in my question but this is the most relevant line: Bus 001 Device 007: ID 1058:0730 Western Digital Technologies, Inc. My Passport Essential (WDBACY) – MagTun Apr 30 '21 at 15:45
  • Please see my answer. If it helps to solve the problem, please remember to accept it by clicking on the checkmark icon that appears just to the left of my answer. Thanks! – heynnema Apr 30 '21 at 18:31

1 Answers1

2

WDC WD5000BMVW-11AMCS0

First we disable UAS for this WDC drive...

# drop this into /etc/modprobe.d/disable_uas.conf
# -rw-r--r--   1 root root  500 Apr 30 06:59 disable-uas.conf
#
# sources:
# https://unix.stackexchange.com/questions/525290/usb-hdd-not-found
# https://unix.stackexchange.com/questions/239782/connection-problem-with-usb3-external-storage-on-linux-uas-driver-problem
#
# examples:
# options usb-storage quirks=059f:105e:u 
# options usb-storage quirks=059f:105f:u,059f:105e:u,174c:1351:u
#
# do these commands:
# sudo update-initramfs -u
# reboot
#
# WDC WD5000BMVW-11AMCS0 drive
# Bus 001 Device 007: ID 1058:0730 Western Digital Technologies, Inc. My Passport Essential (WDBACY)
options usb-storage quirks=1058:0730:u

Bad Block

Then we bad block using the recommended method...

Note: do NOT abort a bad block scan!

Note: do NOT bad block a SSD

Note: backup your important files FIRST!

Note: this will take many hours

Note: you may have a pending HDD failure

Boot to a Ubuntu Live DVD/USB in “Try Ubuntu” mode.

In terminal...

sudo fdisk -l # identify all "Linux Filesystem" partitions

sudo e2fsck -fcky /dev/sdXX # read-only test

or

sudo e2fsck -fccky /dev/sdXX # non-destructive read/write test (recommended)

The -k is important, because it saves the previous bad block table, and adds any new bad blocks to that table. Without -k, you loose all of the prior bad block information.

The -fccky parameter...

   -f    Force checking even if the file system seems clean.

-c This option causes e2fsck to use badblocks(8) program to do a read-only scan of the device in order to find any bad blocks. If any bad blocks are found, they are added to the bad block inode to prevent them from being allocated to a file or direc‐ tory. If this option is specified twice, then the bad block scan will be done using a non-destructive read-write test.

-k When combined with the -c option, any existing bad blocks in the bad blocks list are preserved, and any new bad blocks found by running badblocks(8) will be added to the existing bad blocks list.

-y Assume an answer of `yes' to all questions; allows e2fsck to be used non-interactively. This option may not be specified at the same time as the -n or -p options.

heynnema
  • 70,711
  • Thanks for this! The command says that superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem (I have added the full result in my question) – MagTun Apr 30 '21 at 19:51
  • @MagTun Your command "sudo e2fsck -fccky /dev/sdd" is incorrect. You don't bad block sdd, but rather a partition, like sdd1 or sdd2... etc. That's why I have you run the fdisk command. Also, did you do the first part of my answer and reboot? – heynnema Apr 30 '21 at 22:09
  • @MagTun Status please... – heynnema May 01 '21 at 14:02
  • thanks for your patience and sorry I can't give you updates more often, I only have access to the HD in the evening (European timezone). Sorry for this stupid mistake, I should have paid more attention. Yes, I did the first part of your answer and I also rebooted afterward. I retried with sudo e2fsck -fccky /dev/sdd1 but it is still not working. Here is the result: https://pastebin.com/8mKv2vAd – MagTun May 01 '21 at 19:36
  • I tried to find a solution, like with this question, but without success. – MagTun May 01 '21 at 19:39
  • @MagTun My bad block procedure is for Linux ext2/3/4 partitions. sdd1 is a ntfs partition. You'll have to bad block that from Windows. Did the first part of my answer eliminate any sdd errors in syslog? grep -i sdd /var/log/syslog*. – heynnema May 01 '21 at 20:25
  • Well, Windows doesn't recognized the HD (it doesn't even appear in device manager), so I guess, the only solution that remains is to try to format it with linux and then try again on Windows. Thanks a lot for help and your patience. I am amazed by how much efforts you put into helping me, so once again, thanks so much! – MagTun May 02 '21 at 19:43
  • @MagTun Formatting it to ext2/3/4 will allow it to be seen on Linux, and you'll be able to bad block it using my procedure. Windows won't recognize ext2/3/4 format. – heynnema May 02 '21 at 19:53