[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16. The Post-Install Tune-up

Many Linux distributions install lots of stuff that many people never use. Often there are services or daemons set to run that aren't needed, and system configuration settings are conservative so as to run on the widest range of hardware. All these things can detract from your Linux desktops performance, and that's what this article is about; getting more performance from your box by performing a post-install tune-up. Here's what we'll be doing:

You don't need to do all these things by the way, only those that you need or want to, the rest are optional. Be aware that if your box is reasonably configured to begin with (and most distributions are, out of the box), you are unlikely to get a dramatic improvement from any one of these things.

However, by doing some or all of them you should end up with a system that boots more quickly, has more disk space and slightly more free memory, and a small but noticeable improvement in performance. The one thing you can do that will have a profound effect on performance is run lightweight, efficient software, so you should make that your first priority when building a fast Linux desktop.

16.1 Disclaimer  
16.2 Before You Start  
16.3 The Boot-Up  
16.4 How To Make The Changes  
16.5 Re-Claiming Hard Disk Space  
16.6 Hard Disk Tuning  
16.7 Filesystem  
16.8 Kernel Recompilation  
16.9 Miscellaneous Tips  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.1 Disclaimer

I don't guarantee the accuracy of anything that follows, so use this information at your own risk. In other words, if by following this guide you trash your computer, don't blame me.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.2 Before You Start

I'll assume you'll be running a SysV type system, as this is the most common and what you'll have if you are running a Red Hat-type distribution. SysV simply refers to the way services etc are started at boot time. If you are running some other system, you can still clean up the boot process; check your distribution's documentation for details. It's a good idea to browse through any documentation that came with your distribution anyway. This might be in the form of HTML files or a printed manual, and with many modern distributions is very comprehensive. The documentation should be able to provide you with details of any variations to the boot process used by your particular distribution, though I think the common distributions are pretty much all the same in this regard.

If this is a fresh installation, you should make sure all your hardware is properly configured first. Linux has really come a long way as far as hardware recognition goes, and chances are you won't have to do anything, though things like sound cards sometimes have to be setup manually. Once you are sure everything is going to work, you can continue with the tuning ....


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.3 The Boot-Up

We probably should start with a brief description of what actually happens when you boot your Linux box. You can skip this bit if you want to, but I think an understanding of what goes on at boot-up can often be helpful, so stick around ....

After the kernel is kicked into life by GRUB or LILO or whatever, the following steps occur (with possible minor variations):

  1. The kernel gets it's own internal systems set up.
  2. The init program is started.
  3. init reads the `/etc/inittab' file. This file provides init with the default run level for the system (eg console, graphical, single-user etc.) Take a look at `/etc/initab' yourself so you understand what the various run levels do.
  4. init then runs a script (usually `/etc/rc.d/rc.modules') to load auto loaded kernel modules.
  5. Depending on the default run level (from `/etc/inittab'), init then starts or stops all the services in that particular run level directory. For example, if runlevel 5 is the default according to `/etc/inittab', then all the scripts in `/etc/rc.d/rc5.d/' are run.
  6. init then runs another script (usually `/etc/rc.d/rc.local') . This is where the user can put stuff that he/she wants to be started automatically at boot-up. You might want to start your OSS sound driver from here for example. Users of older versions of Mandrake can edit this file to get rid of that damn ugly penguin ....

This is a bit over-simplified, but I hope you get the idea. If you take a look at the scripts in `/etc/rc.d/rc5.d' (or whatever your default runlevel is), you'll see that the names of the scripts all start with an S(for Start) or a K(for Kill or stop) followed by a number. The number determines the order in which the scripts are run. Most distributions start a diverse range of services or daemons at boot time, and while this automatically covers the needs of the majority of users, it also means that there will probably be several processes started that aren't required. This results in longer boot-up times, increased memory usage, and more potential security holes. Stripping un-needed stuff from the start-up scripts is easy; the hard part is determining what does what, and what you do and don't need. Hopefully the listing below will be of some help, it notes some of the most commonly found services and gives a brief description of what they do. And don't forget to make backups or notes of your changes, just in case you find you really did need to have that daemon started after all .... (this list is courtesy of Stan and Peter Klimas' Linux Newbie Administrators Guide)

anacron
checks cron jobs that were left out due to down time and executes them. Useful if you have cron jobs scheduled but don't run your machine all the time--anacron will detect that during bootup.
amd
automount daemon (automatically mounts removable media).
apmd
Advanced Power Management BIOS daemon. For use on machines, especially laptops, thatsupport apm.
arpwatch
keeps watch for ethernet/ip address pairings.
atd
runs jobs queued by the "at" command.
autofs
control the operation of automount daemons (competition to amd).
bootparamd
server process that provides information to diskless clients necessary for booting.
crond
automatic task scheduler. Manages the execution of tasks that are executed at regular but infrequent intervals, such as rotating log files, cleaning up /tmp directories, etc.
cupsd
the Common UNIX Printing System (CUPS) daemon. CUPS is an advanced printer spooling system which allows setting of printer options and automatic availability of a printer configured on one server in the whole network. The default printing system of Linux Mandrake.
dhcpd
implements the Dynamic Host Configuration Protocol (DHCP) and the Internet Bootstrap Protocol (BOOTP).
gated
routing daemon that handles multiple routing protocols and replaces routed and egpup.
gpm
useful mouse server for applications running on the Linux text console.
httpd
daemon for the Apache webserver.
inetd
listens for service requests on network connections, particularly dial-in services. This daemon can automatically load and unload other daemons (ftpd, telnetd, etc.), thereby economizing on system resources. Newer systems use xinetd instead.
isdn4linux
for users of ISDN cards.
kerneld
automatically loads and unloads kernel modules.
klogd
the daemon that intercepts and displays/logs the kernel messages depending on the priority level of the messages. The messages typically go to the appropriately named files in the directory /var/log/kernel.
kudzu
detects and configures new or changed hardware during boot.
keytable
loads selected keyboard map.
linuxconf
the linuxconf configuration tool. The automated part is run if you want linuxconf to perform various tasks at boottime to maintain the system configuration.
lpd
printing daemon.
mcserv
server program for the Midnight Commander networking file system. It provides access to the host file system to clients running the Midnight file system (currently, only the Midnight Commander file manager). If the program is run as root the program will try to get a reserved port otherwise it will use 9876 as the port. If the system has a portmapper running, then the port will be registered with the portmapper and thus clients will automatically connect to the right port. If the system does not have a portmapper, then a port should be manually specified with the -p option (see below).
named
the Internet Domain Name Server (DNS) daemon.
netfs
network filesystem mounter. Used for mounting nfs, smb and ncp shares on boot.
network
activates all network interfaces at boot time by calling scripts in `/etc/sysconfig/network-scripts'.
nfsd
used for exporting nfs shares when requested by remote systems.
nfslock
starts and stops nfs file locking service.
numlock
locks numlock key at init runlevel change.
pcmcia
generic services for pcmcia cards in laptops.
portmap
needed for Remote Procedure Calls. Most likely, you need it for running network.
postfix
mail transport agent which is a replacement for sendmail. Now the default on desktop installations of Mandrake (RedHat uses sendmail instead).
random
saves and restores the "entropy" pool for higher quality random number generation.
routed
daemon that manages routing tables.
rstatd
kernel statistics server.
rusersd, rwalld
identification of users and "wall" messaging services for remote users.
rwhod
server which maintains the database used by the rwho(1) and ruptime(1) programs. Its operation depends on the ability to broadcast messages on a network.
sendmail
mail transfer agent. This is the agent that comes with Red Hat.
smbd
the SAMBA (or smb) daemon, a network connectivity services to MS Windows computers on your network (hard drive sharing, printers, etc).
squid
An http proxy with caching. Proxies relay requests from clients to the outside world, and return the results. You would use this particular proxy if you wanted to use your linux computer as a gateway to the Internet for other computer on your network. Another (and probably safer at home) way to do it, is to set up masquarading.
syslogd
manages system activity logging. The configuration file is `/etc/syslog.conf' .
smtpd
Simple Mail Transfer Protocol, designed for the exchange of electronic mail messages. Several daemons that support SMTP are available, including sendmail, smtpd, rsmtpd, qmail, zmail, etc.
usb
daemon for devices on Universal Serial Bus.
xfs
X font server.
xntpd
finds the server for a NIS domain and stores the information about it in a binding file.
ypbind
NIS binder. Needed if computer is part of Network Information Service domain.

Many users will find they have a lot of unnecessary stuff in their /etc/rc.d/rc*.d/ folders. If you aren't sure if you need something or not, just move it somewhere else temporarily (but don't delete it), re-boot and see how things go. If you find that you do need it, just move it back and re-boot.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.4 How To Make The Changes

I usually just fire up a file manager and make a new folder in /etc/rc.d called JunkFromRc5 or something similar. Then I just drag the unneeded scripts from /etc/rc.d/rc5.d/ into the new folder (obviously my default runlevel is 5, you might need to use something different..). Alternatively, you can use a graphical tool like tksysv, or perhaps your distribution has it's own tool. You might also want to edit `/etc/rc.d/rc/local'. Apart from user's entries, this often has a few lines that overwrite `/etc/issue' with some system specs (and/or that hideous penguin), and the contents of the `/etc/issue' file are displayed just before the login screen. Many people prefer to delete this bit and insert a line to display a fortune here instead, eg. /usr/games/fortune > /etc/issue. As usual, if you aren't sure what you are doing, make a backup copy of the file first.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.5 Re-Claiming Hard Disk Space

This bit is easy, if a little time consuming. I usually start by getting rid of unneeded software packages. Fire up your favorite package management tool (like kpackage) and spend some time browsing through the list of installed programs. Tools like kpackage are ideal for this kind of work as they can easily show you the size of each package, a summary (so you know what the package is for), and any related dependencies.

Do you really need six editors, four file managers, five shells, three ftp clients etc.? Don't be surprised to get rid of a hundred megs or more of stuff. Packages like the Tex related ones, Emacs/Xemacs, and various emulators are never used by many, yet they occupy lots of space. If you are doubtful about removing some packages, keep some notes so you can re install them later if you have to.

Many distributions also install lots of documentation (check out /usr/doc or /usr/share/doc ). You'll probably find that there are only a few files in there worth keeping, and remember most of this stuff is available on the Web anyway. The du tool is invaluable for finding disk hogs. Also look for core files left over from crashes; these are only really useful to debuggers and can be deleted.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.6 Hard Disk Tuning

I've seen a few articles claiming huge performance gains from using hdparm, a command line tool for setting (IDE) hard disk parameters. The claimed gains are sometimes in the order of several hundred percent. While I'm not doubting these figures, I have to wonder whether they just indicate that the disk was horribly mis-configured to start with. I've tried using hdparm on a few disks, and have found modest gains in performance. Keep in mind that disk performance is only one factor in overall system performance, and even a fairly big jump in disk performance might not make a perceptible difference to the overall speed of your system. If a disk was noticeably slow, I would certainly give hdparm a try, but otherwise I wouldn't worry about it too much. Some common distributions already set some of the optimizing parameters at boot time anyway, so as I said before, unless you think there is a problem, you could probably just leave well enough alone. If you do decide to give it a go, make sure you read (and understand) the man page (at a terminal emulator type man hdparm), and be aware that with some of the adjustments there is a small but real risk that things can go spectacularly wrong, ie. corruption of the file system. If you'd like to give hdparm a try, here's the basic usage:
hdparm [-flag] device

Running hdparm without any flags (or with the -v flag) will display the current settings. To see the current settings for my first hard disk (/dev/hda) for example, I would use: hdparm /dev/hda. To do a basic check of the speed of the first hard disk I would use: hdparm -Tt /dev/hda. Some more commonly used flags:

-c3
Enables IDE 32 bit I/O support
-a [sectcount]
Get/set sector count for read ahead
-m16
Sets multi-sector I/O (in this example 16 sectors, you may need to experiment to find the optimal number for your disk)
-u1
Unmasks interupts
-d1 -X34
Unable DMA mode2 transfers
-d1 -X66
Enable UltraDMA mode2 transfers
Read the man page for more options.

I guess the logical way to use hdparm would be to find out what your disk supports, then set hdparm accordingly. More commonly though, trial and error is used, changing one setting at a time and measuring the performance after each change. Don't use settings recommended by someone else ; while they may have worked perfectly on that persons disk, your disk might be completely different and the results may not be good. There are several tools available for testing disk performance, one of the better known ones is bonnie. And remember the changes will be lost when you re-boot, so if you want to make them permanent, you'll have to add them to a boot script like `/etc/rc.d/rc.local'.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.7 Filesystem

Linux updates a last access time attribute every time you open a file. If you are after all the speed you can get, and you are sure you don't need this feature, you can add noatime to the mount options listed in `/etc/fstab'. For example:
In the `/etc/fstab' file add the line /dev/hda5/ ext2 defaults,noatime 11 if you do not wish to update last access time on the files in /dev/hda5 partition.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.7.1 Alternative Filesystems

You might have tried (or read about) alternatives to the traditional ext2 file system, and at present the most common seem to be ReiserFS and Ext3. These have some advantages over ext2, including quicker performance, so if you are about to start a new Linux installation you should certainly consider using the Reiser file system. However, as with hdparm, unless you are doing something unusually disk intensive, the gains are likely to be minor, and if your current system is doing the job I'd stick with it.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.8 Kernel Recompilation

This is another one of those things that is often recommended in the Linux tune-up guides. While it may have been important years ago, it is probably of questionable value now that modular kernels are the norm. So unless you need to compile in some special feature, or you are using a pre-historic non-modular kernel (in which case you could probably benefit from updating your Linux installation), I wouldn't bother. Most recent distributions come with a variety of optimized kernels, and automatically install the one that best suits your system. Of course, you might want to recompile just for its sheer geek entertainment value, and I guess that's as good a reason as any.... I won't go into the details of kernel compilation here, check your distribution's documentation or the Kernel How-Tofor details.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.9 Miscellaneous Tips

This article has only covered the very basic stuff - if you are interested in reading some much more detailed info about configuring Linux read the Configuration How-To.
If you are serious about tuning your Linux box, you'll need some benchmarking tools. To get started, take a look at these two sites:
The Linux Benchmarking Project and bench.

Obviously you'll be aiming to conserve memory as much as possible. Use the free command from a terminal emulator to see memory usage details. Ideally, you'll be able to balance usage against available memory so that swap isn't used.

You can save some memory by using a plain background on your desktop, rather than an image file.

Other useful tools are ps -aux (shows details of running processes), and top (similar to ps but continually updates).

Help reduce the time it takes X to update the screen on low-end machines by not using a greater colour depth than necessary, eg. use 16bit instead of 32 bit. You can check X's performance with x11bench, which is often installed by default.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated on March, 5 2003 using texi2html
Hosted by www.Geocities.ws

1