1
\$\begingroup\$

A simple question, the answer to which is surprisingly difficult to find. Does the internal controller in a HDD have to erase a sector on the hard drive if it already contains information, before it can be overwritten? This is what has to happen in flash memory and this is performed by the Flash Translation Layer. That is, a page has to be erased before being written to. The reason one must to erase before programming flash is because you can only write 0s. So first the data is erased and a block is all set to 1s. Then 0s are written as necessary. Does the internal controller (or any layer of the software) of a HDD also have to do this? Or on a HDD can you write both 0s and 1s?

Also what is the mechanism for read and write operations? I know data is stored as varying magnetisations, however what technology does the read write head use to sense the magnetisation and how does it modify it? I haven't been able to find a comprehensive description.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ SSDs don't need to be erased before being written to. The FLASH chips inside do but the controller inside the SSD takes care of this for you where necessary. \$\endgroup\$
    – Finbarr
    Apr 9, 2018 at 15:56
  • \$\begingroup\$ You can't simply erase content on a storage drive. It would take a very long time to write zeros to storage device... Instead, whatever you got rid of stays there until it's able to be overwritten. \$\endgroup\$
    – user103380
    Apr 9, 2018 at 16:04
  • \$\begingroup\$ I know! I've changed the wording of the question to make that clear. I'm not asking about SSDs or flash memory at all though, but rather HDDs. \$\endgroup\$ Apr 9, 2018 at 16:04
  • 1
    \$\begingroup\$ What are you asking, exactly? Whether you as a user of a hard disk have to erase it before writing or whether the internal controller in the drive has to do something to the physical media on your behalf? \$\endgroup\$
    – Finbarr
    Apr 9, 2018 at 16:15
  • 1
    \$\begingroup\$ I am asking, does the internal controller in a HDD have to erase a sector on the hard drive if it already contains information, before it can be overwritten. This is what has to happen in flash memory and this is performed by the Flash Translation Layer. That is a page has to be erased before being written to. Does the internal controller (or any layer of the software) of a HDD also have to do this? \$\endgroup\$ Apr 9, 2018 at 16:35

4 Answers 4

2
\$\begingroup\$

A disk drive typically has a layer of material that can be magnetized in any direction. At any moment in time, a drive head can either be in "read" mode (record changes in the magnetic field that moves under it) or in "write" mode (force the magnetic field near the head into a particular orientation). To allow for "random" access, the surface of the drive contains a "start of sector header" pattern at the start of each sector, each followed by a sector number. These headers are written when the disk is low-level formatted and never again after that. Following each complete header will be a "start of sector" pattern which is immediately followed by a sector's worth of data.

To read a sector, the drive controller will move the head to the track containing the sector and then wait until it sees a start of sector header pattern, followed by the number of the sector to be read. Once it sees that, it will wait for the next "start of sector" pattern and then retrieve the data that follows it.

To write a sector, the drive controller will locate the sector header as described above, but as soon as it is observed the drive will switch the head to write mode and then, oblivious to what may be under the head at the time, write out a sector header followed by a sector's worth of data, and then switch back to read mode. If the drive has been properly formatted, the drive will switch out of write mode before it obliterates anything other than the sector it was trying to write. If the drive hasn't been properly formatted, all bets are off.

Modern hard drives add additional complications by having some track-identifying information recorded further below the surface of the disk than normal data, in a way that isn't disturbed by normal write operations, but which can be read--even while writing using a second coil on the same head assembly. The same principle applies, though--the disk contains markers which will never be overwritten during normal use, which tell the drive where to read or write sectors of data, but during the actual write operation the drive will be oblivious to anything that had been in the sector previously.

\$\endgroup\$
1
  • \$\begingroup\$ So the answer to the OP's question is: No special erase procedure is needed or performed because any data of a sector can simply be replaced in a single pass by real overwriting? \$\endgroup\$
    – JimmyB
    Apr 10, 2018 at 12:39
1
\$\begingroup\$

According to this Wikipedia article, there are multiple ways to erase data.

As I mentioned before, with HDD storage, there are ways to permanently get rid of content on the disk. However, physically changing attributes on an HDD is super efficient and it takes an incredibly long time to do.

There are three main ways you can permanently get rid of data:

  1. Perform a data wipe by writing "zeros" on your HDD with software. This very effective because you can reuse the drive if you want to. However, doing this can take a very long time... I'm talking about hours of writing zeros.
  2. There's a method called, "Degaussing", that is named after the magnetostatic property of... well, utilizing the magnetic field. This is not recommended if you want to reuse the storage device.
  3. Physically destroying it. Degaussing can also fall into this category. However, there are other means. You can burn it with fire, taking the actual disk itself and scratching it or shattering it, you have the freedom of destroying it. Again, this is not recommended if you want to reuse this storage drive.

These techniques may not be applied to flash memory like SSDs or USB drives. The reason behind this is because there are already built-in algorithms that don't allow intruders to access remnant data from deleted information.

But to answer your main question: No. You do not have to erase data before writing to an HDD. If you simply delete a picture or song from your hard drive, it will still technically be on your disk until you are able to physically overwrite the data on the hard drive.

However, with flash storage, you must erase content from the storage device before writing to it.

The magnetization reading of an HDD is performed by GMR (giant magnetoresistance) sensors (as @Sparky256 mentioned).

\$\endgroup\$
1
\$\begingroup\$

This link provides the details of current HDD read/write operations. A quote from the article:

Giant magnetoresistance (GMR) is a quantum mechanical magnetoresistance effect observed in multilayers composed of alternating ferromagnetic and non-magnetic conductive layers. The 2007 Nobel Prize in Physics was awarded to Albert Fert and Peter Grünberg for the discovery of GMR.

The effect is observed as a significant change in the electrical resistance depending on whether the magnetization of adjacent ferromagnetic layers are in a parallel or an antiparallel alignment. The overall resistance is relatively low for parallel alignment and relatively high for antiparallel alignment. The magnetization direction can be controlled, for example, by applying an external magnetic field. The effect is based on the dependence of electron scattering on the spin orientation.

The main application of GMR is magnetic field sensors, which are used to read data in hard disk drives, biosensors, microelectromechanical systems (MEMS) and other devices 1. GMR multilayer structures are also used in magnetoresistive random-access memory (MRAM) as cells that store one bit of information.

In literature, the term giant magnetoresistance is sometimes confused with colossal magnetoresistance of ferromagnetic and antiferromagnetic semiconductors, which is not related to the multilayer structure.

A quick summary would be that HDD drives can read or write arbitrary bits on the fly. Changes to files are updated in the FAT or NTFS table or whatever is used as a 'Table of Contents' for that drive. Mass erasure means just that. A single pass to erase just the sector/encryption headers or erase ALL bits in a single pass.

\$\endgroup\$
0
\$\begingroup\$

The reason flash must be erased before writing to it is because you cannot write arbitrary bit values to it; each cell has a fixed reset state that requires both time and energy to move the cell into, and then much less time and energy is used to move the appropriate cells into their set state.

With magnetic media there is essentially no difference in the amount of time or energy to move a domain into either state, therefore there is nothing to be gained by performing a mass erase (except when destruction of all data on the medium is requested).

\$\endgroup\$

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.