Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My understanding is that running rm on a file simply unlinks it, marking the space as free in the filesystem. It should then follow that deleting one file always takes roughly the same amount of time (i.e. delete speed is proportional to number of files, not size of files).

So why does deleting a 15 GB file take over a minute with a simple rm file.tar.gz?

share|improve this question
5  
What filesystem? –  Shane Madden Sep 7 '12 at 3:23
8  
On many file systems, each "block" of free space has to be "marked" free. Large files have more blocks. This is not true of all file systems though! –  Chris S Sep 7 '12 at 3:25
    
@ShaneMadden good question; ext4 right now, but I've noticed it on other ext#'s as well. –  Tom Marthenal Sep 7 '12 at 3:28
    
That's why every file should have it's own virtualized filesystem so the inodes can be blindly wiped super fast! <JEST> –  thinice Sep 7 '12 at 3:56
    
Which filesystem would perform better at this case? I am right now using a portable drive to move large VM disks from one machine to another and rm taking forever is driving me nuts. –  motobói May 6 at 2:30

1 Answer 1

up vote 34 down vote accepted

It takes a constant amount of time to unlink a single block, but files beyond the size of a single block consist of multiple blocks linked together, and the larger the file the larger the quantity of blocks that are linked.

share|improve this answer
11  
<BSD Zealot> mumble mumble UFS mumble mumble soft updates mumble mumble delete stuff faster mumble mumble pancakes! </BSD Zealot> –  voretaq7 Sep 7 '12 at 3:45
    
XFS deletes large files very rapidly, but large numbers of small files very slowly. –  Andrew Sep 7 '12 at 4:37
4  
One file will always just use one inode. It does use multiple data blocks. –  Simon Richter Sep 7 '12 at 7:58
1  
One block to rule them all, one block to find them, One block to bring them all and in the darkness bind them. –  Rqomey Sep 13 '12 at 20:02

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.