How to prevent bad sectors?

You can't prevent bad sectors.
If you reformat all you are doing is remapping around them, so they're no longer available for use.
They cannot be repaired & if they start to appear at an increasing rate, it's a good sign your drive is on its last legs, about to fail.
Backup & replace before that happens.. not after.


First, as always, I'll start by saying storage is unpredictable and you should always have a backup.

Now, "bad sectors" behave quite differently on HDDs and SSDs, and have different common causes (and a very long tail end of uncommon but possible causes, hence the unpredictability). But in both cases, the suggested procedure is to replace the drive ASAP and either restore from backup or go for data recovery.

You can get quantitative data on drive status and impending failure by gathering S.M.A.R.T. data from the drive, using a tool like smartmontools/smartctl on Linux or CrystalDiskInfo (or gsmartctl) on Windows.


Most commonly, a series of bad sectors on a HDD suggests physical damage to the platter. This is often apparent in S.M.A.R.T. data as the "reallocated sectors count" goes up (the drive starts using its spare sectors) and "pending sector count" is above 0 (there are no spare good sectors left [!!!]). These tend to "spread"/"grow", i.e. the physical damage gets worse the more the drive tries to read it.

This is why the usual advice for bad sectors on a HDD is to replace ASAP, and sometimes this gets to the point of "stop using the drive; the only thing you should do on it is run a recovery tool like ddrescue because at this point remaining drive lifetime can be just a few hours or less, in the worst case.


A SSD is a different story. Each cell has limited "write endurance", and each write damages it slightly (very, very slightly). These are often rated in "TBW" (total bytes written) and "DWPD" (full drive writes per day, for its warrantied period usually 3-5 years). A high-quality drive can even be expected to exceed its rated writes without obvious adverse effects. This is often represented in S.M.A.R.T. data as a "media wearout indicator" or similar, and like a HDD, a SSD usually has extra cells it can use to replace a cell that has worn out.

If you're seeing "bad sectors" on a SSD, and the number seems to be increasing, it's likely that you've hit the point where the wearout is above the spare cells the SSD had (more likely on older or cheaper SSDs). With modern SSDs with wear-leveling, this means all cells are likely in a similar state, and, much like bad sectors on a HDD, this problem will only grow. And, much like a HDD, it is time to replace the drive.

Depending on the SSD size and age, it may also be worthwhile investigating what may be causing a large number of writes on your system: it's rare for a SSD in consumer use to actually wear out these days.


tl;dr: Check S.M.A.R.T. data. Replace the drive. There is no recovery.


There are different kinds of bad sectors, and different causes. What you describe is of the "bad" kind.

While disks are expected to work mostly reliably, reality has it that bad sectors happen, especilly in adverse conditions, and towards the end of a device's lifetime. Drives will luckily, and unluckily, automatically remap bad sectors when they occur, you usually do not ever even notice unless you look at SMART info.

However, you did notice, which is bad. Because when a sector (or rather block, SSDs arrange sectors in larger blocks, and can physically only erase complete blocks) gets "bad", that normally means it cannot be erased and written to any more, but the data is still recoverable. The drive will covertly copy everything to a more healthy sector and will never tell you. SSDs do that all the time during normal operation anyway, this is called "wear levelling". So there is really no externally observable difference. But you did see a difference, and that's bad.
Either, this means the drive has already had so many failures that it has already run out of reserve sectors, or it cannot even read the sector any more, or the controller has a serious problem, or the whole thing is about to die. Or, whatever. In any case, no good.

Unrecoverable sectors are something that are generally considered to be "normal", although with a very, very low likelihood of occurring. Manufacturers say something like 1014 or 1015, but 1012 may be more realistic. Still...

Your mileage may vary, but I replace a disk when the first unrecoverable reads happen because on a healthy drive that kind of stuff just doesn't happen. Yeah, it's a "normal" thing, and it can (in theory) happen, but it doesn't happen. You can't trust a drive that has non-zero failures with your data.

You can somewhat mitigate that bad things will happen by having quality hardware and treating your hardware with respect. For the most part, that means no high temperatures, no electric "surprises" or other "harsh physical stuff". SSDs are much less sensible to "harsh physical stuff" than spinning disks, but they are not indestructible.

Fixing bad sectors (on any kind of disk) is an extremely stupid idea, only topped by overwriting a SSD with zeroes, which is even worse. Do not do that, ever.

What "fixing" bad sectors does is nothing but marking them as unreadable. The drive will remap the sector and thereafter never let you access that sector any more. That's as bad as it gets because often data can still be recovered when applying some patience. There are programs (like ddrescue) which copy partitions and re-read unreadable sectors a couple of hundred times in the hope that eventually a read succeeds. This takes forever but surprisingly it actually works! I've had to do it once a few years ago. However, after "fixing" bad sectors, you are out of luck. Your data is gone forever.
Zeroing a SSD will do two things. It will kill your data, and it will add one unnecessary complete erase-write cycle to every block. That's not what you want.

What you probably want to do is back up all data ASAP (if you haven't done that previously, which you should have done), then replace the drive.

Also, for the future you want to run an automated daily backup job. Yeah sure, only wusses do backups. But seriously, run an automated backup every evening, no exceptions. No, not once a week, every evening. If you have a weekly backup job because it's so annoying that it takes so long in the evening, you will have to rescue data (talking out of experience). Because when you back up weekly, it is guaranteed to happen that you get a failure 6 days after the last backup.

Before trashing the drive, be aware that your drive may not be guilty after all. I've had it happen some 7-8 years ago. The "expert" at the shop where I had my PC built talked me into buying a MSI board which was exactly as good as the ASUS board that I wanted (only, he probably had a better profit marge on that one).
So... stupid... fell for it, only to discover a week later that I got some corrupted files. Replaced disks, same problem. Eventually got a few bluescreens, ran memtest. Every now and then, once per hour or so, it would show a randomly occurring memory error. Had all RAM replaced, no avail. End of story: The mainboard wasn't compatible with the RAM.
Bottom line: It probably is the disk's fault, but not necessarily so.