DEV Community

Cover image for Restoring Bad Sectors and Fixing HDD Errors
Michael Mirosnichenko
Michael Mirosnichenko

Posted on

Restoring Bad Sectors and Fixing HDD Errors

Read about the ways of fixing HDD errors, if it is possible to restore bad sectors and how you can do it. Let’s find out how to recover data from faulty hard disks. When bad sectors and other hard disk issues appear, it may result in losing all the information on the disk. In today’s article, we’ll tell you about the possible ways to fix such errors and recover data from faulty disks.

Taking into account the overwhelming popularity and significant numbers of information storage devices currently in use, the issue of why bad sectors appear and how hard disk (HDD) errors can be fixed becomes quite relevant. An important requirement for securing user data and preventing its unexpected loss is to keep the hard disk you are using in good working condition. When there are any problems with its structure, software or hardware elements, it’s better to take care of transferring user data to a properly working storage device or recovering the lost data if the bad sectors in your hard disk caused its breakdown. Below, we will try to consider the possible methods to solve the problems mentioned above.

Hard Disk (HDD) Design: a Brief Overview

Before we get down to describing solutions to the problems we have mentioned, it is worth focusing on the hard disk design peculiarities to fully understand the principles of its work, proper diagnostics and choice of troubleshooting solutions.

A hard disk is a mechanical mass-storage device having moving parts, and it makes it the most vulnerable element of a personal computer. The main components of a hard disk are the logic board, read/write heads, and hard aluminum or glass platters covered with a thin layer of ferromagnetic coating which is where all data is actually written to.

Depending on the stated memory size, hard disks may use one or several platters placed on a single axis. Due to high speed of rotation, the read/write heads hover over the platter surface when writing or reading information, which ensures longer lifetime for the hard disk as a system. When it’s over, they move to the landing zone where they are positioned safely enough not to damage the other parts.

The hard disk case is a hermetically sealed container, which keeps away any foreign elements or particles, and ensures the general protection of the device.

Principles of Storing Information on an HDD

Based on the information on hard disk design described in the previous part of this article, we know that all information is stored on hard platters inside the hermetically sealed disk case.

The process of writing and reading information suggests existence of certain rigidly structured disk space with certain elements that divide it into parts. That is why the inner organization of the disk platter surface has special marking, which makes it possible to write and store information on the device. According to that, the surface of the platters is divided into tracks, each of them being subdivided into sectors (the smallest area of the disk memory used to store information). The size of a sector as a minimal unit of measurement for data written to disk is 512 bytes. Yet depending on the selected file system applied when formatting the hard disk, sectors may be united into clusters which, in their turn, will be used as single memory chunks when writing and storing data. A cluster can consist of several physical sectors, and its total size depends on the total number of the sectors it has united, so a cluster can be as large as sixty-four kilobytes.

When writing data, the system detects the size of the file being written and places it to the required number of clusters. Clusters with the data written to them can be placed differently on the disk surface. Depending on the size of the source file, hard disk load and a number of other factors the clusters containing data of the same file can be placed either next to each other or be scattered all over the disk platter. In other words, the source file will be broken into separate parts and written to the disk in a pattern of fragments. In the end, it will make the read time longer as the magnetic head of the disk will have to find all fragments of a file when such file is addressed. If a sector gets damaged, a part or all the information might be lost as sectors are the main elements in charge of storing data.

What is a Bad Sector?

As we have described it in the previous part of the article, a design peculiarity of a hard disk drive is the presence of sectors (or clusters) for writing and storing various information. If, for various reasons, a sector becomes damaged, the information written there will probably be lost and recovering it might not be easy, depending on the degree and type of damage. That’s why damaged sectors are traditionally called bad sectors or bad blocks, and it is impossible to use them for storing data anymore.

Users cannot possibly detect bad sectors, as they don’t have any visual representation in the operating system. You will have to use specialized software to identify them.

Using a hard disk with bad sectors may have undesired consequences, as the information from such sectors cannot be read, and you can’t write any information there either. If the number of faulty sectors is very small and it doesn’t increase over time, such situation is rather acceptable and you may use this hard disk for a long time. Even new hard disks are shipped from manufacturers with a certain number of bad sectors. The system marks identified bad sectors and when writing data to disk ignores them and places them into the list of exclusions.

YouTube:

Possible Causes Why Bad Sectors Appear

The magnetic surface of the hard disk may get damaged (giving way to emergence of bad sectors) through a number of causes. However, their nature comes from either of the two factors: mechanic influence or software errors.

In case of mechanical influence, the most widespread issues are those provoked by an impact to the disk case, or the disk falling down from somewhere. Even if you are always careful and never dropped your disk, nobody can guarantee that it was not dropped before – for example, in a shop or warehouse.

The second prize goes to faulty production, breaches of technology or design mistakes. There is always a chance that a certain batch or a new model of hard disk can be affected by this factor, and it may result in bad sectors appearing here and there. If this process is not static and the number of bad sectors is growing, soon the disk may get so damaged that all of its information will be gone forever.

When special auxiliary utilities of the operating system address a sector, they may receive a message with an error in return, and it makes the system mark this sector as bad. Such type of causes is classified as a software error and may include the following kinds.

Often, the problem is caused by an error which appears after a power failure, and as a result, data is written only partially or with some errors. The next time the system addresses such sector, it will be inaccessible. No less frequent are the errors caused by failures of the operating system, specific apps or programs.

Damage to the file system or contents of the master boot record don’t let the operating system identify certain partitions, or their parameters may be identified incorrectly. Damaged signatures, distorted bootloader code, destroyed contents of the partition table and wrong identification of logical partition boundaries – all of these result in a disk becoming inaccessible.

Also, software errors may include accidental deletion of system files in charge of the hard disk operation, and deliberate damage to the data caused by malware or a virus. As a result, important boot information is lost, and the disk sectors receive a software error warning.

Preliminary Steps to Secure Your Data

Presence of BAD sectors in your hard disk can initiate many problems: the disk won’t boot, local partitions are damaged, the information is unreadable, firmware errors, increased hard disk wear, locked data access etc.

Also, the hard disk becomes very slow which results in its freezing (absence of response to any user actions) at some moments, especially when the operating system is initialized or started.

When you face such symptoms, you should take care about transferring your data to another storage device, creating a backup copy or using a remote cloud storage. Backups are an important step towards safety of your data and their protection against unexpected loss. If you back up your data regularly, you can be sure that your data can always be restored even if something happens to the main storage device. It’s because there is a minimal chance that the hard disk containing your data and the storage device containing a backup copy may get damaged at the same time.

The cloud storage option lets you access your data anywhere and from any device, which is very convenient if you use several devices all the time. However, you can use a cloud storage only if you are absolutely confident that the cloud storage is well-protected against hacking attacks and other ways that third parties may access it.

Ways of Fixing HDD Errors

There only two types of causes behind HDD errors. If bad sectors appeared on the disk after some mechanical influence (after an impact or after the hard disk surface was damaged), there is nothing you can do to have these sectors back to normal condition. Creating a hard disk is a complicated technological process, so manufacturers often add some reserve space. If the system detects a bad sector, it gets excluded from the table of “good” sectors and replaced with a properly working sector from the spare sector part. However, the number of spare sectors is limited. If there is a lot of new damaged sectors, the hard disk may not have enough spare sectors to replace them with.

In case of software errors, you can use some methods to correct bad sectors involving diagnostics, error fixing and restoring operability of such sectors.

Using the Standard CHKDSK Tool

The main tool in the Windows operating system that allows to repair the hard disk issues is the integrated utility CHKDSK.

However, it is meant to work on diagnostics and correcting errors on hard disks (HDD) primarily. If you are using solid-state drives (SSD) on your computer or laptop, you can learn more about diagnosing such storage devices from the video guide: SSD Diagnostics: Programs to find and fix SSD errors.

YouTube:

CHKDSK performs a detailed examination of the hard disk and check the detected errors. This application scans the hard disk, repairs logical sector errors, marks bad and damaged sectors that cannot be repaired, and moves data to safe and properly working sectors still available on the hard disk.

There are two ways to start CHKDSK. In the first case, you will have to use the Command Prompt utility started with administrator rights. Click on the Start button in the lower left corner of your desktop, on the Taskbar, and open the main Windows menu. Scroll down the list of available applications and click on Windows System. In the drop-down menu, find the line Command Prompt and right-click on it. From the list of possible actions in the More section, select Run as administrator.

In the window of the command prompt with administrator rights, type the command to start the CHKDSK app:

Chkdsk C: /f /r

In this example, we’ll be checking for errors the logical disk C: and repairing them.

This application lets you use many different flags meant to perform a corresponding task. However, only two of them are used to fix hard disk problems:

/f – using this flag tells the application to check the hard disk for errors and fix them;

/r – this flag is used with the flag /f and makes the application look for damaged sectors in the hard disk and restore their contents.

Image description
You can learn more about the methods for checking the hard disk for errors and possible ways of fixing them from the video guide on our YouTube channel: «How to check your hard disk for errors and fix them in Windows 10, 8, 7.»

YouTube:

In the second case, you can take action to find bad sectors and fix errors right from the Windows File Explorer. Open the File Explorer in any way you like, for example, by double-clicking This PC on the desktop. In the Devices and drives section right-click on the necessary disk. Select Properties from the context menu that appears.

Image description

Top comments (0)