LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 04-20-2009, 02:19 PM   #1
TurtleFur
LQ Newbie
 
Registered: Apr 2009
Posts: 1

Rep: Reputation: 0
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?
 
Old 04-20-2009, 02:28 PM   #2
kentyler
Member
 
Registered: Dec 2008
Location: Newark Ohio
Distribution: Fedora Core
Posts: 270

Rep: Reputation: 38
I think you meant this http://www.howtoforge.com/how-to-shr...isk-files-vmdk

I don't think it makes that much difference, correct me if I'm wrong.
 
Old 04-20-2009, 02:38 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I'm a little fuzzy on what you want to do.

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.
 
Old 04-20-2009, 03:56 PM   #4
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
If you just want to zero things out in order to aid compression, it is easy.

dd if=/dev/zero of=/my/output/file/on/the/partition/to/be/zeroed

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.
 
Old 04-20-2009, 06:25 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by jiml8 View Post
If you just want to zero things out in order to aid compression, it is easy.

dd if=/dev/zero of=/my/output/file/on/the/partition/to/be/zeroed

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.
 
Old 04-20-2009, 06:59 PM   #6
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
It is no more dangerous than any other command that creates a file on a filesystem.
 
Old 04-20-2009, 09:21 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by jiml8 View Post
It is no more dangerous than any other command that creates a file on a filesystem.
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?
 
Old 04-20-2009, 09:33 PM   #8
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by pixellany View Post
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.
 
Old 04-21-2009, 07:22 AM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Sorry---I was being dense.
Quote:
And why, exactly, do you think it does anything other than that? Because it uses dd?
Probably...
 
Old 04-21-2009, 07:46 AM   #10
kentyler
Member
 
Registered: Dec 2008
Location: Newark Ohio
Distribution: Fedora Core
Posts: 270

Rep: Reputation: 38
You could do cat /dev/zero > /filename till the hard drive fills also.
 
Old 04-21-2009, 07:49 AM   #11
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by kentyler View Post
You could do cat /dev/zero > /filename till the hard drive fills also.
That's exactly what jiml was talking about.....
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Reconfigure hard drive that already contains data garyg007 Slackware 5 12-06-2008 08:58 PM
Any linux command to initialize a hard drive just.srad Linux - General 4 10-07-2008 09:28 AM
Recover data which was deleted- Linux linuxguy08 Linux - Server 2 09-10-2008 07:37 PM
Linux/Hard Drive Data. rvijay Linux - Hardware 3 02-09-2005 08:38 AM
Getting Data off old hard drive artemis Linux - Hardware 6 11-02-2002 01:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration