Tuning your system
Disabling system services
In a typical installation a lot of services are running to ensure maximum compatibility and usability experiences to the user. Since this is a good approach for most of people, sometimes, some services are not used at all while your system is up. Because of this, it is a good idea to disable these non used services. You can do this with several programs. In Red Hat based systems, you can use setup in console mode or serviceconf in a graphical session (showed below).
Some of the services you would like to disable are:
* Network Manager: chooses the best available connection (are you always connected and permanently moving?)
* bluetooth: if you usually don't work with bluetooth devices you can disable it.
* cron: disable it if you have not programmed tasks (maybe you would like to run these tasks for yourself instead of schedule them).
* cups: printer daemon (I have it disabled in my laptop since I don't print from it)
* iptables: the linux firewall. At your own risk.
* irda: Same as bluetooth for Infra Red communications
* irqbalance: disable if you are not working with an SMP system.
* nfs: you can disable it if you are not sharing your files through NFS.
* misc. servers (ssh, sftpd...): A lot of servers are launched by default. Do you really want your system becomes a server?
* vnc: Virtual Network Console. Disable if you don't need remote graphical access to your system.
In Red Hat systems, you can add and remove system services using the chkconfig command (for non graphical sessions) in this way:
chkconfig service on/off
Other systems have their own mechanisms for managing services. See your handbook.
Disabling X at booting.
You would like to disable X or not, depending of the type of user you are. I’m a fanatical of the command line, and I have disable X at boot time. When I start my system I log in a console do my work and shut it down. This can save a lot of RAM if you don’t mind to deal with bash (or the shell you use). If you want to disable X, go to the /etc/inittab file and change the line:
id:5:initdefault:
For this one:
id:3:initdefault:
The next time you boot your system, you will be in pure command line. This not only saves memory but it is faster for simply operations, e.g. If I want to insert a line in my movie list file I waste less time in console mode than in graphical mode, waiting for GNOME, Metacity and X server to be loaded.
Removing consoles
One of the cool features of a linux distribution is the availability of several terminals. These terminals are accessed with Ctrl+Fn keys and allows to log in more than once in the system. But sincerely, I have been using Linux since several years ago and I never needed more than three or maybe four terminals at a time. So you can save some memory by disabling some of them. Even more, if you usually use a graphical desktop, you can use one or more gnome-terminals or konsoles, so you can safely left only one additional terminal in your system and free the other ones.
To achieve this, the /etc/inittab file must be modified again. Just comment the lines that set the terminals:
# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
Hdparm
At this moment we revisited hdparm. We have seen that it can show disk information but it can set some properties too. The most important options you can try are:
-d: enables/disables DMA transfers.
-X: fine tuning for the DMA transfers.
-A: for look ahead when reading disk blocks.
-c: enable IDE 32 bit support.
-C: very important for laptops (power management features)
As an example, I disable my DMA transfers, look ahead and 32 bit support and run a test:
[root@Hammer ~]# hdparm -A0 -d0 /dev/hda
/dev/hda:
setting using_dma to 0 (off)
setting drive read-lookahead to 0 (off)
using_dma = 0 (off)
[root@Hammer ~]# hdparm -tT /dev/hda
/dev/hda:
Timing cached reads: 1580 MB in 2.00 seconds = 789.33 MB/sec
Timing buffered disk reads: 8 MB in 3.20 seconds = 2.50 MB/sec
Notice that buffered disk reads have decreased dramatically! It is more than 15x worse (compared to the test performed above...).
Sysctl
Probably this is the best tool for tuning linux systems. It can configure a lot of system parameters while the linux kernel is running. It handles this, by reading and writing to kernel variables through procfs files.
The complete list of available variables is shown by typing:
[root@Hammer ~]# sysctl -a
It would be a waste of time to explain every variable in this long list. Instead of that, if you are curious, you can play with them (most of them are self-explanatory).
My advice: look at networking options.
Installing video card drivers
This is one of the devices that I’m sure you are not using all its capabilities if you are working with a stock configuration and installation. The biggest video card vendors, like Nvidia, ATI or Intel provides their own proprietary drivers for linux. This license issue is the reason by which they are not included in most of the distributions. Proprietary drivers can improve your video card performance very much. Let’s use x11perf again. I run a deepcopyplane500 test with the “Standard VGA” driver chosen by my stock installation. I saved the result in test1 file. Then I change to the ATI proprietary drivers for my ATI Radeon Mobility 9700 and run the test again saving the result in test2 file.
The use of x11perfcomp will reveal the big difference between the two drivers.
[fernape@Hammer ~]$ x11perfcomp test1 test2
1: test1
2: test2
1 2 Operation
-------- -------- ---------
7.7 54.2 Copy 500x500 n-bit deep plane
Almost 8x better performance with the ATI drivers!
As you can see, it is really a good idea to install the proper optimised driver for your video card.
Going further, you can even improve the performance of the driver. Nvidia and ATI, allows you to install a precompiled package or to generate a new one. The last option allows you to compile the driver for your specific machine instead of use a generic one.
If you choose the recompile option, you will need your kernel sources, but fortunately the installers make a good job and generate the package automatically without additional work.
Drivers for frequency scaling
If you are using a processor with variable frequency (e.g. Centrino or AMD64) you would like to properly set up your processor configuration to save battery charge. Cpufreq is a program that helps you to do this. It can manage Centrino and AMD64 processors, and allows you to control the frequency value by means of an interface under /sys. With cpufreq you can fix the frequency to the minimum value (max. saving), the maximum value (better performance), or let the driver choose when to increase or decrease the frequency.
To install this daemon, you will need libsysfs and a linux kernel capable of frequency scaling. Most of the modern distributions comes with cpufreq installed. Now it is time to configure it. In my case, it was not properly configured so my AMD was at 100% of use all the time.
Above a list of configurable files is showed:
[fernape@Hammer ~]$ ls /sys/devices/system/cpu/cpu0/cpufreq/
cpuinfo_max_freq scaling_available_governors scaling_governor cpuinfo_min_freq
scaling_cur_freq scaling_max_freq scaling_available_frequencies scaling_driver scaling_min_freq
Details - Compiling your linux kernel (the easy way...)
The linux kernel is the core of the operating system. It is used permanently when you are working with your distribution. Even when you are executing a “hello world” program, is the kernel who loads the program, attends to memory requests and executes system calls to perform the actual work you can see.
Due to this, it is very important to have installed and properly configured (and optimized) your linux kernel. Compiling the kernel is a long and complex topic that can't be covered here in depth. However, you can be lucky if your distribution provides default configuration files for the most common architectures. This is the case of the Red Hat based systems. Let's see how to easily recompile our kernel:
First of all, I assume that you have your linux kernel sources properly installed in your machine.
These configuration files ensure that you will obtain the same result you had with a stock kernel but with your specific processor optimizations. You can safely load this file and don't worry about anything. The picture below shows the configuration file loaded.
Even more, in my case, I'm sure my processor is an Athlon64 so I can set it in the options and deselect the Generic-x86-64 option.
Then save your settings and continue with the process:
make;
make modules;
make modules_install;
And if needed, create your initrd file.
If you have compiled and installed your kernel successfully, you will take advantage of your system architecture without a big effort.
---------
Best Regards,
eUKShane
http://www.eukhost.com