Howto: Simple tuning of Debian systems

Share your own howto's etc. Not for support questions!

Howto: Simple tuning of Debian systems

Postby Lavene » 2006-06-28 06:41

This HOWTO describes some simple and easy things you can do to 'tune' your Debian system. The methods described in this HOWTO is just some of several approaches one can use and does not claim neither to be the best nor the most effective way to tune your system, but contain things the author has found to be useful. Although the described method should be safe it's always a good idea to make a backup of important data before doing major changes to the system. This HOWTO is licensed under the terms of the GNU Free Documentation License. It has been written in the hope that it will be useful to the community but it comes with no warranty; use it at your own risk.

This HOWTO assume you have the following:
Pure Debian.
Standard install of Stable or Testing.
(Most of this HOWTO will however apply to most Debian based systems)

Before you start:
A standard Debian install contains a huge number of packages in order to provide a good system for everyone. But for most users a lot of these packages will never be used and they end up just taking up space on your hard-drive. So if you have limited space on your HD, and you don't want to embark on a minimal reinstall, it is a good idea to remove the things you don't need. But before you start to randomly remove packages you should try to define what you actually use your system for. Then you should go through your menu taking notice of what applications you never use. Then it's time to prepare the leaning of your system. First make sure you have the latest package list:

Open a terminal, su to root (At the prompt type su, hit enter, type your root password, it enter), then:
Code: Select all
# apt-get update

It's also a good idea to make sure the systems database is up to date:
Code: Select all
# updatedb

Next you want to install the following tools (which may or may not be installed on your system already):
Code: Select all
# apt-get install deborphan rcconf synaptic

Slimming the system:
First we want to remove any unused locales and system documents in languages we don't use. The tool for that is 'Localepurge'. Note that when you install 'Localepurge' it will start right away:
Code: Select all
# apt-get install localepurge

Go through the configuration as you are prompted making sure to select the locales you want to KEEP. When done the program will remove the unnecessary files and report the amount of disc space freed. Note that localepurge will execute and remove any new locales that may be installed on your system in the future. Very handy...

Removing unwanted software:
Now we will start the one task that will have the most impact on our system; removing unwanted software. The perfect tool for this is the 'Synaptic' package manager. You can start it either from the menu or from the commandline, and when it's up and running, click the 'Status' button and select the 'installed' option. You then get a complete list, in alphabetical order, of the packages that is installed on our system. Left-click on an entry and select 'Mark for complete removal'. (This is the equivalent 'to apt-get remove –purge package').

If the selected package has any dependencies it will present you with a list. READ IT CAREFULLY! Some packages that seem trivial has some very DANGEROUS dependencies like your kernel package, entire desktop environments or other necessities. If you don't know what all of the dependencies are, leave the package alone for now.

Now it's just a matter of going through the list of installed packages and marking the ones you want to remove. When you are all done you click the 'Apply' button, review the list presented by Synaptic and confirm by hitting 'Apply' again. It will then start the remove process. Please note that this process can take quite some time depending on the number of packages you remove.

When it's done, do an 'updatedb' again for good measure.

Orphaned libraries:
Orphaned libraries are libs that has no packages depending on them. Orphaned libs serves no purpose and can safely be removed. For details see deborphan's man page.
Code: Select all
# orphaner

Note that when done the first time around it may present you with another list of orphans. Just keep going until there are no more orphaned libs left.
A word of caution: If you have installed a lot of programs from source you should be a bit careful with this as it might break something since your system is not aware of these programs.

Another limited resource is memory. Keeping as much available memory as possible means a faster, more efficient system. A standard install of pretty much every mainstream Linux distro installs deamons and services that runs constantly in the background, using valuable memory. But most users don't need all of the default services running so it's a good idea to only have what you need running. The tool of choice is
Code: Select all
# rcconf

It will give you a list of running services with the option to disable them. Since different systems has different things running I can't say what is needed or not. Check the man pages for each service to determine if you need it. The disabled services will stay in the list so it's easy to enable them again if you need to.

Virtual consoles (gettys):
Debian enables six virtual consoles as default but most people doesn't need that many. Unfortunately virtual consoles hog memory so it's a good thing to disable a few that you don't need. As root open the file /etc/inittab in your favorite editor, then look for:

# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
# 4:23:respawn:/sbin/getty 38400 tty4
# 5:23:respawn:/sbin/getty 38400 tty5
# 6:23:respawn:/sbin/getty 38400 tty6

Add a # in the beginning of the ones you want to disable, starting with the highest one. This is called “comment out” and make the system ignore what comes after the #. In the above example getty 4, 5 and 6 is disabled. Don't forget to save it when you are done (did you remember to back up the original?)

The Kernel:
The kernels provided by Debian comes with a lot of options enabled. A very good way to save a few bytes is to recompile it with only the things you need enabled. See for a kernel compile howto.

Desktop Environment:
If you really need to run a light system it might be a good idea to drop the big desktop environments like KDE or GNOME and opt for a lighter Window Manager. A good place to 'shop' for a WM is Don't be afraid of trying some of them out. They will usually happily coexist with KDE and/ or GNOME and take up almost no space at all on your harddrive. And a bonus is that playing around with various window managers is great fun.


PS: Got a neat trick on increasing system efficiency? Add to the thread! :)
Site admin
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby Lux » 2006-06-28 23:44

More simple tuning (for PCs with i686 CPU or better):
-- Install hdparm and make sure that dma is enabled for your hd and cdrom/dvd drive(s).
-- Install libc6-i686.
-- Install prelink, edit /etc/default/prelink, and run (as root) "prelink -a".
-- Install the i686-optimized linux-image (or roll your own kernel from source; in menuconfig go to "Processor type and features" and select a processor family that matches your CPU; install x86info if you don't know your processor type; other interesting menuconfig settings under the same category are "Preemption model" and "Timer frequency").
-- Run "dpkg-reconfigure dash" and use dash as /bin/sh.
-- If you use ext3, check out "man tune2fs" and see if you find some of the following commands useful:
Code: Select all
tune2fs -o journal_data_writeback /dev/your_partition
tune2fs -O dir_index /dev/your_partition
tune2fs -m 0 /dev/your_partition
tune2fs -c 50 /dev/your_partition

-- Afterwards, the "data=writeback" journal mode can be set for ext3 in /etc/fstab, like this:
Code: Select all
/dev/hda1    /    ext3    rw,noatime,data=writeback    0    1

-- Most users will find that disabling IPv6 makes Firefox faster -- type "about:config" in Firefox's address bar, scroll down to "network.dns.disableIPv6" and right-click it to toggle the value.
"Hit the philistines three times over the head with the Elisp reference manual."
-- Michael A. Petonic --
User avatar
Posts: 474
Joined: 2006-01-25 13:00
Location: Finland

Postby Grifter » 2006-06-29 00:17

If you run a daemon for something that doesn't generate much traffic, but which you still require (such as a private ftp), start them from inetd instead of running as a daemon, that way they only use resources when someone connects
Eagles may soar, but weasels don't get sucked into jet engines...
Posts: 1572
Joined: 2006-05-04 07:53
Location: Svea Rike

Postby bluesdog » 2006-07-08 03:11

If you do not require famd, (File Alteration Monitor Daemon), disable or remove it from your system.

If you ever had trouble unmounting cds, or if some applications seemed to run very sluggishly, or not at all, after/during other disk-intensive ops, check top to see what system resources are being used by fam

On my system, fam was consuming nearly 90% after running Azureus for a while, and wouldn't release the resources even after stopping Azureus!
User avatar
Posts: 2082
Joined: 2006-02-01 09:02
Location: Similkameen, British Columbia, Canada

Postby osmo » 2006-07-08 03:23

For "Removing unwanted software" I'd recommend using aptitude always when installing and removing packages as it takes note whether a package was installed to satisfy a dependency or if you specified to install that package.

With aptitude you could then review your unautomatically installed packages with
Code: Select all
$ aptitude search . | egrep ^i.[^A]

That should be a lot less than all your installed packages. Remove what you don't need and their no longer used dependencies will be removed as well.
User avatar
Posts: 60
Joined: 2006-03-15 14:40
Location: Finland

Postby Lavene » 2006-07-08 03:37

bluesdog wrote:On my system, fam was consuming nearly 90% after running Azureus for a while, and wouldn't release the resources even after stopping Azureus!

To be honest, 'fam' is a real piece of sh*t and the developers seem unable to do anything about it. As an example, here's a few of the outstanding bugreports. Yes they are duplicates but it's a good indication of the level of frustration this package causes:

    #331413: fam: can't unmount cdrom
    #252896: fam uses 100% of CPU
    #298576: famd busy-looping
    #303108: famd takes over my CPU!
    #304558: famd 100% cpu usage
    #376507: fam seems to loop, causes freeze of system after a while

A real shame.

Site admin
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby DeanLinkous » 2006-07-08 03:50

I havent noticed any problems with gamin....
fam sucks
gamin good
fam sucks
gamin sucks less?
User avatar
Posts: 1611
Joined: 2006-06-04 15:28

Postby Lavene » 2006-07-08 04:14

I did run into a similar problem with gamin a while back when I was using Kanotix but I don't know what caused it back then...

Site admin
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby garrincha » 2006-07-15 01:38

Here is another tip - this one is for freeing up disk space under Debian GNU/Linux especially for old PC with low Gigs of memories. I use Etch/Testing, so I presumed that it should be similar for others.

Remove the cached .deb files
When you run the apt-get command, it downloads and caches the package in the /var/cache/apt/archives directory. If you apt-get a lot of stuffs, these .deb binaries will eat up a lot of disk space.

Type (as root) in the terminal:
Code: Select all
# cd /var/cache/apt/archives
# du –ch

Code: Select all
8.0K    ./partial
832M    .
832M    total

Remove all the *.deb files:
Code: Select all
# rm –f *.deb

et voila! You will get as much space as possible back!
User avatar
Posts: 2340
Joined: 2006-06-02 16:38

Postby Lavene » 2006-07-15 03:37

garrincha wrote:Here is another tip - this one is for freeing up disk space under Debian GNU/Linux especially for old PC with low Gigs of memories. I use Etch/Testing, so I presumed that it should be similar for others.
<snip snip>

Actually apt-get already has this covered:
Code: Select all
apt-get clean

For more info:
Code: Select all
man apt-get

Tina :)
Site admin
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby garrincha » 2006-07-15 12:26

Ah, how could I forget about "apt-get clean"! It was a while since I read the man page on apt-get. :)

Yeah, it does the job as I mentioned in my post above. moreover there the man page has useful info.
User avatar
Posts: 2340
Joined: 2006-06-02 16:38

Postby garrincha » 2006-11-05 17:15

A question.

I just checked my Synaptic Package Manager, there are packages in the installed (local or absolute) status section.

I'm wondering whether it is safe to completely remove some of the packages there? Most of these are libraries and I do not really know much about these.
Maurice Green on Usain Bolt's 9.58: "The Earth stopped for a second, and he went to Mars."
User avatar
Posts: 2340
Joined: 2006-06-02 16:38

Postby Lavene » 2006-11-05 18:50

It's usually a bad idea to remove stuff you don't know what is ;)
To take care of the libs you don't need you have the 'deborphan' package. See my OP for details. But just quickly:
Code: Select all
# apt-get install deborphan

Code: Select all
# orphaner

It will delete all orphaned libs on your system. The rest of them you probably want to keep :)

Site admin
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby mikekgr » 2007-03-12 06:32

Dear All,

I found this "speed up" tips a very nice add on on my Debian system. Thanks a lot

Best Regards,
Mike Kranidis
Posts: 56
Joined: 2004-12-24 18:25
Location: Greece

Postby craigevil » 2007-03-12 11:22

Running prelink as # /usr/sbin/prelink -avmR and then setting up a prelink cron job seems a better way to go then just prelink -a.

1. use apt-get or synaptic to install prelink
2. Open /etc/default/prelink with your favorite editor, as sudo/root
3. Change PRELINKING=unknown from unknown to yes
4. Adjust the other options if you know what the heck you're doing. Defaults work well
5. To start the first prelink run as root prelink -avmR(the longest one!),then run su/sudo /etc/cron.daily/prelink

Is there a way that libc6-i686 won't be seen as an orphan?

Debian Reference - Tuning a Debian system

* Hard disk access optimization. Very effective.
* Dangerous. You must read hdparm(8) first.
* hdparm -tT /dev/hda to test disk access speed.
* hdparm -q -c3 -d1 -u1 -m16 /dev/hda to speed up a modern IDE system. (It may be dangerous.)

Use rcconf or sysv-rc-conf to edit when services start. The few things that run at boot that you do not really need the fast your system will boot.

Adding this line MOZ_DISABLE_PANGO=1 to /etc/environment supposedly speeds up Mozilla Firefox.
Last edited by craigevil on 2007-03-12 15:38, edited 2 times in total.
Debian Sid KDE Kernel 3.17 Thinkpad R40 Intel M 1.3 CPU 2GB RAM Radeon Mobility 7500
Debian - "If you can't apt-get something, it isn't useful or doesn't exist"
Debian upgrade script smxi | sysinfo script inxi
User avatar
Posts: 5192
Joined: 2006-09-17 03:17
Location: Oz


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 2 guests