How are deleted files replaced by new ones?

183 views

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

8 Answers

Anonymous 0 Comments

Your computer’s storage is simply a vast sea of 1s and 0s that any program can use.

When one of them wants to create a file, it asks the operating system to allocate a portion of the hard disk to them. The OS then stores an entry saying “file A.txt is using bytes 1000 to 1500”. B.txt might be using bytes 2050 to 5000, and so on. New files simply find an unused range and “claim” it.

When a file is deleted, the operating system just has to delete the entry in its index that it made for that file. The bytes themselves are left untouched. In the future, any other file looking for space can claim that range for itself and overwrite the data that was previously there.

This is how file recovery software is able to work. After the file is “deleted”, the software can still read the bytes on the disk and, as long as no other file has been written to the same location, recreate the original one.

You are viewing 1 out of 8 answers, click here to view all answers.