How can I avoid that cp freezes my OS?

3

I am using cp to copy data like so:

cp -r from_here to_there

When I do that, my computer freezes and unfreezes periodically. I have 4 CPUs installed and the HD is connected via SATA. from_here and to_there are both on the same file system so no network is used. The freezing is somehow dependent on the amount of files being copied. For a lot of files it is even impossible to sign in on the machine via ssh.

Is there a way to check why my OS freezes and unfreezes? Can I maybe tell cp to take it easy somehow?

Woltan

Posted 2011-07-26T12:40:47.037

Reputation: 33

You can use nice cp [arguments] (for CPU) or ionice cp [arguments] (for disk IO, on some systems), but that won't eliminate the root of your problems I guess (more info

– slhck – 2011-07-26T12:47:37.733

Is there a way to lower process priority (sorry, not a linux guy) – soandos – 2011-07-26T12:47:48.840

@slhck for ionice cp -r from_here to_there i get: none: prio 4 ionice: cannot parse number 'cp'. For nice cp -r 24 24m it simply starts copying and I do not get any feedback... – Woltan – 2011-07-26T12:57:26.153

try renicing the process once it's started. – Sirex – 2011-07-26T13:39:05.490

I just found out, that the process has a priority of 20. So it cannot get any lower than that. – Woltan – 2011-07-26T14:18:29.593

Answers

3

Depends on what version of kernel you are using. There was a bug in the kernel causing the machine to be unresponsive under I/O stress.

If you have a recent-enough kernel, just using ionice should be enough. I'm using ionice in conjunction with screen for background downloading and it works great (no impact on machine responsiveness).

screen -d -m ionice -c 3 io_heavy_cmd

Let_Me_Be

Posted 2011-07-26T12:40:47.037

Reputation: 1 364

I gave your recommendation a try and at first sight it seems to not block my computer anymore. I'll test this a little more until I accept the answer^^ – Woltan – 2011-07-27T06:48:02.027