1

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.

  • 1
    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. – Finbarr Apr 09 '18 at 15:56
  • 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. –  Apr 09 '18 at 16:04
  • 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. – genericpurpleturtle Apr 09 '18 at 16:04
  • KingDuken - so one can straight away overwrite data on a HDD without having to perform an erase first (unlike flash memory)? – genericpurpleturtle Apr 09 '18 at 16:06
  • Well let's say that you delete a picture from your HDD. The information stays there until you're able to overwrite with say, a different picture. Like I mentioned, writing 0's will take a very long time. This is why when you wipe your hard drive, it takes hours. There are tools like DBan that will mechanically delete everything. How the HDD overwrites information, I'm not entirely sure about. I do know, however, that Flash and SSD memory makes it hard to recover remnent data. [Here's a good Wikipedia page about how data is erased](https://en.wikipedia.org/wiki/Data_erasure). –  Apr 09 '18 at 16:15
  • 1
    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? – Finbarr Apr 09 '18 at 16:15
  • 1
    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? – genericpurpleturtle Apr 09 '18 at 16:35
  • I guess another way of phrasing it is as such. With flash memory the reason you have to erase before programming 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. On a HDD can you write both 0s and 1s? – genericpurpleturtle Apr 09 '18 at 16:42
  • Your last comments make your initial post much clearer. The sentence starting with "Do HDD like Flash memory..." was ambiguously formulated (as if you were confusing HDD with SSD or something). You should probably reformulate a bit and include your comments in the main post. – dim Apr 09 '18 at 20:06

4 Answers4

2

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.

supercat
  • 45,939
  • 2
  • 84
  • 143
  • 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? – JimmyB Apr 10 '18 at 12:39
1

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.

1

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).

0

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).

Ignacio Vazquez-Abrams
  • 48,282
  • 4
  • 73
  • 102