Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### cat /usr/lib/pm-utils/power.d/readahead
- #!/bin/sh
- [ -x /sbin/blockdev ] || exit $NA
- # more readahead = (hopefully) less hard drive activity.
- # less readahead = less trashing the page cache.
- DRIVE_READAHEAD_AC=${DRIVE_READAHEAD_AC:-12288}
- DRIVE_READAHEAD_AC=${DRIVE_READAHEAD_AC:-12288}
- help() {
- cat <<EOF
- --------
- $0: Control drive readahead.
- This hook tries to trade off the number of times we spin up a drive
- to read for potentially wasted cache.
- Drive readahead parameters:
- DRIVE_READAHEAD_AC = Number of KB to speculatively read on AC.
- Defaults to 256 KB.
- DRIVE_READAHEAD_BAT = Number of KB to speculatively read on battery.
- Defaults to 3072 KB.
- EOF
- }
- readahead() {
- # the intent here is to iterate through all filesystems
- # mounted on a local block device. It Works For The Maintainer(tm).
- # More sophistication in figuring out what exactly is a local block device
- # would be welcome.
- for dev in $(awk '/^\/dev\// {print $1}'</etc/mtab); do
- printf "Setting readahead for %s to %d..." "$dev" "$1"
- /sbin/blockdev --setfra $1 "$dev" && echo Done. || echo Failed.
- done
- }
- case $1 in
- true) readahead "$DRIVE_READAHEAD_BAT" ;;
- false) readahead "$DRIVE_READAHEAD_AC" ;;
- help) help;;
- *) exit $NA ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement