Re: deleting files with linux

From: Chris Lowth (please@no.spam)
Date: 04/22/03


From: Chris Lowth <please@no.spam>
Date: Tue, 22 Apr 2003 14:59:15 +0100

Whoever wrote:

> On Mon, 21 Apr 2003, G. Wolfe Woodbury wrote:
>
>> The "standard" Linux filesystem (ext2/ext3) remove files by removing the
>> pointer to the 'i-node' in the directory file. The i-node is then
>> released for re-use, and the disk blocks in use by the inode are added
>> back to the list of free blocks.

Not quite true .. "rm" decrements a "reference count" (the number of "links"
to the inode). The node and it's space are only freed when..

        - the reference count drops to zero (ie: no more links)
and - the file is closed by any processes that have openned it.
and - the file system "syncs" it's buffers

>> ls -l <filename> #to get the length of the file
>> dd if=/dev/zero of=<filename> count=<length> #to write zero's
>> dd if=/dev/urandom of=<filename> count=<length> #to write random data
>> bytes rm <filename>

Nope - wont work (well - may not work) because dd truncates and re-allocates
the file space, which can wind up moving it (or bits of it).

Keep it simple - use the "shred" utility which is specifically designed to
do what the OP is after (ie: "in-place" zapping of the file).

Chris

-- 
My real address is: chris at lowth dot sea oh em
-> OpenSource e-mail virus protection : http://protector.sourceforge.net
-> iptables configuration wizards : http://www.lowth.com/LinWiz


Relevant Pages

  • Re: filesystem benchmarking fun
    ... [seeky writes while creating kernel trees on ext3] ... I did some more work to split out the two cases (block device inode ... Chris> writeback and log flushing). ... Chris> Unpatched ext3 would break down into seeks after 8 kernel trees ...
    (Linux-Kernel)
  • Re: inode_unused list corruption in 2.4.26 - spin_lock problem?
    ... On Wed, 23 Jun 2004, Chris Caputo wrote: ... Please don't forget that the inode is still hashed and is not yet ... >> failing to see how iput() is safe as it stands right now. ... I have added your patch to my test setup in case it helps. ...
    (Linux-Kernel)
  • Re: cTioga - help with axes
    ... On Wednesday, December 15, 2010 05:31:04 pm Chris R. wrote: ... The next step would be to email the author, or maintainer, or whoever is ... developer, you could look at the code and try to figure it out yourself. ...
    (comp.lang.ruby)
  • Re: [PATCH 09/18] fs: rework icount to be a locked variable
    ... Chris? ... +void iref_locked(struct inode *inode) ... I'm a big fan of _GPL exports, but adding this for a trivial counter ...
    (Linux-Kernel)
  • c.s.a.beagleboard?
    ... In acknowledging the growth of related news traffic, ... propose that whoever does, ... comp.sys.acorn.beagleboard newsgroup. ... BW Chris F. ...
    (comp.sys.acorn.misc)