How to remove Bad Sectors from HD

Questions about the project and the distribution - obviously no support questions here please

How to remove Bad Sectors from HD

Postby madonawills on Mon Nov 19, 2012 5:45 am

I want to remove Bad Sectors from my Hard Disk, How I can ?
madonawills
 

Linux Mint is funded by ads and donations.
 

Re: How to remove Bad Sectors from HD

Postby itsme4401 on Mon Nov 19, 2012 6:14 am

Simply stated: You can't.
Even worse: Your HDD is stating to you that its decease is immiment.
Smartcontrol
Code: Select all
sudo smartctl -a /dev/sda
should give you the answer how bad it is.
Back up your data now(!) i.e. even before you run smartcontrol.
itsme4401
Level 3
Level 3
 
Posts: 104
Joined: Sat Nov 27, 2010 4:12 pm
Location: Netherlands

Re: How to remove Bad Sectors from HD

Postby homerscousin on Fri Nov 23, 2012 3:54 pm

It depends. A power outage can cause bad sectors. They can probably be fixed. A deteriorating disk surface or read/write head you may fix some errors now, but they will be back. Noone here could even guess without you posting your SMART numbers. There are lots of disk scanning programs out there from HDD manufacturers, Windows and Linux. You can easily Google search this. Just be aware that these programs are very HDD intensive. They scan the entire disk. If you have a fragile disk to begin with, it may only make it worse. Be prepared with a new drive and save all your important files before you try to fix.
i5 3570k, ASRock z77 Extreme 4, 8 Gb Ripjaws 1600, Antec 430w psu, HVR 1600 tv tuner, custom case- marble top, oak face. Carver & DCM Time Window sound system. Mint 14 KDE.
homerscousin
Level 5
Level 5
 
Posts: 541
Joined: Fri May 25, 2012 2:43 pm
Location: Somewhere on planet Earth (mostly)

Re: How to remove Bad Sectors from HD

Postby heavy metal on Sat Nov 24, 2012 12:49 pm

Install "GSmartControl" and/or "Gnome-Disk-Utility (Palimpsest)", Both programs are IMHO the best out there and they work very good in telling you the condition of your disk, been using these programs since Lucid Linx and now on LM Maya!
Linux Mint Debian Edition MATE DE 64-bit
Gigabyte G41M-ES2L--->2gb ram
Intel Pentium Dual Core 2.60ghz-->E5300
WD-6400AAKS-Caviar-SE16-640gb
Proud user of LMDE
User avatar
heavy metal
Level 2
Level 2
 
Posts: 90
Joined: Mon Jan 25, 2010 11:00 pm
Location: Puerto Rico

Re: How to remove Bad Sectors from HD

Postby heavy metal on Mon Jun 02, 2014 6:40 pm

FYI, I have succeeded in removing bad sectors from my brother's 160GB Western Digital Hard Drive, I just used an Windows XP install cd I had around, just use the "Full Format" option, not the "Quick Format" option, the Windows Full Format option will check and try to repair any errors like bad sectors on your hard disk, at least it worked for my brother's hard disk!
Linux Mint Debian Edition MATE DE 64-bit
Gigabyte G41M-ES2L--->2gb ram
Intel Pentium Dual Core 2.60ghz-->E5300
WD-6400AAKS-Caviar-SE16-640gb
Proud user of LMDE
User avatar
heavy metal
Level 2
Level 2
 
Posts: 90
Joined: Mon Jan 25, 2010 11:00 pm
Location: Puerto Rico

Re: How to remove Bad Sectors from HD

Postby woodsman on Mon Jun 02, 2014 7:10 pm

Can you clone the drive to free up that drive?

Theoretically you then can perform a full write and read to require the firmware to mark the bad blocks. Something like this:

dd if=/dev/zero of=/dev/sdX
dd if=/dev/sdX of=/dev/null

Some might argue that only the latter command is needed to have the firmware mark bad blocks. In that case you do not need to clone the drive or even backup. You do need to boot with a live disk, however, in order to have the drive not in use anywhere.

Of course, performing the first command will destroy all data, which is why I asked whether you can clone the drive. Please do not execute that first command on any drive that you still need the data. :)

There is a how-to often cited but following the instructions is a challenge for many people because of the expertise required:

http://smartmontools.sourceforge.net/badblockhowto.html

That all said, I have had drives that once they started developing bad blocks never could be repaired. Bad blocks kept returning. Sometimes best to replace the drive and then use the suspect drive for spare projects where data retention is not mission critical.

I use smartd to monitor my drives in all systems and have the configuration files set to send me emails of any errors.
woodsman
Level 4
Level 4
 
Posts: 205
Joined: Tue May 11, 2010 10:22 pm

Re: How to remove Bad Sectors from HD

Postby coffee412 on Sat Jun 07, 2014 9:17 am

There is good advice in the replies about hard drives and bad sectors. What I would like to do is go thru a typical repair problem with the OP question.

-= BAD SECTORS =-

Bad sectors on a hard drive are caused by different problems. Basically what happens is that the drive read/write heads are either damaged in some way or for some reason damage a sector(s) on the hard drive. Perhaps the read/write heads of the drive are just wearing out and not able to read some sectors correctly. Either way you are going to be ahead of the game by replacing the drive in question. You can never remove a bad sector. What you can do is have the sector marked out so that it is not used in the future. Most current drives firmware, when it detects a bad sector, will do this and has spare sectors available to remap the bad sector to a good sector. However, These are limited. Running smartcontrol and checking the readout from your drive is a good way of seeing if you have bad sectors and how many have been remapped. In my shop if I detect a bad sector I recommend a replacement drive as soon as possible. The reason for this is because even though the bad sector has been remapped you will eventually be finding more bad sectors as the drive is used more.

-= BACKING UP =-

Before you do anything with the drive you want to at the very least backup your data. This can be as simple as installing an other drive and making a copy of your home directory to the backup drive. In this senario you will be reinstalling your operating system on the new replacement drive and then moving your important documents over to the new drive from your backup drive. A better way to make a backup is to clone your bad drive (if you can) to the backup drive using DD. DD is a command line program that is very easy to work with but will take a while to perform the cloning. DD does a sector by sector copy of the drive including unused space. Therefore it is common for it to take a long time to perform this. However, Using DD will duplicate everything on the disk so that you only need to swap out the bad disk for the good cloned replacement. Keep in mind that should the bad sectors contain important files you might have to do some new repairs after replacement. Anyways, To perform a clone of a bad drive (we will call it /dev/sda) to a new drive (we will call /dev/sdb) you will need to boot from (in this case) your mint dvd and open up a term window , issue the following command as root:

Code: Select all
sudo DD if=/dev/sda of=/dev/sdb conv=sync,noerror


DD will perform a clone of the bad drive to the new drive and should it encounter bad sectors it will not error out.

You can also use clonezilla, A bootable cd. Be sure to go into expert mode and select skip bad sectors.

When complete replace your old drive with the new clone. Be sure to mark your bad drive with a black marker pen as bad. No sense in keeping it around either as some tend to do.

-= SOME OTHER THOUGHTS =-

Its very important that whenever you are going to work on a drive that you get a backup of some sort before you do. What normally happens when a drive is suspected of being bad is that in the testing phase you are stressing the drive and it could fail or develop other problems.

Its also important to understand that should you be in a situation where you are recovering files from a drive you should clone the drive or perhaps just the partition and work on that instead of the bad drive. The reason for this is that during a recovery a drive is stressed pretty hard and can fail during the recovery.

DD is always performed on unmounted drives.

I cannot stress enough that you backup. Even if your drives are good you should have some backup plan. If your just interested in backing up important files you can use a program like rsync and backup to a secondary drive in the computer. Operating systems can always be reinstalled but data is the important stuff.

On my surfing box I have a 1TB system drive and a spare 1TB that I use rsync to back up my home directory. Making a bash script to backup the home directory and creating a cron job to do this at 2am in the morning. Should I ever need to recover a file it becomes quite easy then. I also run a 3 disk raid5 setup on my backup server for all important files and image files. This is more advanced but provides an extra layer of safety.

One other point - Clonezilla is a fine program but I have ran into situations where the drive discriptions can get swapped around. Be very sure which drive is which!

In linux you would see this:
/dev/sda (bad drive)
/dev/sdb (replacement drive)

Booting from a clonezilla disk you might see this instead:
/dev/sda (GOOD DRIVE)
/dev/sdb (BAD DRIVE)

Therefore, Do not assume that the discription of your drives will be the same when booting from a clonezilla disk other wise you will have 2 blank disks!!


coffee :D
Fedora 20 / Linux Mint 17 / AMD phenom II X6 1090T / Raid5 / MythTV / No Gnomes here! - LXDE ----- http://youtu.be/HESL32TXNK0
User avatar
coffee412
Level 2
Level 2
 
Posts: 59
Joined: Mon Nov 12, 2012 7:38 pm
Location: Indiana, USA

Re: How to remove Bad Sectors from HD

Postby srs5694 on Sat Jun 07, 2014 10:13 am

heavy metal wrote:FYI, I have succeeded in removing bad sectors from my brother's 160GB Western Digital Hard Drive, I just used an Windows XP install cd I had around, just use the "Full Format" option, not the "Quick Format" option, the Windows Full Format option will check and try to repair any errors like bad sectors on your hard disk, at least it worked for my brother's hard disk!


Chances are you simply wrote data around the bad sectors, by reorganizing which sectors are used. The bad sectors are still there. The filesystem might map them out, but bad sectors often spread, so the problem is very likely to recur. There are analogous tools for some Linux filesystems, but they're basically historical relics, from the days before SMART hard disks. I wouldn't recommend using them.

It's also possible that you triggered the drive to automatically swap the bad sectors with spares, as coffee412 described. This would have happened sooner or later in any event -- but in my experience, if the disk was showing symptoms of having bad sectors, the odds of a rapid increase in problems are very high, even if the disk maps out the first of the bad sectors.

The most optimistic interpretation of what happened to you is that it wasn't bad sectors at all, but some sort of filesystem damage. In that case, a complete reformat of the disk would certainly fix the problem.

This is just entropy in action. Disks fall apart, just like everything else. Unfortunately, we lack the technology to do the microscopic repairs that would be necessary to save a disk once it starts to physically fail. Sector re-mapping and mapping bad sectors out of use by the filesystem are just ways to delay the inevitable. I agree with coffee412 and others who've said that you should replace a drive the moment you start seeing bad sectors. Trying to squeeze a little more life out of the disk is flirting with disaster.
srs5694
Level 6
Level 6
 
Posts: 1020
Joined: Mon Feb 27, 2012 1:42 pm

Re: How to remove Bad Sectors from HD

Postby coffee412 on Sat Jun 07, 2014 11:07 am

It just doesnt make any sense to map out a bad sector and proclaim "My hard drive is fixed!". Its still broke and its going to eventually get worse. So then, Your going to have more issues and have to fix them again (rinse / repeat...).

Just replace the failing drive.

Besides, How valuable is your data?

coffee
Fedora 20 / Linux Mint 17 / AMD phenom II X6 1090T / Raid5 / MythTV / No Gnomes here! - LXDE ----- http://youtu.be/HESL32TXNK0
User avatar
coffee412
Level 2
Level 2
 
Posts: 59
Joined: Mon Nov 12, 2012 7:38 pm
Location: Indiana, USA

Re: How to remove Bad Sectors from HD

Postby Edward M. Grant on Sat Jun 07, 2014 11:09 pm

coffee412 wrote:It just doesnt make any sense to map out a bad sector and proclaim "My hard drive is fixed!". Its still broke and its going to eventually get worse. So then, Your going to have more issues and have to fix them again (rinse / repeat...).


That depends. My CentOS telecommuting machine reported 1 bad block on its boot disk soon after I installed the OS in 2008 and is still reporting 1 bad block today. My old Toshiba laptop started reporting bad blocks one day, and was increasing the number of bad blocks by about a hundred a day by the time I replaced the drive.

So I wouldn't worry much about a single bad block, but if the number keeps increasing, it's time to replace the disk.
Edward M. Grant
Level 1
Level 1
 
Posts: 27
Joined: Sun Feb 16, 2014 7:03 pm
Location: Canada

Re: How to remove Bad Sectors from HD

Postby srs5694 on Sun Jun 08, 2014 6:48 pm

Modern disks use SMART, which is supposed to map out a small number of bad blocks. Thus, if a single bad block becomes visible to the OS, that means that the number of bad blocks on the disk is actually much higher than that -- enough to exceed the manufacturer-defined safety margin for the disk. It's like spotting a termite in your house -- the one you spotted is not the only one there!
srs5694
Level 6
Level 6
 
Posts: 1020
Joined: Mon Feb 27, 2012 1:42 pm

Re: How to remove Bad Sectors from HD

Postby administrollaattori on Sun Jul 06, 2014 3:35 am

1. backup your data and OS from the partition and re-format the partition via another partition or live-DVD/USB
Code: Select all
sudo mkfs.ext4 -c /dev/sdxy  ## where x=drive and y=partition
User avatar
administrollaattori
Level 6
Level 6
 
Posts: 1464
Joined: Tue Sep 03, 2013 4:51 am

Re: How to remove Bad Sectors from HD

Postby PatH57 on Sun Jul 06, 2014 3:50 am

Hi,

agree with all of your comments, if the good drive tells you he is seek then he is...
That said play with it as a spare, will teach alot about how it works (time consuming but linux users like to know :D )
Get a USB to disk converter for a few $ and install or try to install different OSs (got winxp, win7 and win8 one one faulty) and when it goes belly up you didn't loose anything but you learned a lot.
Just for fun...
People disagree with me. I just ignore them.
(Linus Torvalds, regarding the use of C++ for the Linux kernel.)

Please Add [Solved] to the topic-title of your first post when appropriate so others know they might find a solution here.
User avatar
PatH57
Level 10
Level 10
 
Posts: 3446
Joined: Tue Mar 25, 2014 12:11 pm
Location: here and there

Linux Mint is funded by ads and donations.
 

Return to Non-technical Questions

Who is online

Users browsing this forum: No registered users and 0 guests