[CentOS] Silly question - Anything faster than rm?

William L. Maltby

CentOS4Bill at triad.rr.com
Mon Oct 1 02:48:07 UTC 2007


On Sat, 2007-09-29 at 14:19 -0700, Jamie Lists wrote:
> On 9/29/07, Luciano Rocha <strange at nsk.no-ip.org> wrote:
> > On Sat, Sep 29, 2007 at 04:43:43AM -0700, Jamie Lists wrote:
> > > Maybe this is a silly question, but i have a few million files i need
> > > to delete but i can't just reformat the volume.
> > >
> > ><snip>

> Thanks for the tip.. We just have millions and millions of files and
> it's taking FOREVER haha!
> 
> I thought maybe there might be some other command i'm not aware of
> that would wipe this stuff out faster ya know.

Unfortunately, it's not the command that is slow. A very large number of
"hosekeeping" functions related to file system must be performed if you
do this in place. Update free lists, used lists, etc. All involve
reading and/or rewriting disk stuff. And remember that the cache of this
stuff must be flushed periodically.

If it's ext3, mount as ext2 (someone else suggested it I think). You can
also use tune2fs's dir_index to see if that helps (although I doubt it).

I forget how to do it now, but you can also increase the flush intervals
to reduce the number of rewrites to the disk. I'm sure one of the folsk
more knowledgeable can provide the hint for this.

If you have space, the suggestion by another that you copy off and back
may be faster. If you have a list of all files/directories and a list of
ones to delete, you can use comm to get the list of those to be kept
(after sorting both lists) and feed this to cpio to archive the files to
keep. The unmount and remake you file system and restore from cpio.

Cpio can also be used to copy directly to another directory/file system.
This might be slower than the archiving process though, depending on
several things.

Some folks prefer tar over cpio, but the same concept can apply.

> 
> James
> <snip sig stuff>

HTH
--
Bill




More information about the CentOS mailing list