Ultimate Ubuntu performance tweaking guide
Lets start first with the kernel:apt-get install build-essential libncurses-dev kernel-package
cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.tar.bz2
This will download the latest sources available, in my case linux-2.6.20.tar.bz2
cd /usr/src
tar -xjf linux-2.6.20.tar.bz2
cd linux-2.6.20
Now lets apply the Con Kolivas patches, these are patches designed to improve system responsiveness with specific emphasis on the desktop, but suitable to any workload.
wget www.kernel.org/pub/linux/kernel/people/ck/patches/2.6/2.6.20/2.6.20-ck1/patch-2.6.20-ck1.bz2
bzcat patch-2.6.20-ck1.bz2 |patch -p1
Copy the current kernel config and configuring the kernel
cp /boot/config-`uname -r` .config
make menuconfig
In “General Setup” activate:
- Support for paging of anonymous memory (swap)
- Support for prefetching swapped memory
In “Processor type and features“:
- Processor family Choose the model of your processor.
- set Preemption Model to Voluntary Kernel Preemption (Desktop)
- High Memory Support
- off - if you have less than 1 GB of RAM
- 1GB Low Memory Support - if you have 1GB of RAM
- 4GB - if you have more than 1GB of RAM
- set Timer frequency to 1000 Hz
In “Kernel hacking” uncheck “Kernel debugging“.
Now exit and save the configuration.
Making the new kernel package:
make-kpkg -initrd –revision=LinuxMonitor1 kernel_image kernel_headers modules_image
Installing the new kernel
cd ..
dpkg -i *.deb
HDParm
sudo gedit /etc/hdparm.conf
at the bottom add:
/dev/hda {
dma = on
io32_support = 1
}
/dev/cdroms/cdrom0 {
dma = on
interrupt_unmask = on
io32_support = 0
}
Concurrent Booting Concurrent booting allows Ubuntu to take advantage of dual-core processors, as well as processors that hyperthread or multithread or what ever the different companies call it now. sudo gedit /etc/init.d/rc Look through the file and you will find CONCURRENCY=none. You must change it to: CONCURRENCY=shell
Prelink
Disclaimer: Prelinking might break your system! Only consider for use if you can risk the chance that your install might mess up. Most of all make sure that it gets to run the whole thing through the first time you prelink. Stopping in the middle can lead to system failure. Prelinking is a powerful device and needs to be used with care.
Prelink is no longer necessary in Feisty. Feisty uses a new linking mechanism called DT_GNU_HASH which dramatically speeds up the linking process without the need for continuously running this prelink program. Again, prelink is NOT useful starting from Feisty
How to enable prelink
1. Activate Ubuntu universe sources
2. Put this command into terminal to install Prelink:
sudo apt-get install prelink
3. Now put this command into the terminal:
sudo gedit /etc/default/prelink
4. Change where it says “PRELINKING=unknown” from unknown to “yes”
5. Adjust the other options if you know what the heck you’re doing. If it looks foreign to you, the defaults work well.
6. To start the first prelink (the longest one!), put this in terminal:
sudo /etc/cron.daily/prelink
Automatic Prelinking After Program Are Installed
One problem with prelinking in that when you install new programs those programs are not prelinked. So to avoid this problem when installing programs with apt-get or synaptic, use the directions below.
1. Put this in terminal:
sudo gedit /etc/apt/apt.conf
2. When the file opens in Gedit, put this line at the end of the file and save (even if the file has no content before you add the line):
DPkg::Post-Invoke {”echo Running prelink, please wait…;/etc/cron.daily/prelink”;}
General Notes About Prelinking
In the future, prelink performs a quick prelink (a less-than-1-minute procedure on most systems) daily, usually at midnight. Every 14 days, or whatever you changed it to be, a full prelink will run.
If you just did a major apt-get upgrade that changed systemwide libraries (i.e. libc6, glibc, major gnome/X libs, etc etc etc) and experience cryptic errors about libs, rerun step 6.
To undo prelink, change step 4 from yes to no, then rerun step 6.
Prelinking will make the binaries it prelinks change, so it’s not appropriate if you have tripwire or another checksum-based IDS system, or if you do incremental or differential backups to save on space.
Services
*Note you might not have all these services on your box.
To enable/disable services go to System -> Administration -> Services
1. acpi-support - leave it on.
2. acpid - The acpi daemon. These two are for power management, quite important for laptop and desktop computers, so leave them on.
3. alsa - If you use alsa sound subsystem, yes leave it on. But if you have the service below, its safe to be off. The default is off when alsa-utils is on.
4. alsa-utils - On my system, this service supercedes the alsa, so I turn off the alsa and turn this on at S level.
5. anacron - A cron subsystem that executes any cron jobs not being executed when the time is on. Most likely you’ve probably turned your computer off when a certain cron job time is ready. For example, updatedb is scheduled at 2am everyday, but at that moment, you computer is off, then if anacron service is on, it will try to catch up that updatedb cron.
6. apmd - If you computer is not that old which can’t even support acpi, then you may try to turn this off.
7. atd - like cron, a job scheduler. I turned it off.
8. binfmt-support - Kernel supports other format of binary files. I left it on.
9. bluez-utiles - I turned it off. I don’t have any bluetooth devices.
10. bootlogd - Leave it on.
11. cron - Leave it on.
12. cupsys - subsystem to manager your printer. I don’t have one so I turned it off, but if you do, just leave it on.
13. dbus - Message bus system. Very important, leave it on.
14. dns-clean - Mainly for cleaning up the dns info when using dial-up connection. I don’t use dial up, so I turn it off.
15. evms - Enterprise Volumn Management system. I turned it off.
16. fetchmail - A mail receving daemon. I turned it off.
17. gdm - The gnome desktop manager. I turned it off anyway since I get use to boot to console first. This is up to you if you want to boot directly to GUI.
18. gdomap - You can turn it off.
19. gpm - Mouse support for console. If you feel you’d better have a mouse on console, go turn it on.
20. halt - Don’t change it.
21. hdparm - tuning harddisk script, should be on.
22. hibernate - If your system support hibernate, leave it on. Otherwise, its useless for you.
23. hotkey-setup - This daemon setup some hotkey mappings for Laptop. Manufacturers supported are: HP, Acer, ASUS, Sony, Dell, and IBM. If you have a laptop in those brands, you can leave it on, otherwise, this might not have any benefits for you.
24. hotplug and hotplug-net - activating hotplug subsystems takes time. I’d consider to turn them off.
25. hplip - HP printing and Image subsystem. I turned it off.
26. ifrename - network interface rename script. Sounds pretty neat but I turned it off. Mainly for managing multiple network interfaces names. Since I have a wireless card and an ethernet card, they all assigned eth0 and ath0 from kernel, so its not really useful for me.
27. ifupdown and ifupdown-clean - Leave it on. They are network interfaces activation scripts for the boot time.
28. inetd or inetd.real - take a look your /etc/inetd.conf file and comment out any services that you don’t need.
29. klogd - Leave it on.
30. laptop-mode - A service to tweak the battery utilization when using laptops. You can leave it on.
31. linux-restricted-modules-common - You need to see if you really have any restricted modules loaded on your system. I’d leave it on.
32. lvm - I don’t use it so I turned it off. Leave it on if you *DO* have lvm.
33. makedev - Leave it on.
34. mdamd - Raid management tool. I don’t use it so I turned it off.
35. mdamd-raid - Raid tool. If you don’t have Raid devices, turn it off.
36. module-init-tools - Load extra modules from /etc/modules file. You can investigate your /etc/modules file and see if there is any modules that you don’t need. Normally, this is turned on.
37. mountvirtfs - mount virtual filesystems. Leave it on.
38. networking - bring up network interfaces and config dns info during boot time by scaning /etc/network/interfaces file. Leave it on.
39. ntpdate - Sync time with the ubuntu time server. Leave it on if you want.
40. nvidia-kernel - I compiled the nvidia driver by myself, so its useless for me now. If you use the ubuntu nvidia driver from the restrict modules, just leave it on. 41. pcmcia - pcmcia device - useless if you are using desktop which doesn’t have pcmcia card. So in that case, turn it off please.
42. portmap - daemon for managing services like nis, nfs, etc. If your laptop or desktop is a pure client, then turn it off.
43. powernowd - client to manage cpufreq. Mainly for laptops that support CPU speed stepping technology. Normally, you should leave it on if you are configuring a laptop, but for desktop, it might be useless.
44. ppp and ppp-dns - Useless to me. I don’t have dial-up.
45. readahead - It seems readahead is a kind of “preloader”. It loads at startup some libs on memory, so that some programs will start faster. But it increases startup time for about 3-4 seconds. So, you can keep it… or not. I tested and I just didn’t feel difference loading programs. So I decided to turn it off. If you have a reason to keep it on, please do so.
46. reboot - Don’t change it.
47. resolvconf - Automatically configuring DNS info according to your network status. I left it on.
48. rmnologin - Remove nologin if it finds it. It wouldn’t happen on my laptop, so I got rid of it.
49. rsync - rsync daemon. I don’t use it on my laptop, so turned it off.
50. sendsigs - send signals during reboot or shutdown. Leave it as it is.
51. single - Active single user mode. Leave it as it is.
52. ssh - ssh daemon. I need this so I turned it on.
53. stop-bootlogd - stop bootlogd from 2,3,4,5 runlevel. Leave it as it is.
54. sudo - check sudo stauts. I don’t see any good to run it everytime on a laptop or desktop client, so I turned it off.
55. sysklogd - Leave it as it is.
56. udev and udev-mab - Userspace dev filesystem. Good stuff, I left them on.
57. umountfs - Leave it as it is.
58. urandom - Random number generator. Might not useful but I left it on.
59. usplash - Well, if you really want to see the nice boot up screen, leave it as it is.
60. vbesave - video card BIOS configuration tool. Its able to save your video card status. I left it on.
61. xorg-common - setup X server ICE socket. Leave it as it is.
62. adjtimex - This is a kernel hw clock time adjusting too. Normally, you shouldn’t see this on your boot up list. In very rare case if you do see its on your boot up process, then there might be a reason why it is on, so better leave it that way. In my case, it is off.
63. dirmngr - A certification lists management tool. Work with gnupg. You will have to see if you need it or not. In my case, I turned it off.
64. hwtools - A tool to optimize irqs. Not sure what’s the benefits of turning it on. In my case, I turned it off.
65. libpam-devperm - A daemon to fix device files permissions after a system crash. Sounds pretty good, so I left it on.
66. lm-sensors - If you matherboard has builtin some sensor chips, it might be helpful to see hw status via userspace. I ran it and it said “No sensors found”, so I turned it off.
67. screen-cleanup - A script to cleanup the boot up screen. Well, turn on or off is up to you. In my case, I left it on.
68. xinetd - A inetd super daemon to manage other damons. In my system, the xinetd is managing chargen, daytime, echo and time (find them from /etc/xinetd.d dir), I care none of them, so I turned it off. If you do have some important services configured under xinetd, then leave it on.
The end! Special thanks to i3dmaster, xXx 0wn3d xXx, poofyhairguy and the rest of the ubuntuforums.org people
Thank you for reading this post. You can now Read Comments (40) or Leave A Trackback.
Post Info
This entry was posted on Sunday, March 4th, 2007 and is filed under HOWTO, Linux, Ubuntu.You can follow any responses to this entry through the Comments Feed. You can Leave A Comment, or A Trackback.
Previous Post: Windows Vista (Aero) VS Linux Ubuntu (beryl) »
Next Post: New Domain! »
Read More
Related Reading:- Beryl in Ubuntu Feisy repositories
- Tremulous: the best open source game I’ve played
- Overclocking ATI Radeon cards in Linux
- HOWTO Encrypt CD/DVDs in Ubuntu
- Festival: Linux Text-To-Speech
- Top 5 Linux Live CD/DVDs
- Ubuntu Customization Guide part I
- New Domain!
- Ultimate Ubuntu performance tweaking guide
- Windows Vista (Aero) VS Linux Ubuntu (beryl)


March 4th, 2007 11:11
just curious: what’s the advantage of performing the tweaks you describe? before i go recompiling my kernel, what are the benefits of the Con Kolivas patches? or what does prelinking accomplish? (especially curious about this one - you offer a disclaimer about the dangers of prelinking, but present no case for why this is a benefit)
just curious - i want some info before i go and bork my computer.
March 4th, 2007 12:30
http://en.wikipedia.org/wiki/Prelinking
March 4th, 2007 14:36
followed the kernel bit - got an error when trying to patch:
sudo bzcat patch-2.6.20-ck1.bz2 |patch -p1
patching file fs/proc/array.c
patch: **** Can’t rename file /tmp/poCKCzcF to fs/proc/array.c : Permission denied
any ideas whats wrong?
cheers
michel
March 4th, 2007 14:51
are logged as root ?
March 4th, 2007 14:54
Michel,
I’ve had trouble with piping commands together which require root privileges through sudo. I don’t think root privileges have carried over to the patch command, only bzcat. I usually just change to root and then run the command directly instead of using sudo. I guess you could also run ’sudo bzcat patch-2.6.20-ck1.bz2 |sudo patch -p1′. Maybe give that a try?
March 4th, 2007 16:13
Followed your directions but got lots of errors connected to fglrx/firegl.
Her’s a small sample:
/usr/src/modules/fglrx/firegl_public.c:470: error: ‘firegl_interrupt_write_wrap’ undeclared (first use in this function)
/usr/src/modules/fglrx/firegl_public.c:5162: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
Module /usr/src/modules/fglrx failed.
March 4th, 2007 19:22
im having an issue with the following command, ive included the error too.
/usr/src/linux-2.6.20# dpkg -i *.deb
dpkg: error processing *.deb (–install):
cannot access archive: No such file or directory
Errors were encountered while processing:
*.deb
March 4th, 2007 21:16
I’m having the same problem as flowsuit - no .deb packages to install.
Anyone know what could be wrong?
March 4th, 2007 22:47
the .deb files are located in one directory up… in /usr/src/
March 5th, 2007 03:04
hi there again and thanks for the continuios help
double sudo did the trick
however cant boot into the new kernel. booting in recovery mode shows that it stops booting after the line:
drivers/usb/input/hid-core.c: v2.6:USB HID core driver
any ideas?
cheers
michel
March 5th, 2007 04:23
I think it would be helpful to explain what the benefits of compiling the custom kernel and the HDPARM edit are.
March 5th, 2007 07:20
That worked. Thanks anonymous!
March 5th, 2007 07:26
Is this specific for Dapper (6.06) or Edgy (6.10), or can it be allied to both?
My workplace Dapper install already has entries in the /etc/hdparm.conf file, but they are commented out and I don’t know the difference/benefits between adding your code and using the prewritten options.
Also, do any of these tweeks rely on the others? For example, can I do the /etc/hdparm.conf changes without the kernel recompile, or are they codependent?
March 5th, 2007 10:32
I just realize that my comment (see above) wasn’t very useful:
I am on a fresh install of 6.10,
ati x1600 (fglrx-driver 8.34.8),
core2duo 2.16 mhz,
2 Gb Ram.
I was running Beryl/xgl at the time of compiling.
March 8th, 2007 09:11
I tried it last night and… curiously enough it did not work.
All went well - downloading, compiling etc. Then, the reboot proved it doesn’t work (for me, at least)
I guess I will stick to the kernel that is delivered through standard updates
March 8th, 2007 09:12
Hello!
Dude, after I compile the kernel and install the deb files, it won’t boot… same as another anonymous above… what can I do?
I must say that I have an alternative usplash theme (Xubuntu).. does this matters?
Please advice! Thanks a lot dude!
March 14th, 2007 05:43
I think it to be need not HDParm settings.
It is default.
“io32_support” is meaningless on DMA.
March 20th, 2007 11:32
tried to follow directions, but i couldn’t tell if i was reading an ad or instructions
March 23rd, 2007 18:15
has anyone successfully compiled and booted their kernel using this guide? I am just curious because I see a lot of people had problems and as much as I want to try it out, I’m really not in the mood to be fixing my system for the entire night
April 1st, 2007 23:52
> apt-get install build-essential libncurses-dev kernel-package
These command install gcc-4.1 and other programs in my fresh ubuntu edgy.
I ‘am compiled patched kernel version 2.6.20 with gcc-4.1 and install.
Kernel not start.
April 7th, 2007 05:05
Michel,
I’ve had trouble with piping commands together which require root privileges through sudo. I don’t think root privileges have carried over to the patch command, only bzcat. I usually just change to root and then run the command directly instead of using sudo. I guess you could also run ’sudo bzcat patch-2.6.20-ck1.bz2 |sudo patch -p1′. Maybe give that a try?
Use ¨sudo -i¨ to log in as root user, in that command console. This will allow you to bypass the use of sudo.
April 11th, 2007 02:21
Hi,
Just a point of note but you can leave off the first sudo as you don’t need it.
Also if you untar the kernel in somewhere like your home dir then you don’t need root at all. If you use “–rootcmd fakeroot” with the make-kpkg command you can build a kernel deb without ever needing to type sudo. Then when you are happy just install that deb.
Compiling software as root is generally a bad thing, who knows what it’s going to run while you make the software. Although you should be okay with the kernel it’s a bad habbit to get into.
john
April 24th, 2007 08:43
[…] Ultimate Ubuntu performance tweaking guide - Detailed step by step instructions on what to do in order to improve performance on your system. […]
April 25th, 2007 10:46
[…] Ultimate Ubuntu performance tweaking guide - Detailed step by step instructions on what to do in order to improve performance on your system. […]
April 25th, 2007 12:22
[…] Ultimate Ubuntu performance tweaking guide - Detailed step by step instructions on what to do in order to improve performance on your system. […]
April 25th, 2007 14:55
[…] Ultimate Ubuntu performance tweaking guide - Detailed step by step instructions on what to do in order to improve performance on your system. […]
April 26th, 2007 07:59
[…] Ultimate Ubuntu performance tweaking guide - Detailed step by step instructions on what to do in order to improve performance on your system. […]
May 2nd, 2007 13:41
[…] Ultimate Ubuntu performance tweaking guide - Detailed step by step instructions on what to do in order to improve performance on your system. […]
June 8th, 2007 11:13
make command contains a strange hyphen for the revision option:
make-kpkg -initrd –revision=LinuxMonitor1 kernel_image kernel_headers modules_image
it triggers a target error
June 26th, 2007 22:30
ok. is there a way to go back in the case that i cant boot?
July 9th, 2007 20:03
to fred:
type hypen twice… type “–” instead of “-”
July 21st, 2007 00:15
[…] Ultimate Ubuntu performance tweaking guide […]
July 28th, 2007 12:12
[…] Ultimate Ubuntu performance tweaking guide - Detailed step by step instructions on what to do in order to improve performance on your system. […]
August 5th, 2007 21:20
[…] Ultimate Ubuntu performance tweaking guide - Detailed step by step instructions on what to do in order to improve performance on your system. […]
August 29th, 2007 21:10
Wow this pretty much went off without a hitch. I did have one problem with the “make-kpkg -initrd –revision=LinuxMonitor1 kernel_image kernel_headers modules_image” command but I got it to go pretty good after removing the revision command. Also the recompiling of the kernal took forever. If this did screwup my computer I would have just reformatted and started anew. (I’m just playing around with ubuntu for now.) All in all it did speed up my performance, although I did use another guide before this one so it might not be entirely this guide.
September 29th, 2007 20:38
WEP tweaking Ubuntu Guide
http://en.airdump.net/hacks/hacking-wifi-ultimate-ubuntu-guide/
November 17th, 2007 12:24
[…] Ultimate Ubuntu performance tweaking guide […]
January 29th, 2008 17:18
Thanks to the author for the article, it was very helpful for me.
February 13th, 2008 07:21
[…] Linux Monitor | Ultimate Ubuntu performance tweaking guide pport for paging of anonymous memory (swap) - Support for prefetching swapped memory […]
March 1st, 2008 17:28
How about network stack tuning - it does help a lot for the server. Nice article - congrats!