51

I had a PC with two OSs installed, which hard drive I erased using Disks from UbuntuUSB. I chose quick erase. As I understand, it deleted partition table, but all files' ones and zeroes are still on the HDD. I then created new partition table, and installed Win10.

Question: would the HDD work (read/write) faster now, if I overwrote it with zeroes?
Or: is writing information onto zero-overwritten HDD faster than on a "dirty" HDD?

  • 1
    Probably worth mentioning ATA Secure erasure in this regard. This may not be of direct use t the OP, but may be useful to others. – StephenG Apr 15 '18 at 17:40
  • Are you asking about (magnetic) HDD, SSD, or both? The answer depends. – smci Apr 19 '18 at 0:59
  • It's worth mentioning that physically-addressed flash memory, as might be found in a microcontroller package, will be faster if cleared to default first, since you get this step out of the way up front. – MooseBoys Apr 19 '18 at 4:39
92

Hard drives do not store the literal zeroes and ones that I suspect that you think they do. Instead, they store the data in an encoded format that guarantees that there won't be too many zero bits or one bits next to each other. A long run of zeroes or ones could actually cause synchronization issues when trying to read the data because of minuscule variations in platter speed, vibrations, etc of the physical medium on which the data is encoded to, so it's limited to a certain tolerance.

In addition, hard drives always encode an entire sector (typically 512 bytes or 4096 bytes of data) at once, not just the bits that have changed (again, because it's encoded data). This ensures that the entire sector is correctly encoded every time. So, filling the drive with all zeroes has no practical benefit, although it doesn't harm anything either, other than the minor mechanical wear caused by doing so. You can choose to overwrite everything with zeroes if you want to, but it will have no performance benefit, and you'll simply waste your time waiting for all those zeroes to be written.

Solid state drives go through a similar process; they automatically erase the previous contents of a block before writing a new block of data, so writing all zeroes to a SSD would cause unnecessary wear on the device, as flash technology can only be erased a variable, but finite, number of times before failure. The wear introduced would only be something like 0.01% of the total duty cycles, but it's something that you would want to avoid doing on a regular basis.

  • 9
    can only be erased a certain number of times — Actually, the number is not that certain. Variability is quite large. – Ruslan Apr 15 '18 at 19:33
  • 19
    @Ruslan Poor word choice, I guess. It's not certain (only death and taxes seem certain), but it's definitely finite, and manufacturers only guarantee performance up to "duty cycles" number of times. – phyrfox Apr 15 '18 at 19:46
  • On an old SSD with internal compression but no TRIM support, writing zeros could let the flash remapping layer use less physical flash space for the logical array of data it exposes through the SATA interface... It's a stretch, and worse than a SATA secure erase, though. – Peter Cordes Apr 16 '18 at 1:14
  • 5
    Two issues with your answer; 1) Solid state drives go through a similar process. This is not correct. Hard drives do not go through a read/erase/write cycle the way SSDs do. They can overwrite sectors on-the-fly without having to erase them first. 2) A long run of 0s or 1s could actually cause sync issues when trying to read the data Also not correct. Hard drive sectors have a gap between sectors where they record the sector number, sync bits, and ECC data. The address and sync data keeps the heads from getting "lost" on the platter. A 4k sector is actually 4211 bytes long because of this. – Wes Sayeed Apr 16 '18 at 1:35
  • 2
    @WesSayeed "similar process" meaning that SSD also writes entire sectors at once. True, normal HDD doesn't erase first, but it's still a similar process; both write entire sectors at once. And yes, I'm aware of the inter-sector gap that contains ECC and whatnot, but they still use something like MMFM/GCR to make sure that the clock doesn't get desynchronized within the sector, which means they can't have too many zero bits in a row. – phyrfox Apr 16 '18 at 1:39
53

No, it will not be faster. Writing takes the same amount of time regardless of the data being overwritten.

  • 12
    That's true for a magnetic HD, but it's plausible that an SSD using internal compression and not supporting TRIM could be faster if overwritten with zeros. They'd take less real space on the flash storage, leaving the flash remapping layer more room to work with. So it would be a bit like TRIM / discard. – Peter Cordes Apr 16 '18 at 1:10
  • 2
    @PeterCordes - while true, what proportion of SSDs actually in use today don't support TRIM? I know that of the several types I've used from across multiple product generations and from a variety of manufacturers (from high end all the way down to unbranded/store branded), all of the ones I've encountered do. – Jules Apr 16 '18 at 9:09
  • 1
    @PeterCordes The question is about zeros being overwritten rather than used to overwrite. Internal compression seems to not have lift off since it can only be done at a sector granularity and it may have trouble keeping up with the throughput. Writing over zeros could be faster if the SSD had no provisioning space and the manufacturer mapped logical zeros into physical ones, so that a disk full of zeros is actually made of "empty" flash pages. – Margaret Bloom Apr 16 '18 at 9:10
  • @Jules: Some old SSDs didn't support TRIM, because TRIM was only added to the ATA standard after the first SSDs existed, and then it took time for controllers to start supporting it. I have one in an old laptop. (I think a firmware update for it is available which adds TRIM support). I'm not sure if any of those old SSDs without TRIM used internal compression as well. I should have said such SSDs are rare these days, but blanket statements like this answer always inspire me to look for counterexamples or special cases where they don't hold. – Peter Cordes Apr 16 '18 at 9:38
  • 3
    @Jules A large portion of SSDs do not support TRIM, mostly simpler flash like USB sticks or SD cards, or MMC. Pretty much anything which isn't ATA. – forest Apr 16 '18 at 9:52
10

This depends on:

  • Whether it's a mechanical HDD or an SSD.

For an SSD, as other answers note, you should not overwrite with zeroes (which would impose unnecessary wear on the Flash cells), but instead use either a Secure Erase or a full-disk TRIM. Some of the more recent versions of formatting utilities will do a TRIM automatically if they detect an SSD. The reason for this is that SSDs make a strong distinction between an "empty" sector and one "filled" with any data, including zeroes.

  • Whether there are unreadable sectors on the drive.

Many drives will develop a small number of "bad spots" if used hard for several years. Any that have already been encountered will show up in SMART data as "Pending Uncorrectable".

If there are no unreadable sectors, a mechanical HDD does not benefit from being overwritten, though it also does no harm aside from consuming a lot of time up-front.

If there are some unreadable sectors, attempts to read them will take a long time, and the drive will keep trying to recover the data in spare moments, which will affect performance. Overwriting them will prompt the HDD to discard the existing data, test whether the physical location can still be used for storage, and allocate a spare sector otherwise. This will also reset the "Pending Uncorrectable" counter.

TL;DR - Generally, don't do it.

  • 1
    Also worth noting that overwriting with zeroes is potentially the worst possibly thing to do to flash: the process of writing to a block of flash memory is to erase it (which sets the bits to 1) and then to write into the bits that need to be 0. I'm not certain, but I think that if a sector has all zeroes written to it, that will do more damage to the longevity of the device than writing a random pattern, which will do more damage than writing all 1s, because the erase operation afterwards will require less power if there are fewer 0s (? not sure about this) and therefore do less damage (??). – Jules Apr 16 '18 at 9:31
  • 1
    I think most modern SSDs have some mitigation for that effect, such as an inversion flag, an interference pattern or even a mild compression scheme. A drive which uses realtime encryption, for example, effectively has an interference pattern since zeroes are transformed into pseudo-random hash. I've still got one of the old SandForce-based drives which uses compression and de-duplication instead. But you're correct that simpler Flash devices (thumb-drives and SD cards) will potentially be worn out faster by zeroes than actual data. – Chromatix Apr 16 '18 at 11:46
  • It's also useless to overwrite a flash drive that way due to overprovisioning space. – forest Apr 16 '18 at 12:00
  • one does not need to worry about using a SSD too much. german link: heise.de/-3755009 – user3549596 Apr 17 '18 at 8:49
5

No, overwriting with zeros will make no difference in speed for a hard drive. However, for a solid state drive, overwriting with zeros is worse than doing a trim operation, which marks the blocks as unused. TRIMing the partition or the whole drive for an SSD before installing the OS may result in performance and lifetime benefits for the SSD. If you've already installed the OS, there are techniques to trim the free space in the filesystem for a similar benefit.

2

When you are doing a "slow format", usually is performed also surface test for bad blocks on the drive, so it may be reasonable for older HDDs but you shouldn't notice any R/W performance difference.

0

There is no difference either for HDDs or for SDDs.

In the case of HDDs, the date on the drive is magnetically altered on each sector you write to so it's irrelevant what you write there.

Further, writing random data is better than writing zero's because it messes more with magnetic alignment traces and for advanced forensics it will be quite more difficult to determine what was there before in the case of random data overwrite vs. zero's overwrite.

In the case of SSDs, if you command a value to go to zero or one it makes no difference, it still takes the same time to write the memory blocks, but due to the TRIM optimizations you may find that you cannot overwrite the specific areas you desire. Instead, just make a self-expanding file that takes all the free space and that way it is guaranteed that everything will be written to, preventing any recovery.

0

No, there will not have any speed difference, but you have unnecessary weardown, and an unnecessary chance of failure.

Traditional harddisks encode data with a simple pseudorandom generator, more modern ones and (virtually) all SSDs encode data with AES, always. The reason for that is that storing random data (or random-looking data) is much more favorable towards wear-levelling, both on magnetic and solid state drives, but in particular in the case of the latter (thus AES is first and foremost used to scramble bits, but as a free bonus, you can have security at no extra cost).

Thus, writing out a lot of zeroes effectively writes out a lot of "kinda random bits".

That's that, and it isn't in any way faster to read (or overwrite) one or the other either.

On the other hand, overwriting the complete drive means writing some billion sectors. While harddrives have (purely fictional) failure rates that are so low that they seem like "never happens", given the huge sizes of modern disks "never happens" is much more like "is kinda likely to happen". It is for that reason that for example RAID-5 is no longer recommended because the likelihood for encountering an unrecoverable failure while trying to re-sync after a failed disk is so high that it might become a practical concern.

What does that mean? Well, it means nothing in general, but overwriting the complete disk without need is probably not a good idea. Even for a secure erase, if that's intended, there exist nowadays much better (faster and more reliable) methods.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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