Linux command to zero out deleted data from hard drive
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Linux command to zero out deleted data from hard drive
I am looking for the Linux command (or commands) that zeros any sectors on the hard drive that contain deleted data. Pretty much the same as what "secure delete" apps do for Windows, but without all of the hashing and rewriting. I am trying to make compression on my backup images of Vmware virtual machines more efficient and I read that an easy way to do that is to zero deleted sectors. Does anyone know how to do this?
First, "deleted data" and "deleted sectors" are not the same thing.
"Secure delete" I assume refers to erasing a file in such a way that it could never be recovered. To do this on an individual file presumably involves replacing the file data with random data and then all zeroes---just as is done when "wiping" a whole drive or partition.
This command will run until the hard drive is full, then it will bomb. When it bombs all you do is delete the file you just wrote, and you have accomplished what you set out to accomplish.
This command will run until the hard drive is full, then it will bomb. When it bombs all you do is delete the file you just wrote, and you have accomplished what you set out to accomplish.
That looks like a REALLY dangerous command. If it works the way you say, then the user might expect to zero out a file, and wind up zeroing much more.
I disagree.... Again, if it works as you describe, it does a lot more than just create a file.
The original question (I think) is how to do secure erase of one or more specific files. Your command goes way beyond that.
Have you actually tried it? Cna you post an example?
I do it periodically. Especially when I want to image and compress a partition.
It works exactly as I describe. It writes a zero filled file. Lacking any instructions on the size of the file, it writes until the partition is full. This has the effect of zero-filling all previously unused space on the partition. Then you delete the file, thus freeing all the space and leaving it zero filled.
And why, exactly, do you think it does anything other than that? Because it uses dd? dd writes with user permissions, just like every other command out there. If you try to write as root to /dev/sd-something, I am sure it would be totally destructive. Short of that, it works perfectly.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.