5

In ext4 (or ext*, ntfs, fat) file system, if I overwrite a non-contiguous file will the same non-contiguous storage spaces be used or there's a different way to handle such?

2

It depends on what does the overwriting and how the filesystem implements writing in general.

For example, shred tries to overwrite a file in place in order to wipe it; but even if it succeeds there is no guarantee there won't be any old copies elsewhere. Another example for programs that usually write in place are databases.

Most other programs (such as office or text or image editors) have to rewrite the entire file anyway, instead of just changing a small part of the old one. They would usually delete/truncate the file first and create a new one in its place, very likely ending up in another location on disk. Sometimes they even create a new file (guaranteed to be in a new location as the old one is not removed yet), and only replace/rename the old one when that was successful.

If your goal is to get rid of sensitive data, you should probably overwrite all free space in the filesystem, or the entire filesystem device. You can't rely on filesystems doing what you want, nor on various programs to never have created another copy that is still left somewhere.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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