How do hard disk erase data?As far as I know, the hard disk stores data like this:

The write head contains a coil of wire with a core of iron.When current passes through, depending on the direction of current a magnetic field is created in the coil.

The surface of the hard disk is made of a ferromagnetic material. The magnetic field created in the coil magnetizes the ferromagnetic material. This magnetization remains.

A magnetized ferromagnetic material can lose its magnetization only by increase of temperature(Curie temperature) or if we hit it hard.

I guess none of those procedures erase data from a hard disk.How is it done then?

  • 1
    \$\begingroup\$ Generally by just marking that part of the disc as something to be overwritten next time something needs to be written. \$\endgroup\$
    – Hearth
    Oct 5, 2019 at 10:49

2 Answers 2


You don't "erase" as much as "write over" the data on a hard disk.

Your write head "writes" spots on the platter such that some spots are magnetized as though the spot were a magnet with the "south" end up, and other spots were "north" end up.

To "erase," you write zeroes (or ones) to all the addressable spots on the platter. This doesn't actually set all the spots to the same direction. The data you write are encoded in various ways. All zeroes would probably result in a series of alternating "north up" and "south up" spots.

The whole thing is much more complicated than that, but is based on the ability of the write head to change the magnetic polarity of small spots on the platter.

The write head is an electromagnetic that can make very small (but strong) magnetic fields. Push current through one way and it forces a spot on the platter to magnetize "north up." Push current through the write head the other way and it forces a spot on the platter to magnetize "south up." Changing the eletrical polarity of the current through the write head changes the magnetic polarity of the written spot on the platter.

The Wikipedia page on the technology of hard disks explains it fairly well. That link goes right to the section on how magnetic recording is done on hard disk drives.

This image from the Wikipedia page shows how data is written:

enter image description here

Longitudal recording changes which direction is north or south (with or against the rotation direction.)

Perpendicular recording changes whether up or down is north or south - that's the one I used in the explanation above.

As Marcus Müller says, you really almost never erase data from a hard disk.

When you delete a file, all that happens is that the operating system writes a marker in the file system that says "this file no longer needed, its space can be used for something else." The operating system then ignores that file when showing you the list of files on your disk.

There are programs that look for such flagged files and allow you to recover them. If the space the file occupies hasn't been taken for a new file, then you can often recover a deleted file just by removing the "deleted" marker.

You can really delete files or the entire contents of disk, if you need to.

There are programs you can use that will overwrite all the storage space of a file with ones or zeroes, or random data, and then mark them as deleted. You can still "recover" the file, but the data is gone because you overwrote it with garbage.

SDelete from the Microsoft SysInternals is an example of a program that overwrites files to really remove the data.

There are programs that do the same thing to whole disks. They overwrite all data bits with ones or zeroes or random data. That takes a long time on a modern hard disk because they are so large.

Many flash based SSDs can do pretty much the same thing in an instant. They encrypt the data before writing it using an internal key. To delete, you just ask the disk to generate a new key. The old key is gone, the new key can't decrypt the old data - everything "deleted" in a flash. :)

  • \$\begingroup\$ If we really want to delete a file,we just overwrite the spots with random data.Correct? \$\endgroup\$ Oct 5, 2019 at 12:33
  • \$\begingroup\$ @BrightFuture: Yes. To really get rid of a file you must overwrite the data. \$\endgroup\$
    – JRE
    Oct 5, 2019 at 13:02

A hard drive never erases data. A hard drive doesn't care about what the data is.

The notion of "there's data there" (or "there's no data") comes from a file system driver, part of your operating system.

It interprets some structure (a file system table) stored on your hard drive. If that structure doesn't say "there's a file starting at hard drive position X, spanning through Y and Z", then there's no file there. To erase a file, you just remove the entry from that table and store the modified table to disk. Suddenly, what's in X, Y and Z doesn't mean anything to anyone anymore, and can (and will) be overwritten when the file system driver wants to write a new file, or enlarge an existing one.

Until overwriting happens: the data is still there, it's just not associated to anything anymore.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.