10

If I use some IO intensive application (like Virtualbox, Steam data verification or even dd) my system becomes almost unresponsive. Despite all being started with normal priority, they make the desktop very sluggish and delay a lot the startup of other applications.

I know I can use something like ionice to change the priority to idle for instance, but in the case of Virtualbox which spawns many processes it becomes difficult.

Can I give some type of hints to the system, so when launching some specific applications they are started with the least IO priority?

1
  • did you try my solution? Does it do the job?
    – sm4rk0
    Feb 23, 2013 at 12:21

2 Answers 2

8
+50

Note: This solution only works with the cfq scheduler, as explained here. You should check which one is used by issuing

cat /sys/block/sda/queue/scheduler

and change it if necessary.

If I understood correctly, you want some ionice setting to be applied every time you start a command. You can do it this way:

echo 'ionice -c 3 /usr/bin/VirtualBox "$@"' > VirtualBox
chmod a+x VirtualBox
sudo mv VirtualBox /usr/local/bin/

First command creates a file VirtualBox with the single-quoted text as its content. This should have the full path to the program, because if one only specify VirtualBox it can interpret it as the file we just created and create a "loop".

Second command makes it executable, and third moves this new file in a folder which is in front of the "system" bin folder /usr/bin, so our new file gets executed instead of the original. The "$@" part contains all the arguments the command was invoked with, so they get forwarded to the real VirtualBox command.

According to answer ("yes") to this Super User question Do children processes inherit ionice priorities from their parents? How do you check the IO priority of a running process?, it should be enough to ionice the parent process, like this:

ionice -c 3 VirtualBox

From ionice man page, following I/O scheduling class values are available:

  • 0 for none
  • 1 for realtime
  • 2 for best-effort
  • 3 for idle (used in example above)

A number or class name can be used.

Also, -n level option is applicable for realtime and best-effort classes, with 0-7 as valid data (priority levels).

10
  • 1
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Lucio
    Feb 22, 2013 at 0:39
  • @Lucio, thanks for a hint, but isn't "it should be enough to ionice the parent process" essential part?
    – sm4rk0
    Feb 22, 2013 at 0:43
  • 1
    Yes, your right. But, if you can, take a time and then add more information from your own experience about this procedure, creating a better answer :)
    – Lucio
    Feb 22, 2013 at 0:45
  • @Lucio, I hope it's good enough now. Thank you for insisting (:
    – sm4rk0
    Feb 22, 2013 at 1:17
  • 1
    FYI: ionice can working with cfq scheduler only! For more details: unix.stackexchange.com/questions/136226/…
    – andras.tim
    Oct 31, 2014 at 14:03
-1

You can use the 'renice' command to prioritise processes:

renice -<priority> <application's pid>

It could also be your drive is spinning down too much, so when you want to start application like Virtualbox it has to spin up before you can start working around (this can take a while).

3
  • Thanks for the tip, but i was looking for a way to make that automatically and system wide. For example: when launching Virtualbox, run it with the lowest IO priority possible...
    – Salem
    Feb 16, 2013 at 14:37
  • regular nice and renice don't prioritize IO separately. Feb 23, 2013 at 21:29
  • And this is nice, not ionice. The one is for CPU the other for IO.
    – Dagelf
    Sep 8, 2019 at 16:45

You must log in to answer this question.

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