Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: How can I zero out unsued hardrive space?

  1. #1
    Join Date
    Apr 2006
    Location
    usa
    Beans
    377
    Distro
    Ubuntu Gnome 14.10 Utopic Unicorn

    How can I zero out unsued hardrive space?

    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?

  2. #2
    Join Date
    May 2007
    Location
    Northern Ireland
    Beans
    498
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How can I zero out unsued hardrive space?

    Quote Originally Posted by cosmoshell View Post
    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
    "Those who make peaceful protest impossible make violent revolution inevitable"

  3. #3
    Join Date
    Apr 2006
    Location
    usa
    Beans
    377
    Distro
    Ubuntu Gnome 14.10 Utopic Unicorn

    Re: How can I zero out unsued hardrive space?

    Quote Originally Posted by androssofer View Post
    the dd command can do this.. well it can make a large file of zeros.

    here is an article about it:here
    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?.

  4. #4
    Join Date
    May 2007
    Location
    Northern Ireland
    Beans
    498
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How can I zero out unsued hardrive space?

    Quote Originally Posted by cosmoshell View Post
    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

    Code:
    /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

    Code:
    df -h
    then get dd to create it that size...
    "Those who make peaceful protest impossible make violent revolution inevitable"

  5. #5
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: How can I zero out unsued hardrive space?

    How about running:
    Code:
    dd if=/dev/zero of=zero.file; sync; 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.
    Last edited by Cheesemill; July 26th, 2012 at 09:47 PM.
    Cheesemill

  6. #6
    Join Date
    Apr 2006
    Location
    usa
    Beans
    377
    Distro
    Ubuntu Gnome 14.10 Utopic Unicorn

    Re: How can I zero out unsued hardrive space?

    Quote Originally Posted by Cheesemill View Post
    How about running:
    Code:
    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.

  7. #7
    Join Date
    May 2007
    Location
    Northern Ireland
    Beans
    498
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How can I zero out unsued hardrive space?

    Quote Originally Posted by Cheesemill View Post
    How about running:
    Code:
    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?
    "Those who make peaceful protest impossible make violent revolution inevitable"

  8. #8
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: How can I zero out unsued hardrive space?

    Quote Originally Posted by androssofer View Post
    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

  9. #9
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: How can I zero out unsued hardrive space?

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

  10. #10
    Join Date
    Jul 2007
    Location
    Burlington, NC
    Beans
    1,995
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How can I zero out unsued hardrive space?

    Quote Originally Posted by Cheesemill View Post
    Nope.

    Just one pass of zeros will leave the data unrecoverable from the wiped section of the disk.
    Big +1
    Give me Free Software or Give me Death!

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •