Skip to content

Instantly share code, notes, and snippets.

@wd5gnr
Created November 28, 2020 04:22
Show Gist options
  • Save wd5gnr/fb3316185191b456336c74cf3f1d5b9e to your computer and use it in GitHub Desktop.
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!
#!/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
@wd5gnr
Copy link
Author

wd5gnr commented Jun 1, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment