summaryrefslogtreecommitdiff
path: root/pm/power.d/readahead
blob: 5cae541ddc3c6ed3c6dfd3e74f6baa87c7c110d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

[ -x /sbin/blockdev ] || exit $NA
[ "$CHASSIS_TYPE" = "Portable" ] || exit $NA

# more readahead = (hopefully) less hard drive activity.
# less readahead = less trashing the page cache.

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
	/sbin/blockdev --setfra $1 "$dev"
    done
}

case $1 in
    true) readahead 3072 ;;
    false) readahead 256 ;;
    *) exit $NA ;;
esac

exit 0