What would cause cp to hang on one file?

Red Squirrel

No Lifer
May 24, 2003
69,852
13,421
126
www.anyf.ca
I'm using cp to just do a quick manual backup of a folder before making lot of changes, but it's stuck on one file, just sitting there. Been over 3 minues now. It's just code, so the file is like maybe a few kb. Even locally right on the file server (without NFS being in the picture) it's hanging. When I was doing it through NFS originally in the GUI it was estimating over 1 hour to copy 100MB worth of files.

This makes no sense. Why would it just randomly stop like that? The cpu and iowait is not even that high right now, the machine is basically idling.
 

Red Squirrel

No Lifer
May 24, 2003
69,852
13,421
126
www.anyf.ca
Wait, never mind just realized that I had accidentally put & at the end of the command so it was actually done just that I had to hit enter to get the prompt. Though I'm still wondering why it was so slow on NFS, it said it would take an hour to copy only 100MB of file. That should take under a minute at gig speeds.
 

R81Z3N1

Member
Jul 15, 2017
77
24
81
Sometimes small files over different file systems presents problems, the overhead of the file system is greater than the size of the file. From my understanding of NFS, it is not the most optimal file system.

I would do some tests, with say ext4, or xfs see if it is repeatable, also might be a lock on the file, or the file is in use some where might want to check that as well. Could also be a bad block, or if on SSD might be some overhead maybe the disk is rewriting the blocks, or is garbage collecting, as the size might be oddball and not fit the block size.
 

Red Squirrel

No Lifer
May 24, 2003
69,852
13,421
126
www.anyf.ca
Actually I wonder, does mdadm raid require any kind of "defrag" or similar operation once in a while? I know ext4 does not, but what about at the block level on the raid? I wonder if the raid is where the bottleneck is and certain parts are slower than others. In this case it's a raid 10.
 

edcoolio

Senior member
May 10, 2017
275
75
56
Actually I wonder, does mdadm raid require any kind of "defrag" or similar operation once in a while? I know ext4 does not, but what about at the block level on the raid? I wonder if the raid is where the bottleneck is and certain parts are slower than others. In this case it's a raid 10.

You should defragment it on occasion, assuming that the array consists of mechanical drives. A cron job while you are sleeping is ideal, once a month is fine.