Created
November 28, 2020 04:22
-
-
Save wd5gnr/fb3316185191b456336c74cf3f1d5b9e to your computer and use it in GitHub Desktop.
A script to move baloo to a cgroup where you can limit its disk usage!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#baloo-nice by Al Williams | |
RLIMIT=1048576 # bps limit (read) | |
WLIMIT=1048576 # bps limit (write) | |
DEVICES="8 252 253 259" | |
SEARCH=baloo | |
if [ ! -d /sys/fs/cgroup/blkio/baloo ] | |
then | |
mkdir /sys/fs/cgroup/blkio/baloo # assume you need to be root to do this | |
fi | |
for I in $DEVICES | |
do | |
echo "$I:0 $RLIMIT" >/sys/fs/cgroup/blkio/baloo/blkio.throttle.read_bps_device | |
echo "$I:0 $WLIMIT" >/sys/fs/cgroup/blkio/baloo/blkio.throttle.write_bps_device | |
done | |
for I in `pgrep $SEARCH` | |
do | |
echo $I >/sys/fs/cgroup/blkio/baloo/cgroup.procs | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can also limit memory... see https://gist.github.com/wd5gnr/9af32eff7fad5d4057b2698fb9606868