Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In the sysinternals suite for windows there is this nifty sdelete tool for securely deleting individual files as well as overwriting unallocated disk space with randomness or zeroes ( the -c or -z option).

I know there is a similar function in OSX in the disk manager but I'd like to add this as a cron job in order to know that all my deleted files really are deleted. This is also a good way to optimize virtual machine disk usage.

Are there any command line based tool that is equivalent to sdelete on osx?

share|improve this question
add comment

4 Answers

up vote 2 down vote accepted

With a little more searching:

man diskutil -- Modify, verify and repair local disks

secureErase [freespace] level device
Securely erase a disk or freespace on a mounted volume.
Level should be one of the following
1 - Single pass randomly erase the disk.
2 - US DoD 7 pass secure erase.
3 - Gutmann algorithm 35 pass secure erase.  Ownership of the affected disk is required.
share|improve this answer
    
Same comment as above... –  8DH May 1 '11 at 19:21
    
I'll try that out. Thanks. –  8DH May 2 '11 at 10:45
add comment

shred (part of GNU coreutils) and wipe.

Quote from shred's manual; applies to all tools:

CAUTION: Note that shred relies on a very important assumption: that the file system overwrites data in place. This is the traditional way to do things, but many modern file system designs do not satisfy this assumption.


To wipe free space, fill the filesystem like this:

# repeat 3 times
for x in {1..3}; do
    dd if=/dev/urandom of=/tmp/foo bs=8M
    rm /tmp/foo
done
share|improve this answer
    
Thanks for the ponter but if I understand it right shred and wipe both erase existing files. The sdelete feature I'm looking for in an equivalent osx cmd line tool is to overwrite all unallocated space on disk with random bits. –  8DH Apr 27 '11 at 10:51
    
@8DH: In that case, just create a really big file containing random data. It's what sdelete does. –  grawity Apr 27 '11 at 10:52
    
@8DH: Unrelated tip: On Windows, you don't need sdelete; you can use `cipher /w:C:` to wipe free space. –  grawity Apr 27 '11 at 10:54
    
Nice. I'll try that. Thanks. –  8DH Apr 27 '11 at 10:57
add comment

If you have MacPorts installed you can compile bcwipe.

080938 port info bcwipe
bcwipe @1.7-7 (sysutils, security)
Variants:             universal

Description:          The BCWipe software is intended to give you a confidence
                      that your deleted files cannot be recovered by an intruder.
                      BCWipe repeatedly overwrites special patterns to the files
                      to be destroyed. BCWipe for UNIX offers two wiping schemas:
                      US DoD 5200.28-STD standard and Peter Gutmann's 35 pass
                      scheme.
Homepage:             http://www.jetico.com/

Platforms:            darwin
License:              unknown
Maintainers:          nomaintainer@macports.org
share|improve this answer
    
Very interesting. I'll try it out. Does it have the same limitations as described by @grawity? –  8DH May 1 '11 at 19:20
add comment

man srm srm - securely remove files or directories

http://xahlee.org/mswin/file_shredding.html

On the Mac, just use the menu “Finder▸Secure Empty Trash”.

The command line equivalent is “srm”. Like this: 「srm -r -s dir_path」. The “-r” means all content in the dir, including sub dir. The “-s” means just overwrite once.

share|improve this answer
    
Thanks, but does it also overwrite unallocated space? –  8DH May 1 '11 at 19:19
    
srm and BCWipe only do secure file deletion. diskutil has an option which will "overwrite unallocated space" just like Disk Utility and the "Erase Free Space" option. diskutil secureErase freespace 1 device Open terminal and type: man diskutil then scroll down to secureErase ( or do a find ) Read well. -Bill –  broomdodger May 2 '11 at 5:36
    
I'm sorry. Thanks for the help. –  8DH May 2 '11 at 10:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.