What are the best ways to securely erase free space on Android without root privileges and keeping existing apps and data intact? Let’s assume a device containing a SSD not a HDD.
My search found these threads and an article about secure erasure of individual files or the entire device. I found nothing that describes securely erasing free space.
Securely shredding individual files is difficult if not impossible. Copies can exist in a variety of ways such as through manual, or automatic backups, wear leveling (on modern flash storage), caching and filesystem journaling.
Wear leveled devices do not guarantee a fixed relationship between logical blocks addressed through the interface. This means that the physical locations in which the data is stored may be different to where it is actually located, so shredding may not provide adequate security.
And as the tool on F-Droid linked above similarly says:
Due to how flash drives work and the partition layout of devices, it’ll never be possible to fully fill the drive.
You are best off ensuring that nobody can access your phone through a strong lock screen password.
To securely erase an entire Android device, you can simply wipe it.
For the people I’m helping, unfortunately ensuring unauthorized people cannot access their devices is impossible and refusing to unlock devices is a crime. Clearing entire devices is not an option because it will cause loss of Signal accounts and other non-portable data tied to those devices. This is why I asked the question.
Typically when you delete a file it is not really deleted, it is merely removed from the file system’s index.
A free space eraser tool such as this one fills the remaining space of your drive with random noise files and then deletes them.
This process makes deleted files for the most part irrecoverable.
What is file table filling?
On some file systems, deleted file names can still be accessible in backup index databases.
By creating many tens or hundreds of thousands of empty files with different random names you can push out the old files.
This process makes deleted file names for the most part irrecoverable.
It also says
Due to how flash drives work and the partition layout of devices, it’ll never be possible to fully fill the drive.
Warning! Excessive use WILL destroy your device!
I have known about these points. It may be good to check the SSD supports TRIM and trigger it, like @Lake suggested, then check (how?) the free space has actually been erased. But, particularly if I cannot check TRIM does the job, clearing the free space once using another method seems like a good idea. Is sfill (manpage) the best command-line tool for clearing free space on an SSD? There also is fstrim (manpage), though not sure if its name is related to TRIM or just a coincidence.
I think I’ll try one of the above tools, but I hope to hear from someone who has experience or further insight into doing what I’m setting out to do.