Why does deleting things clear storage even though the pc only can’t find it?


Why does deleting things clear storage even though the pc only can’t find it?

In: Technology

Like, I heard that the pc doesn’t delete stuff, if you click on delete, but rather just doesn’t where it is. Why does it clear storage?

The PC “remembers” which parts of the hard drive are “empty” and can be used to store new information.

When you delete a file the file system marks that file for deletion and deletes any references to that files location on disk.

As far as the OS is concerned, this space is now clear and that’s reflected through the GUI. The files are still on the disk in the same place, the OS just sees that space as “Oh hey I can store stuff in those blocks of space now”.

The OS doesn’t read a disk and say “How many blocks read 0?”, but rather “How many blocks can I write to?”, a deleted file is marked as blocks the OS can write to.

To actually delete the data, you would have to overwrite the section of the harddrive.

Think of your harddrive like a whiteboard. You can write all over it and then decide to get rid of something. Deleting it would be like crossing out the bit you don’t want. The data is still there.

But then you have another idea, and you write it over the bit where you crossed something out. You’ve now replaced the information.

Deleting a file hides the file from you, however your computer can still find the data as it knows exactly where it is. But it marks the space as available. So when there is a need to find storage space on your hard drive, either because you want to store more data on it or just to tidy up the existing data to make it easier to access, the computer might pick the storage that contains the data for the deleted file. It is first at this point that the data will get deleted as it is overwritten with the new data.

This is sometimes different between operating systems. However, generally the deleted stuff is marked as “this stuff can be overwritten”. When the PC then calculates free storage, it counts both “unwritten” and “rewritable” stuff.

It’s like you run a big neighborhood and you have an address book with all the people who live there in it. One day one of your neighbors calls up and says “hey I’m moving. Take my name out your book.” So you do that. You don’t erase the address, just the name, and you don’t go to their house and clean it for them.

Then a few days later someone comes up to you and says “Hey I’m looking to move into a new place. Are there any open houses in your neighborhood?” And you look through your address book and sure enough, there’s a space without a name. You and your friend drive up to the house and all the neighbor’s old stuff is still there, so you clean it out and help your new friend move in. Then you put his name in the book at that address so you know where he lives.

There really isn’t such a thing as “empty space” on a drive. There is only “reserved by X files” or “free to use”. When your drive calculates the remaining free space, it’s simply telling you how much of the drive is unreserved by any particular files. When you delete something from the drive, you remove the drive’s pointer that says “file XYZ is here” and the allocated space that was reserved for that file is now free to be used by something else.

But were you to move the drive head and read the data on the drive at the physical location where that data was written before you’d still read it (that’s how drive recovery works in some aspects, it manually reads every sector of the drive and works backwards to recreate pointers to what was written there before).

When that data is marked as deleted, the storage locations are marked as available and can be overwritten by new data. The old data might still be there for a while, but there is no guarantee how long.

As others have pointed out, deleting just marks the area as writable, but doesn’t actually remove the data. The reason this is how it works in the first place is because removing the data takes time and generally isn’t needed. For people/organizations that have sensitive data, they will actually go back are write zeros over everything.

For SSDs, it’s actually important to not actually wipe that data because they have a finite number of writes before they become unusable.

Filesystems work like libraries.

When you want to find a book you look up the location in a catalog and then go get it.

Deleting just removes the entry from the catalog so you can’t find it. But the book is still on the shelf somewhere (until it has been replaced by another book).

This is why you can still recover deleted files…you just ignore the catalog and walk through the library and catalog everything yourself.

To truely delete something you must not only delete the catalog entry but you must also replace the book on the shelf by overwriting the old data with garbage.