Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a Cent OS server with a NAS storage.

I have heard "rm" command makes overall disk IO slow. So, I gave up doing rm -R. I will do rm one by one with a shell script. --EDIT--> rm and sleep 0.1 one by one slowly.

Before I delete files, I want to change owner with "chown -R" command.

I have about 20,000,000 files to "chown". They are 2 TeraB in total in NAS storage.

I hope "chmod -R" won't affect too much on overall disk IO performance.

How about it? And, how can I measure the performance?

share|improve this question
Where in the world did you hear that? And what makes you think that running multiple rm operations is better than running one big one? – terdon Sep 10 '13 at 4:09
I do rm and sleep 0.1 one by one with a script. Not for the better performance but for less burden in short time. – 19 Lee Sep 10 '13 at 4:50
Just for the sake of discussion, how do you get the one filename you want to remove each time through the loop? – Kent Sep 10 '13 at 4:58
[for i in "$1"/*;do] (…) – 19 Lee Sep 10 '13 at 5:10
You may wish to refer here for the correct way to throttle rm's disk usage. Also see here. Do note that those answers assume a local drive - and if you are running massive deletion operations, it would be better to run them directly on the NAS if possible. – Bob Sep 10 '13 at 14:22
up vote 5 down vote accepted

Doing rm one by one with a shell script will not be faster, it will do the exact same thing rm -r would do, just wasting more CPU time running in the shell rather than the fast C of rm. There is absolutely no sane reason to do a chown -R before you delete files, their owner won't matter after they are deleted. As for commands to measure how much I/O you are using, I would recommend iotop. It will show I/O usage broken down by process.

share|improve this answer
Thank you for the answer. I do rm and sleep 0.1 one by one with a script. And, chown -R prevents my rm script from deleting other files. – 19 Lee Sep 10 '13 at 4:47
CPU resource is enough. And, I'm worrying the disk IO performance for access of other files. – 19 Lee Sep 10 '13 at 4:54
chown the files recursively to a new owner prevents the script from deleting other files, how? You changed ownership on everything to a new owner, you now delete everything. How will there be other files that this protects since they all now belong to the chown -R owner? There is a circular tail chasing logic to the description I'm not following. – Fiasco Labs Sep 10 '13 at 5:36
Sorry for not enough information. I do chown -R NewUser immediately. And, I run the rm script as the NewUser a month later. I'm worrying any bugs of my rm script. And, I have 1 month buffer to rollback any misses after I did chown -R. All of these will be done programmatically either by a batch or by an api. I omitted this explanation because this is not main topic of the question. – 19 Lee Sep 10 '13 at 5:43

rm does not affect disk I/O any more than any other command that needs to write to your disk. The only time I can think of when this will be a problem is if the disk in question is a network mounted drive. Large I/O operations can then indeed affect the entire network but it should make no difference whatsoever if the command you run is rm or chmod or chown or mv or whatever.

If you are experiencing latency problems when running multiple I/O operations, you will experience the same problems with chown and rm. If you have not noticed any problems when doing this, then just ignore it and run rm -rf * normally, you don't need to test it. The only test you need is to do it and find out if you can see problems. If you don't then forget about it.

share|improve this answer
"rm -r and chown -r has no big differences" is just what I wanted to know even though this was a bad news for me if it's true. Thanks(+1). – 19 Lee Sep 10 '13 at 17:56

You can use any sort of disk monitors while "chown"ing your files, that's how you can measure your Disk I/O load.

share|improve this answer

There is absolutely no reason to chown the files.

As for the I/O, you can use the iotop utility,

In case if you don't have it installed, you can install it first using the command:

yum install iotop # or att-get instal iotop

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .