Let's say that I have some files on a hard drive (the data for each file is represented by a different letter):



Now let's say that I delete file Z without securely wiping it. The file will still be on the hard drive until something overwrites it:



Now let's say that I decide to create a new file (b). This will take up some of the remaining space on the hard drive. My question is, does the hard drive or operating system take the deleted files into account when deciding where to put the data for the new files?


From a convenience perspective, it seems like it would be best for the hard drive/OS to intentionally avoid overwriting deleted files, like this:


By doing that, I would have a higher chance of recovering File Z if I later realized that I wanted it back.


From a security perspective, it seems like it would be best to do the opposite and instead prioritize overwriting old files, to help prevent deleted data from being recovered by a malicious third party. For example, like this:



My question is, are either of these things actually taken into account when writing new data? Or is the new write location essentially just random?

2 Answers 2


Yes, I take them into account.

On HDDs it's more like o be overwritten compared to being stored into free space, because the tendency is to put the data into the faster portion of the drive which is at the beginning of it.

For SSDs, in theory, the data should be allocated to the less used sectors, which means there's a higher chance data will land into the free space compared to reusable one.


A lot will depend on the storage medium.

For SSD's, the wear-levelling algorithm will try to use different blocks each time, so data remains for much longer than HDD's, which may be random or tend to start from the earliest "free" space.

Filesystems designed with security in mind don't tend to use deliberate overwriting using the next file to be written as their security mechanism. They typically use deliberate overwrites on release, or encrypted storage.

  • For SSDs, aren't blocks of data normally TRIMed on delete?
    – timuzhti
    Commented Sep 9, 2016 at 11:08
  • If trim is an option, sure, but quite often the block is just disassociated
    – Rory Alsop
    Commented Sep 9, 2016 at 14:56
  • We do not change English spellings to American spellings (or vice versa) in edits.
    – Rory Alsop
    Commented Jun 17, 2020 at 18:14
  • Is "levelling" English? en.wikipedia.org/wiki/Wear_leveling, and the ' seem possessive, not plural.
    – schroeder
    Commented Jun 17, 2020 at 18:17
  • yep - both are acceptable.
    – Rory Alsop
    Commented Jun 17, 2020 at 21:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .