Archive for category Tutorials

CPU Frequency Scaling

Posted by on Friday, 22 May, 2009

CPU frequency management is one of the keys to power preservation. Ideal for boxes that sit idle a lot of the time, e.g. that file server out the back.

Results will vary with Desktop/GUI systems, I found the response on Xubuntu too slow to clock up when needed, so I would manually set it to performance when using the system and ondemand if I was going to leave it idle. I guess this could be automated, to switch to ondemand when the system has been idle for a while..

apt-get install cpufrequtils sysfsutils
modprobe p4_clockmod (see links at bottom for other CPU types)
modprobe cpufreq_ondemand
echo ondemand | tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

Verify whats happening:

cpufreq-info

Save config/apply at startup:

echo p4_clockmod | tee -a /etc/modules
echo cpufreq_ondemand | tee -a /etc/modules
echo devices/system/cpu/cpu0/cpufreq/scaling_governor = ondemand | tee -a /etc/sysfs.conf

Reboot and run cpufreq-info again to verify:

cpufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006
Report errors and bugs to linux@brodo.de, please.
analyzing CPU 0:
  driver: p4-clockmod
  CPUs which need to switch frequency at the same time: 0 1
  hardware limits: 350 MHz - 2.80 GHz
  available frequency steps: 350 MHz, 700 MHz, 1.05 GHz, 1.40 GHz, 1.75 GHz, 2.10 GHz, 2.45 GHz, 2.80 GHz
  available cpufreq governors: ondemand, userspace, powersave, conservative, performance
  current policy: frequency should be within 350 MHz and 2.80 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 350 MHz (asserted by call to hardware).
  analyzing CPU 1:
  driver: p4-clockmod
  CPUs which need to switch frequency at the same time: 0 1
  hardware limits: 350 MHz - 2.80 GHz
  available frequency steps: 350 MHz, 700 MHz, 1.05 GHz, 1.40 GHz, 1.75 GHz, 2.10 GHz, 2.45 GHz, 2.80 GHz
  available cpufreq governors: ondemand, userspace, powersave, conservative, performance
  current policy: frequency should be within 350 MHz and 2.80 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 350 MHz (asserted by call to hardware).

Debian HOW-TO : CPU power management

How to make use of Dynamic Frequency Scaling


Postgrey HOWTO for Centos and Debian based Linux – Postfix Greylisting

Posted by on Wednesday, 6 May, 2009

Greylisting is a great invention to minimize a huge pile of spam. Any SMTP server thats incorrectly configured or mail sent from infected desktop machines just tries the first time, gets bounced, and never tries again.

Legitimate email comes through fine, however the downside is it can take a few minutes more than the usual. Considering how much Spam greylisting prevents its worth it for a lot of people.

The quick and dirty of the install is.

For debian based distros (Ubuntu etc included)

apt-get install postgrey

For Redhat/Centos based distros you will need to add the DAG/rpmforge repos into your lists and then

yum install postgrey

Next you need to enable it to listen on a port. In debian edit the file /etc/defaults/postgrey and add-in/edit the line

POSTGREY_OPTS="--inet=127.0.0.1:60000 --delay=60"

For Redhat based releases you need to CREATE /etc/sysconfig/postgrey and add in the following line

OPTIONS="--inet=127.0.0.1:60000 --delay=60"

Now restart the postgrey daemon with

/etc/init.d/postgrey restart

If you do a netstat you can see its now listening on localhost port 60000 (unless you buggered something up of course)

Now you need to edit the /etc/postfix/main.cf
search for the line that has smtpd_recipient_restrictions and add to it

check_policy_service inet:127.0.0.1:60000

And average config will look something like this

smtpd_recipient_restrictions =
reject_unknown_recipient_domain,
permit_mynetworks,
check_policy_service inet:127.0.0.1:60000
permit

Now reload the postfix with /etc/init.d/postfix reload
Now all you need to do is check the logs with tail -f /var/log/maillog and hope you got it all going right.


Centos 5 – Adding extra sources for bleeding edge

Posted by on Wednesday, 6 May, 2009

So you got yourself say a Centos VPS or Server. Some guy comes along and develops you a website made in the latest and greated PHP version and yours isnt running it!.

Easily fixed. First of all to know, is Centos 5 is basicly RHEL 5 only free, you can use the same sources lists and rpms between the two.

So adding the first source would be the DAG/RPMForge lists. The FAQ is up here http://dag.wieers.com/rpm/FAQ.php which is pretty generic and basic.

Red Hat Enterprise Linux 5 / i386:

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Remembering that Centos 5 is the same as el5 (Red Hat Enterprise Linux … RHEL) this works nicely. You may find that you get the following error when using apt to update

E: Dynamic MMap ran out of room
E: Dynamic MMap ran out of room
E: Error occured while processing packagename
E: Problem with MergeList
/var/state/apt/lists/listname
E: msync
E: The package lists or status file could not be parsed or opened.

This can be fixed by putting the following line into the bottom of /etc/apt/apt.conf

APT::Cache-Limit 50000000;

At Rimuhosting where i work we usually default to Centos 5.3 which is pretty much the latest release. I found the DAG/RPMForge lists not quiet as up to date as the Remi lists at http://blog.famillecollet.com/pages/Config-en

The easy way to get these ones going is as follows

wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

By default the remi lists are not enabled, you can use them indevidually with yum –enablerepo remi install packagename . Or you can edit the /etc/yum.repos.d/remi.repo and change the enabled=0 to enabled=1

Now you can yum update and yum upgrade nicely!

Let me know any other mirrors you found handy.