Re: "Repair" hard disk with bad sectors by reading and rewriting same data?

"Percival P. Cassidy" <[email protected]>
Newsgroups alt.comp.hardware
Message-ID <[email protected]>
On 8/13/20 3:18 PM, VanguardLH wrote:
> "Percival P. Cassidy" <[email protected]> wrote:
> 
>> I have a 6TB drive that shows 8 bad sectors. Would it be possible to
>> repair it without harm to the data using
>>
>> dd if=/dev/daX of=/dev/daX (and perhaps with bs settinng as well) ??
> 
> dd lets you copy an entire partition atop of itself?  Seems dangerous.
> If there is an error during the operation, well, that's why dd is also
> known as disk destroyer.

I don't know for sure that dd does allow that. I was just wondering.
> 
> Presumably you don't know in file(s) encompass the bad sectors.  Or do
> any files use those sectors, and instead the bad sectors are in free
> space?

I don't know -- haven't tried. But if I knew, I guess I could simply 
make a copy of the file with a different name and it would end up on a 
different part of the drive, and then I could try writing zeroes to the 
bad sectors.

> Why not use fsck (if the volume can be unmounted, like "sudo unmount
> /dev/daX", and then "sudo fsck /dev/daX)?  If the bad sectors are in
> free space, go for it.  If the bad sectors are used in files, do a
> logical (file) backup beforehand, or use dd to save a disk image (in
> another partition or to an .img file).
> 
> I haven't used [U|Li]nux for many years.  Wait until a *NIX guru shows
> up, but what you propose to write a partition atop of itself looks
> dangerous, and I would think dd would error on that attempt.
> 
> Since dd is just a copy tool, I don't see that it will attempt to
> recover iffy sectors.  The copy may be devoid of any files with bad
> sectors because, after all, they couldn't be read without error.
> 
> "dd conv=noerror" will continue after an error, but it skips bad blocks.
> Adding the sync option just adds zeros instead of skipping the bad
> blocks.  gddrescue also keeps going after an error, but it attempts
> recovery on a partial yield from a bad block while trying to read each
> sector in a block.  However, in either case, if a block is completely
> unreadable then no data gets read from it into the copy or image.
> 
> Is this such an old HDD that it doesn't include its own firmware to
> remap bad sectors using S.M.A.R.T.?  If you read the SMART data from the
> HDD, and there is still a non-zero Current Pending Sector Count (raw
> count), that count doesn't go down after a reboot?  The pending count
> should go down (to do the remapping using the HDD's firmware) while the
> Reallocated Sectors Count goes up.

It's a comparatively recent (although now out of warranty) Seagate SATA 
drive.

Current Pending Sector Count and Uncorrectable Sector Count are both 8 
sectors, but Reported Uncorrectable Sectors and Reallocated Sector Count 
are both 0 sectors. Haven't changed after several reboots and power 
off/on cycles.


> https://www.disktuna.com/reallocated-sectors-pending-and-event-count-dealing-with-bad-sectors/
> See "Pending Sectors" section.
> 
> Note that more remapped sectors means slower read and write speeds.  The
> remapping (reading a remapped sector and then having to read the
> alternate sector used for remapping) takes time.  If the Current Pending
> Sector Count does not go down, there are no more reserve sectors on that
> hard disk, so the bad sectors cannot get remapped.  If that count
> doesn't go down, you need to look at replacing the hard disk, and soon.
> If the count goes down, the HDD's firmware did its job of remapping the
> bad sectors.  With an ever-increasing pending count, you need to clone
> to a partition on a new or different HDD, and get all partitions off the
> old HDD onto the new one.
> 
or> There are many free tools to read SMART data from a drive.  There might
> be some good free disk health monitor tools, but to get decent testing
> and recovery features often means having to pay.  For example, there's a
> free version of HD (Hard Disk) Sentinel.  I use that but under Windows,
> and I eventually went to a paid version.  They have a full-feature trial
> version usable for 30 days.  It's been too long since I used their free
> version to remember if it was effective to get bad sectors remapped (or
> prods the HDD to do it).  Try the free version, and it that is
> insufficient then try their trial version.  Just be aware that some
> "refresh" operations on a disk can be destructive (make sure your files
> are saved elsewhere).
> 
> A simple copy operation, like you proposed, does not get a bad sector
> remapped.  It just tries to copy what it can to the destination, but the
> bad sector remains bad at the source.

I have done dd if=/dev/zero on several drives. The Pending Sector Count 
and Uncorrectable Sector Count both become 0 sectors, but Reported 
Uncorrectable Sectors and Reallocated Sector Count both remain at 0 sectors.

I have HD Sentinel Pro on a couple of Windows machines,, but i don't 
know what a Windows machine will make of an ext4-formatted drive.

> While disk recovery tools are geared towards recovering data from bad
> sectors and then prodding the hardware to remap the bad sectors, maybe
> you can use "smartctl -t offline /dev/daX" to tell the disk's firmware
> to do an offline surface scan to get the bad sectors remapped.  However,
> I don't know that attempts any data recovery from the bad sectors.

I've run smartctl with both short and long offline tests, but they do 
not bring the bad sector count down. They also show "Completed without 
error."

Perce
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.