# removing a directory 300g in size



## azathoth (Dec 2, 2017)

What is fastest way on FreeBSD?
`rm -rf`
`find dir -exec rm -rf {} \;`
or maybe `find dir -exec echo '' > {} \;`
?
I tried first 2 in order on zfs folder.....seemed kinda slow.


----------



## ralphbsz (Dec 2, 2017)

Assuming that the directory has a sane number of files in it (thousands or tens of thousands, not dozens of millions or billions), the cost of delete will be dominated by internal file system operations.  So the userspace stuff probably makes no difference, and I would use "rm -rf" for simplicity.

If the directory tree has many millions or billions of files ... then you need to seek professional help.  That's deliberately a double entendre: People who put that many files are either very stupid, very crazy, or very smart.  And optimizing file system operations at that scale is real work, nothing you do in a few minutes on a discussion forum.


----------



## forquare (Dec 2, 2017)

If the directory is the mountpoint for a ZFS dataset, I think the fastest way would be to destroy and recreate that dataset.


----------

