首先安装lsof:
[code:1]# emerge -av lsof[/code:1]
然后用文字编辑器创建以下三个文件:
/etc/init.d/my-readahead
[code:1]#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
depend() {
before logger
}
start() {
ebegin "Starting readahead ROYALE"
cat /etc/conf.d/* > /dev/null 2>&1 &
cat `cat /etc/conf.d/sofile-list.load` > /dev/null 2>&1 &
if [ -f /forcesampler ];then
/usr/sbin/sample-init-process /etc/conf.d/sofile-list.load &
rm -f /forcesampler
fi
eend 0
}
# total number of lists to keep in /etc/conf.d/
total_to_keep=4
# total number of samples to make in /forcesampler boot.
# It will take twice this amount of seconds to finish sampling.
total_samples_per_boot=200
# touch empty file if not there
[ ! -f "$final_db" ] && touch "$final_db"
let i=0
while [ "$i" -ne "$total_to_keep" ] ; do
if [ ! -f "$final_db$i" ] ; then
break;
else
j=$((i+1))
if [ "$j" = "$total_to_keep" ] ;then
j=0
fi
if [ -f "$final_db$j" -a "$final_db$i" -nt "$final_db$j" ];then
i=$((j))
break;
fi
fi
i=$((i+1))
done
if [ "$i" = "$total_to_keep" ] ;then
i=0
fi