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