PDA

View Full Version : [SOLVED] How can I zero out unsued hardrive space?



cosmoshell
July 26th, 2012, 08:46 PM
I used to have a script that zeros out unused hardrive space by createing a large random file and was woundering how to do this? Im looking for how to do it by termnal. Does this method usely work with common laptop hardrives? Are there any likely problems from using it on a enrypted drive?

androssofer
July 26th, 2012, 09:03 PM
I used to have a script that zeros out unused hardrive space by createing a large random file and was woundering how to do this? Im looking for how to do it by termnal. Does this method usely work with common laptop hardrives? Are there any likely problems from using it on a enrypted drive?

the dd command can do this.. well it can make a large file of zeros.

here is an article about it:here (http://www.cyberciti.biz/faq/howto-create-lage-files-with-dd-command/)

cosmoshell
July 26th, 2012, 09:16 PM
the dd command can do this.. well it can make a large file of zeros.

here is an article about it:here (http://www.cyberciti.biz/faq/howto-create-lage-files-with-dd-command/)

how do i get it to on its own fill the entire thing withought specifing size parameters in? How do I get it to use 1s and 0s randomly?.

androssofer
July 26th, 2012, 09:21 PM
how do i get it to on its own fill the entire thing withought specifing size parameters in? How do I get it to use 1s and 0s randomly?.

you can use


/dev/random

to generate random stuff in the file. instead of /dev/zero as mentioned in the article...

not sure how you would get it to it automatically...

could perhaps get a script to access the amount of free space using


df -h

then get dd to create it that size...

Cheesemill
July 26th, 2012, 09:28 PM
How about running:

dd if=/dev/zero of=zero.file; sync; rm zero.filewhile inside the partition you wish to erase.

Is there any particular reason you want to use random data instead of zeros?
Random data will take much longer for absolutely no benefit.

cosmoshell
July 26th, 2012, 09:30 PM
How about running:

cat /dev/zero > zero.file; rm zero.file
while inside the partition you wish to erase.

Is there any particular reason you want to use random data instead of zeros?
Random data will take much longer for absolutely no benefit.

I was unaware, i thought it would have a benefit randomizing, agenst forensic tools.

androssofer
July 26th, 2012, 09:34 PM
How about running:

cat /dev/zero > zero.file; rm zero.file
while inside the partition you wish to erase.

Is there any particular reason you want to use random data instead of zeros?
Random data will take much longer for absolutely no benefit.

oo, so simple! I like!

could be something on the partition OP wants covered up? in which case random might do it better... i think?

Cheesemill
July 26th, 2012, 09:45 PM
could be something on the partition OP wants covered up? in which case random might do it better... i think?
Nope.

Just one pass of zeros will leave the data unrecoverable from the wiped section of the disk.
One thing to note is that it may not delete everything that you want it to, there can often be copies of deleted files hanging about in other locations (tmp files, cache files etc).

Cheesemill
July 26th, 2012, 09:48 PM
Just edited my original post to use dd instead of cat and add a sync command.

dd fails more gracefully than cat when the drive becomes full and the sync command makes sure that all the data is actually written to disk before the file is deleted.

asmoore82
July 26th, 2012, 11:04 PM
Nope.

Just one pass of zeros will leave the data unrecoverable from the wiped section of the disk.

Big +1

Bufeu
July 26th, 2012, 11:06 PM
Nope.

Just one pass of zeros will leave the data unrecoverable from the wiped section of the disk.
One thing to note is that it may not delete everything that you want it to, there can often be copies of deleted files hanging about in other locations (tmp files, cache files etc).
Yes, once overwritten, always overwritten. No one can't get data back which have been overwritten, that's impossible.

cosmoshell
July 27th, 2012, 01:08 AM
How about running:

dd if=/dev/zero of=zero.file; sync; rm zero.filewhile inside the partition you wish to erase.

Is there any particular reason you want to use random data instead of zeros?
Random data will take much longer for absolutely no benefit.

where does this save to? my computer is full and cant delete this.

cosmoshell
July 27th, 2012, 01:18 AM
where does this save to? my computer is full and cant delete this.

nevermind

Cheesemill
July 27th, 2012, 01:25 AM
where does this save to? my computer is full and cant delete this.
It creates a file called zero.file in whichever directory you were in when you ran the command.

androssofer
July 27th, 2012, 01:26 AM
where does this save to? my computer is full and cant delete this.

if you open a terminal and run this, it will proably save it to the folder you are currently in. Which is most likely /home/username

where username is the name of the user who ran the command.

so the file will be:


/home/username/zero.file

so this would delete it:


rm /home/username/zero.file

you could do:


locate zero.file

and it will show the location of the file.

if it gives you grief about not deleting it. use:


sudo rm -f zero.file

however USE EXTREME CAUTION WHEN RUNNING THAT COMMAND.

as it can mess things up if you type it wrong.. (toy story 2 was nearly lost forever due to a miss typing of that command. True story: source (http://www.youtube.com/watch?v=EL_g0tyaIeE&feature=player_embedded))

cosmoshell
July 27th, 2012, 04:09 AM
as it can mess things up if you type it wrong.. (toy story 2 was nearly lost forever due to a miss typing of that command. True story: source (http://www.youtube.com/watch?v=EL_g0tyaIeE&feature=player_embedded))

I remember that story.