Have you ever booted or rebooted your computer only to find that you have bad sectors on your drive? What exactly are these bad sectors? Are they a sign your drive is going to bite the dust? Can bad sectors be repaired?

What Are Bad Sectors?

A sector is the smallest physical subdivision or the minimum storage unit of a hard disk drive (HDD), solid-state drive (SDD), USB drive, CD-ROM, or any other storage drive. Functionally, a sector is the smallest storage unit that can be independently addressed on your drive.

A bad sector, otherwise called a bad block, cannot be reliably read or written. It's a defective division of a drive's storage space. Bad sectors cannot respond to write or read requests.

There are two reasons why a sector becomes bad. The first is physical damage to a drive's recording medium, including magnetic discs, optical discs, and NAND flash memory cells. Bad sectors may result from manufacturing defects, magnetic wear, dust particles, worn-out flash memory cell of an SSD, or contact between the read/write heads and the platter. Hard bad sectors can't be repaired.

A Hard disk drive with its inner area exposed

The second type of bad sector is logical or soft bad sectors, where the storage cluster isn't functioning properly. Here, your operating system (OS) attempts to read the data on a drive sector and discovers that the contents of the affected sector are inaccessible and the error-correcting code (ECC) isn't working. This type of bad sector can be repaired.

How Do Sectors Get Marked as "Bad"?

3.5 inch and 2.5 inch harddrives

Many drives ship with bad sectors. But low-level formatting and consequent marking of bad sectors are done at the factory at the end of the production process, so you don't have to worry about it.

The manufacturer stores the locations of these sectors in the first of two lists of bad sectors on the drive—the primary defect list (P-LIST). The hard drive electronics automatically ignore sectors on this P-list, so they do not slow down drive access.

However, the marking up of bad sectors doesn't stop at production. Data loss is quite common with hard drives; to prevent this, your hard drive controller routinely scans for issues while your drive is in use. Once bad sectors are discovered, the drive controller records it in the second list—the grown defect list (G-list).

windows detect hard disk problem error message
Image Credit: Microsoft

Drive controllers scan the data in bad sectors and recalculate the ECC of these sectors, comparing it to the previously recorded codes. If they are not the same, the disk controller will try to restore the data from the corrupted one. If the error is minimal and correctable, it will repair/correct the data using the Self-Monitoring, Analysis, and Reporting Technology (SMART) counter 195 (Hardware ECC Correction).

Meanwhile, if the disk controller cannot repair/correct the error, SMART counter 198 (Offline Uncorrectable Sector Count) and counter 197 (Current Pending Sector Count) are implemented until an attempt is made to write the sector. When you attempt to transfer data to the bad sector, the hard disk controller replaces the bad sector by allocating an empty and new sector from the spare pool. It then updates the defect flag to show that the bad sector has been reallocated and updates the G-list.

A final attempt is made to read the data in the original sector. If it fails, all the data is lost. For this reason, you should carry out an advanced recovery attempt before "writing" a suspected bad sector.

How to Scan a Disk for Bad Sectors

Exposed hard disk and its components

Every operating system has tools to scan a disk for bad sectors. Some even automatically invoke scans for bad sectors after detecting an improper shutdown.

If you want to scan for bad sectors manually, you can, depending on your computer's operating system.

Windows OS

Windows chkdsk is an inbuilt disk check tool for scanning your hard disk for bad sectors. It repairs the soft bad sectors so that the data on the sectors are readable again while marking the physical bad sectors as bad.

This tool is designed to run automatically whenever Windows detects a defect on your hard disk. You're also free to run this tool at any time manually. Here's a step-by-step guide on checking for bad sectors and marking them.

  1. In your Start menu search box, input cmd.
  2. Right-click on Command Prompt and select Run as Administrator.
  3. A popup command line window will display.
  4. Input chkdsk and press Enter to run chkdsk in read-only mode. This way, it will not fix any errors it finds.
    The third stage of a Chkdsk process
  5. Alternatively, input chkdsk (disk volume): /f to specify a parameter for chkdsk to fix, chkdsk /r to scan all parameters, and chkdsk /b to re-evaluate previously flagged bad sectors.
    Chkdsk /r and /b processes
  6. If you're not running chkdsk in read-only mode, you'll receive a prompt saying Chkdsk cannot run because another process is using the volume.
  7. Input Y to proceed.
  8. The check disk scan process will occur when you restart your device.
    Chkdsk after restarting
  9. After the check disk process is complete, the bad sectors on your hard drive will be marked as unreadable/unusable. Your operating system will subsequently skip them.

Another method for scanning bad sectors is to use the Windows in-built tool.

  1. Press Windows + E, then select This PC.
  2. Right-click the hard disk you want to scan for a bad sector and click Properties.
  3. Head to Tools > Error Checking > Check.
  4. Windows will then scan your hard drive, and when it's finished, your computer will show you a message indicating whether your drive has errors or not.
    Error checking Windows C
  5. You can select Scan Drive to repeat the scan or Repair Drive so your computer can attempt to fix the error.
  6. When the repair or scan is complete, select Show Details to see the issues detected and repaired.

Linux

Although you can use the Linux badblocks program as a standalone utility to search for bad blocks (sectors) on a disk partition, we recommend using e2fsck -c or the appropriate fsck variant for your file system. This allows you to check for bad sectors while enabling your drive's in-built correction mechanisms to work as they should.

Note that incorrect parameters can cause irreparable damage to your file system. The -c parameter performs a read-only test on the volume. To use a non-destructive read-write test, specify the -cc parameter instead.

A screenshot showing the e2fsck command prompt in the Linux Terminal

The entire bad blocks list is rebuilt when you use -c or -cc. If you wish to keep the existing entries and merely append new blocks to the list, add the -k (keep) option.

Meanwhile, if you suspect damage to the drive or the file system, add the -p (preen) option, which will attempt to repair any damage automatically. It will notify you if it cannot fix the errors it finds.

macOS

You can scan and repair your drive using the Mac Disk Utility First Aid. You may not be able to fix some bad sectors, but you can deallocate the bad sector's storage space so that new data doesn't get stored in it.

  1. Boot your device into macOS recovery by clicking Command + R on startup. Hold until a tab showing the Apple logo appears.
  2. Proceed to the macOS Utilities tab and click Disk Utility.
    Mac Disk Utility
  3. Then select Continue.
  4. Go to the Disk Utility sidebar and pick the relevant hard drive.
    Drive in disk utility
  5. Then click the First Aid tab.
    Mac Disk Utility First Aid
  6. Select Run to correct the hard drive. If it fails to correct, you'll likely have to clear your hard drive and reinstall macOS.

Third-Party Bad Sector Tools

Besides using an inbuilt OS tool, there are third-party tools you can use to scan and repair bad sectors on your drives. Some are free, like HDDScan utility, others are premium, and some have free and premium options, like Active@ Hard Disk Monitor and Macrorit Disk Scanner.

Manufacturer Bad Sector Tools

Manufacturers of hard drives also have specific diagnostic tools for scanning their drives and instituting drive-specific control measures. An example is SeaTools by Seagate, which you can use to quickly check the health of your Seagate, Maxtor, LaCie, and Samsung drives.

How to Fix Bad Sectors

Open Black and Silver Hard Disk Drive with three work tools on it

As mentioned earlier, physical bad sectors are permanently damaged and can't be repaired. But logical bad sectors can be repaired on Windows and other operating systems.

Here are some methods for fixing soft bad sectors:

  1. Use of disk check tools. Examples include chkdsk for Windows, badblocks for Linux, etc.
  2. Recover the data on bad sectors using third-party software tools, like EaseUS Data Recovery Wizard and Disk Drill Data Recovery Software.
  3. Restore your computer to the previous functional state.
  4. Use of OS troubleshooting tools. An example is the Windows Troubleshooting Tool.
  5. Restore OS factory settings. Ensure you back up your data before exploring this option.

How to Prevent Bad Sectors

Preventing bad sectors in the first place is a much better approach to securing data than trying to repair bad ones. Here are some steps you can take to prevent bad sectors.

  • Handle your devices gently and ensure proper shutdown.
  • Avoid using your drives in extreme environmental conditions like high temperatures, excessive dust, ultra-high frequency sound, etc.
  • Avoid static electricity.
  • Ensure a supported or official nominal data cable and a power source are used for a stable power supply.
  • Use disk I/O software from credible manufacturers.

You Can Fix a Bad Sector With the Right Tools

Bad sectors are a never-ending menace plaguing hard disks. But you don't have to panic if you encounter one. Often, if they're the soft type, you can recover your data from the affected sector using recovery tools.

However, it's always best to back up important data to prevent the loss of sensitive data and important files, such as in hard bad sectors.