Optimizing Gentoo (Part 2)

Note: If you get errors when saving, try erasing all the quotation marks and re-inserting them. WordPress likes to mess them up. One error was also fixed below and is noted by [Edit] and [/Edit].

After checking out the optimizations in my last Optimizing Gentoo article, you may want to try a few of these.

Boot Time Optimizations

These tricks will speed up boot time, some more than others. To start out, let’s mount all local devices simultaneously instead of in a sequence.

Look for this in /etc/init.d/localmount:

mount -at nocoda,nonfs,noproc,noncpfs,nosmbfs,noshm >/dev/null

[Edit]
It may also say something like this:

mount -at noproc,noshm,no${NET_FS_LIST// /,no} >/dev/null

Whatever it says, just make sure it says mount -aFt in the beginning and it should work.
[/Edit]

and change it to this:

mount -aFt nocoda,nonfs,noproc,noncpfs,nosmbfs,noshm >/dev/null

Not only can you mount drives simultaneously, you can even start services simultaneously.

In /etc/conf.d/rc, change this:

RC_PARALLEL_STARTUP=”no”

to:

RC_PARALLEL_STARTUP=”yes”

Now that all services will start simultaneously and all drives will mount simultaneously, we need to go even further by running modules-update and env-update only when needed.

/etc/init.d/bootmisc

Change:

if [ -x /sbin/env-update.sh ]
then

ebegin “Updating environment”
/sbin/env-update.sh >/dev/null
eend 0
fi

to:

if [ -x /sbin/env-update.sh ]
then
if [ /etc/env.d -nt /etc/profile.env ]
then
ebegin “Updating environment”
/sbin/env-update.sh >/dev/null
eend 0
else
einfo “Environment up-to-date”
fi
fi

/etc/init.d/modules

Change:

ebegin “Calculating module dependencies”
/sbin/modules-update &>/dev/null
eend $? “Failed to calculate dependencies”

to:

if [ /etc/modules.d -nt /etc/modules.conf ]
then
ebegin “Calculating module dependencies”
/sbin/modules-update &>/dev/null
eend $? “Failed to calculate dependencies”
else
einfo “Module dependencies are up-to-date”
fi

Using rc-update

Gentoo has an unique initialization (init) system, but they have simplified it for users greatly. A great use of the system for a laptop is to use a different and minimized runlevel when on batteries as opposed to being plugged into an outlet. Runlevels may be changed while the machine is running or specified at a boot screen. Another situation is for gaming. If you don’t have much RAM and have unnecessary processes running, then it will slow your computer down slightly.

One of the best resources that tells you how to use rc-update and runtimes is right in the Gentoo handbook, or more specifically here

If you haven’t read all the extra documentation, I suggest at least skimming it. More to come, as usual, as I find it.

4 Responses to “Optimizing Gentoo (Part 2)”

  1. je Says:

    NIce tips

  2. Alexander Davidsen Says:

    This was a really nice articel. Alot of usefull tips. Have you posted this in the gentoo forums, if not, do it :P

  3. Paul Pacheco Says:




    I have worked very hard on this area and your article has a number of problems and could go even further.

    here I keep track of all this type of things.

    In particular:

    1) mounting in parallel does not work if you have say /, /usr and /usr/local in different devices, you may end up mounting /usr/local before /usr, man mount has more details on this. So you should at least add a warning.

    2) RC_PARALLEL_STARTUP=”yes” is not very good: at any given point it is doing 2 tasks or 1 task and a busy loop, so it is not very parallel. I have written an appropiate patch that is trully parallel with no busy wait. You can find it here

    3) The env-update thing has been fixed some time ago. So your change does not do anything.

    4) Your modules-update patch has number of issues and is just broken. Check Here for a discution about them and the proper fix.

    5) If you applied my parallel patch, try to remove unneded stuff from boot runlevel, such as alsa.

    6) Remove consolefont, it is not needed on x86 systems.

    7) I have also written a patch to start xdm before other services. Just adding it to boot won’t do it. This is specially good after my parallel startup patch.

    8) You may want to make a chart out of your boot process to see what the bottleneck is. I made an ebuild for that. Check Here for some samples. This will conflict with the parallel startup patch. If you want both, just mail me.

    All of this has been discussed to death in Here. Search for the posts from “castorilo” (myself) in page 5 for nice instrucctions.

  4. Jesper Frickmann Says:

    That reduced my boot time from 1:14 to 1:10. Great Gentoo for “Ricers” ;-)

Leave a Reply