# secure file deletion for ext3

## Tonglebeak

I've been reading up on secure file deletion for windows, and that got me thinking about ext3. I googled it and found many posts that indicate ext3 doesn't really wipe data away either. I always thought that ext3 0s deleted files, thus making them unrecoverable, but apparently I'm wrong?

What's the best way to secure delete with ext3, and is it possible to secure delete that's already been normally deleted? I also saw something about using an encrypted file system works much better than secure deletion? Can someone fill me in on this, thanks.

----------

## schachti

To securely delete an existing file, you can use app-misc/wipe. However, there are some general issues with securely deleting stuff on journaled file system, see also http://wipe.sourceforge.net/.

To securely delete data from free disk space, use something like

```

dd if=/dev/zero of=/wipefile bs=4k; rm -f /wipefile

dd if=/dev/urandom of=/wipefile bs=4k; rm -f /wipefile

```

----------

## jcat

Another app I've used in the past is "shred".

Cheers,

jcat

----------

## Tonglebeak

Seems I should convert my journal into ordered mode rather than journaled mode. How do I do this conversion?

----------

## RoundsToZero

tune2fs

----------

## Tonglebeak

Took care of that.

Is that secure delete free space script posted earlier save to use?

----------

## schachti

 *Tonglebeak wrote:*   

> Is that secure delete free space script posted earlier save to use?

 

Do you mean the two lines of code that I've posted above? As a general hint: Never use any code that you find in a forum (or anywhere else) and that you do not understand - so I will try to explain:

```
dd if=/dev/zero of=/wipefile bs=4k; rm -f /wipefile

dd if=/dev/urandom of=/wipefile bs=4k; rm -f /wipefile
```

The first line copies (using dd) data from /dev/zero to the file /wipefile on your file system. /dev/zero gives only zeros, so we fill the whole free space on the file system with zeros (as we copy the zeros into a file, we only use free space and do not overwrite any existing file, and as we do not use the count option for dd, dd copies until some error occurs - this is the case when the file system does not contain any more free space, so we fill up the whole free space). The option bs=4k is only used for performance reasons and could be omitted. After dd stops (because the disk is full), we remove the newly generated file to get back the free space.

The next line of code exactly does the same - with the one and only difference that we do not copy zeros to the empty space, but random values that we read from /dev/urandom.

So look at the man page of dd, try to understand what happends there - then you can judge for yourself whether it's safe or not.

----------

