All computers eventual come to the end of their useful life. Whether absolutely, by becoming obsolete and incapable of running current software, or relatively, by becoming too slow for what we personally need them for.
In both cases, you will want to donate, sell or get rid of the computer. The main problem with this is that if you do not erase the data on the hard disk of the computer you are getting rid of, all your sensitive information will now be in the hands of a third party. This blog post will discuss how to securely delete files from your hard disks to make sure that nobody can retrieve the sensitive information they contain.
Why is deleting not enough?
Easy, I hear you say. I will just delete the files I want to get rid of and that’s the end of the story. Would that it were so, my friend, would that it were so. It is, unfortunately, decidedly NOT the end of the story.
You cannot securely delete files from your hard disks by simply pressing delete or using the equivalent command line command. Why not? Well, it has to do with the way computers are programmed to delete files.
I will try to explain this at a very high level of abstraction to avoid getting bogged down in details. I want you to visualize your hard disk as a book divided into pages. Whenever you write a file to your disk, the operating system looks for a number of pages that are sufficient to contain the contents of your file, and then writes the file to those pages. It then marks those pages as “in use”, so no other files can use them.
Writing to disk is an expensive operation in terms of time taken. So operating systems are designed to minimize the time spent doing this. One of the ways operating systems minimize this is how they handle file deletion. When you delete a file, the operating system determines which pages this file was using, and then simply changes their “in use” label to “not used”. This puts them into the pool of “not used” pages that other files can use.
That’s it. The operating system doesn’t actually remove the content from the pages that the file used to occupy. It simply marks those pages as “not used”. This makes deletion of files very fast, but it also means that the content of your file is still sitting there on the disk.
It will remain there on the disk until another file is written to the exact same pages. And until this happens, anyone with the right tools and knowledge can retrieve your file and see everything inside it. As you can see, simply deleting is not enough. So what can you do? I will discuss that in the remaining sections of this post.
How to securely delete files from magnetic hard disks
Magnetic hard drives, or mechanical hard drives, are on their way out. They are being replaced by fast and more energy efficient SSDs, but until they become completely phased out, they will remain part of the storage plan of many people. This section of the blog post discusses how you can securely delete files from these types of hard drives.
Fortunately, mechanical hard drives are easy to work with when you want to securely delete files. What you need is a software file shredder. Like it’s physical namesake, a software file shredder will permanently destroy the contents of a file. It does so by writing random values in the pages that were allocated to that file. Some software file shredders do this several times — that is, they write random values to the pages that belong to the file being shredded many times.
This ensures all traces of the data in that file are completely obliterated from the hard drive. Nobody can retrieve it now. Not even you, so only do this if you are absolutely sure you want to get rid of the file. For Linux and Windows, I recommend the open source BleachBit. If you have heard that name before, it is probably because Hilary Clinton used it to wipe her private email server. This post is not political in any way, everybody and their uncle is storing classified information incorrectly. I only mention this because it is a noteworthy use of the software.
On MacOS, you can use the terminal command
This will shred the file as above. A word for the wise though, this method DOES NOT work on SSDs, USB drives or memory cards. More about this in the next section.
How to securely delete files from SSDs
Short answer. You can’t. There is no way to securely delete files from SSDs. I always like to explain why something is so, so the rest of this section will contain the long answer to this question.
When SSDs first came out, they had a pretty short lifespan compared to mechanical drives — and they were extremely more expensive, but that is besides the point. The reason for this, the short lifespan, is that the way data is written to pages on SSDs results in degradation of the page it is written on. If a page is written to several times, it can quickly become unusable.
This problem has been eliminated in modern devices. To eliminate the problem, the developers of the devices use a concept called wear leveling. What this means, is that when you write to a page that has already been written to before, the hardware, not the operating system, simply marks that page as “not used” and writes the data to another block. The main difference between this and the previous section are the following two things
- This happens when you try to write to a page that has been written to before, not when you delete a page
- This happens completely in hardware, the operating system is completely unaware of this
By doing this, the hardware ensures that all pages are equally written to — and thus wear is leveled accros the entire device, hence the name “wear leveling”. In addition, some good quality devices also have extra space. So if you buy an X Terabytes device, it actually has X + Y Terabytes of storage. This additional Y portion is used when pages begin to fail. Again, all this is done in hardware and the operating system has no idea what is going on.
All this amounts to the fact that it is impossible to overwrite a certain page on an SSD. If you write software to target a certain page for overwriting, it will issue the correct system call to the operating system, and the operating system will issue the correct commands to the hardware. But the hardware will just mark that page as “not used” and write whatever you are trying to write to another page. You cannot wipe files on SSDs. There is no way to do it. This also applies to USB drives and memory cards, they all work using the same technology.
So how do I ensure the security of my files on SSDs?
The best way to secure the content of files on your SSDs, is to encrypt the drive from the get go. I wrote an entire blog post singing the praise of encryption. Seriously, I can’t say this often enough — encryption is your protection against prying eyes, use it! Like I mentioned in that post, you can use BitLocker in Windows and FileVault2 in MacOS to encrypt your entire drive. When you want to get rid of your drive, simply delete your encryption key. That’s it. The data on the drive will be gibberish to anyone trying to retrieve it.
Another, more physically exerting, but, some may argue, more satisfying technique is to equip yourself with the follow advanced cyber security tools
After collecting these high tech tools, I recommend you implement what I like to call The Office Space Photocopier Algorithm. Don’t forget to wear the goggles — safety first. That’s it ladies and gents. Secure your data. Stay safe.