Secure free space erasure on Android

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.

1 Like
2 Likes
  1. Delete the file.
  2. Erase app/cache files for any programs that accessed or generated thumbnails or other caches related to it.
  3. Perform a few hard restarts to ensure TRIM is triggered and any system logs in memory relating to you clearing it are gone
  4. On most modern devices without cached content like thumbnails, such a file is likely permanently gone beyond recovery.
  5. Consider using the tool hbxc0re mentioned if the file’s name is extremely secret or crucial in terms of its security.
2 Likes

As we say in that article:

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.

5 Likes

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.

@hbxc0re Thank you for suggesting Extirpater. The description says

What is free space erasing?

  • 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.

3 Likes