Note: This solution only works with the cfq scheduler, as explained here. You should check which one is used by issuing
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
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.
-n level option is applicable for realtime and best-effort classes, with 0-7 as valid data (priority levels).