Have lsof installed before you install it and test it out.
This is /etc/init.d/my-readahead.
Code: Select all
#!/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
}
stop() {
eend 0
}
Code: Select all
#!/bin/bash
final_db="$1"
# 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
slot="$i"
cp "$final_db" "$final_db$i"
function collect_sample_old()
{
lsof |awk '{print $9}'|grep \.so|sort|uniq > $1
lsof |awk '{print $9}'|grep \.conf|sort|uniq >> $1
lsof |awk '{print $9}'|grep /bin/|sort|uniq >> $1
lsof |awk '{print $9}'|grep /sbin/|sort|uniq >> $1
lsof |awk '{print $9}'|grep ttf|sort|uniq >> $1
lsof |awk '{print $9}'|grep /libexec|sort|uniq >> $1
}
function collect_sample()
{
/usr/sbin/lsof -F n -f |grep "^n"|sed -e "s:^n::g" | grep -v "^$" | grep -v "^/dev"| grep -v "^/proc"| grep -v "^/tmp"| grep -v "^/var"| grep -v "/.mozilla"| grep "^/[a-z]" > $1
}
collect_sample /tmp/init_sample1
i=0
while [ "$i" -ne "$total_samples_per_boot" ] ; do
collect_sample /tmp/init_sample2
cat /tmp/init_sample1 /tmp/init_sample2 | /usr/bin/uniquer > /tmp/init_sample3
mv /tmp/init_sample3 /tmp/init_sample1
sleep 0.5
i=$((i+1))
done
cat /tmp/init_sample1 "$final_db$slot" | /usr/bin/uniquer > "$final_db"
rm -f /tmp/init_sample[123]
Code: Select all
#!/bin/sh
/usr/bin/awk '{
if ($0 in stored_lines)
x=1
else
print
stored_lines[$0]=1
}' $1
Code: Select all
chmod +x /usr/sbin/sample-init-process /usr/bin/uniquer /etc/init.d/my-readahead
rc-update add my-readahead default
touch /forcesampler
Once you boot after this the first time, you will probably see a slow down because its collecting samples for use on the next and subsequent boots. Use your system as you normally would. Open firefox, gaim, OO or whatever. Once the sampler script has finished ('ps -aef|grep -v grep|grep sample-init-process' will tell you if its running), reboot. Now this and all subsequent boots will be much faster. <update> Something has changed with baselayout recently and requires you to hit enter when the sampler starts during the once-only boot for sample collection. </update>
If it takes too long for the sample-init-process to finish, reduce the total_samples_per_boot variable in the sampler script to 100 and try again by touching /forcesampler.
In future, whenever you feel like updating the prefetch database, just 'touch /forcesampler' and database will be updated on next reboot.
Uninstall is easy:
Code: Select all
rc-update del my-readahead
\rm /etc/init.d/my-readahead
\rm /usr/sbin/sample-init-process
\rm /etc/conf.d/sofile-list.load*
\rm /usr/bin/uniquer





