How to test disk performance in Linux

A lot of performance issues can be caused by poor disk performance. Here’s how to test the read and write performance on a Linux system using dd.

1. Write a file 2x the size of the RAM to make sure we get the real write rate. In this example the RAM of the server is 1 GB so I’m writing a 2 GB file (8KB * 250000 = 2GB). You can adjust the number of blocks to make it suitable for the amount of RAM in your system .

time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"

2. Write a new file equal to the amount of RAM in the system to flush out the data cached with last action (8KB * 125000 = 1GB).

dd if=/dev/zero of=ddfile2 bs=8K count=125000

3. Test the read speed

time dd if=ddfile of=/dev/null bs=8k

Hobbit doesn’t recognize last apt-get update

After installing the hobbit-plugins package, all my lenny servers were marked red on the hobbit server and the error message was: “Last apt update: 175.7 day(s) ago”.

The reason is that the hobbit-client relies on the file: /var/lib/apt/lists/lock but apt isn’t updating that anymore.

To fix this I created a cron job to update apt-get every night and update the /var/lib/apt/lists/lock file (crontab -e)

0 4 * * * /usr/bin/apt-get update 1>/dev/null && touch /var/lib/apt/lists/lock

Debugging logrotate issues

If your log files aren’t automatically rotated by the logrotate program there are probably some errors in the config files located in /etc/logrotate.d.

To find out where the error is, run this command:

logrotate -d -f /etc/logrotate.conf

You will see some debug messages on the console and hopefully a error that will lead you to the faulty lines in the config. In my case there were duplicate entries for /var/log/mail.log shown in the debug like this:

error: rsyslog:13 duplicate log entry for /var/log/mail.log