How are deleted files replaced by new ones?

15 views
0

Say if the internal storage of your phone were to fill up and you deleted something like a video or game, what is it actually doing to the file in order to take it off the storage and how are new files able to just replace it?

In: 3

I’m not in IT but I think when you delete a file it’s just a logical deletion, ie the data remains on the drive but it is marked as overwritable. So when you write in a new file, it’s written on top of the old one, making it unreadable. On most storage hardware you can actually recover deleted data without much difficulty, unless it has been overwritten by new files many times.

Edit:to elaborate.
Writing data on a medium is essentially using a magnet to mark tiny north/south areas on it (0s and 1s… Bits) You delete it, the magnetic head comes back to the same area of the medium and changes the magnetised areas again, overwriting the old file with a new one.

There’s a record in the filesystem saying what files exist and what blocks on the storage system contain the pieces of the file. When you delete something it just clears that record and marks the blocks available for new use. This means that the data is still technically there and could be read if you could re-discover the blocks and put them in the right order.

“Secure delete” goes in and zeroes out the bits first, to make sure the data actually no longer exists.

When you delete a file, you are not really removing it. You are removing the directory that points to the file. So the information is there, but the phone has that storage space marked as available, so a new file can be written on the space where the old one is.

(That is why deleted files can sometimes be recovered)

In a computer there is no such thing as nothing. Everything is 1’s and 0’s. You might thing that “0” represents nothing, but in terms of the information it carries, “0” is the same as “1”, so the computer needs a way of knowing whether some 1s and 0s in some place means something or not. To do this, it basically has a directory of what spots on the disk should be treated as actually having information (e.g. files) and spaces that shouldn’t (e.g. “empty” space).

When you write something new, your computer will look for somewhere in that “empty” space to put it, changing the 1’s and 0’s in that space to make the 1’s and 0’s of whatever it is you’re writing, it will then flag that spot as being a spot that contains information.

When you delete something, you might it should just overwrite what’s there with 0s. But, again. 0’s can be information, too. Rather it simply changes the directory to treat that space as empty so it can be overwritten. But until it is actually overwritten, the original data remains there.

Imagine a whiteboard in a classroom. A section with a box drawn around it that’s labeled “Do not erase” is a file that’s saved on disk. Anything outside of that is fair game to be erased and re-drawn.

When you delete a file on a hard drive, all you’re doing is erasing the box and “Do not erase” label. The contents of the box remain on the board until someone comes along and writes over them with something new.

When you want to write something new on the whiteboard, you just need to find an area that’s big enough, draw your box and “Do not erase” label, and then the space is yours to do what you please with it.