Tag Archives: raspberry pi

Removing logging to increase I/O performance on the Raspberry Pi

I recently was looking at optimizing the device to make Apache run faster. Thanks to TAFB from #raspberrypi on FreeNode IRC chat, I experimented with turning off syslog and noticed a few second increase with the two different sites hosted on the Pi. Overall, there will be less IO on the system and less RAM and CPU being used that will result in slightly better performance on the PI. Also, there will be significantly less writes on the SD card. SD cards have a limited number of writes so it is important to reduce the numbers to have a longer lifespan.

The distribution used is Arch Linux.

In /etc/systemd/journald.conf:
Storage=none

Manage The Services:
# systemctl stop systemd-journald
# systemctl disable systemd-journald

Remove Syslog:
# systemctl stop syslog-ng.service
# systemctl disable syslog-ng.service
# pacman -R syslog-ng

Next, I began to tune root filesystem for optimal performance and disabled logging.

Add the following to /etc/fstab:

/dev/mmcblk0p2 / ext4 rw,noatime,data=writeback,barrier=0,nobh,errors=remount-ro 0 1

# reboot

# tune2fs -o journal_data_writeback /dev/mmcblk0p2

Before: Rusher81572.com loaded in 2.857s
After: Rusher81572.com loaded in 2.149s

Before: Rusher81572.com/pi loaded in 4.356s
After: Rusher81572.com/pi loaded in 4.039s

Reducing writes by redirecting writes to /dev/null

This is a perl script that I use to take all the logs located in “/var/log” and redirect the output to /dev/null. This helps reduce the number of writes to the SSD card. This will help the SD card last much longer.

Save this as log.pl
——–
#!/usr/bin/perl
$log=”/var/log/”;
@array=( ‘ssl_request_log’, ‘pacman.log’, ‘named.log’, ‘mail.log’, ‘fail2ban.log’, ‘error_log’, ‘access_log’, ‘auth.log’, ‘crond.log’, ‘daemon.log’, ‘errors.log’, ‘everything.log’, ‘faillog’, ‘kernel.log’, ‘messages.log’, ‘packman.log’, ‘syslog.log’, ‘user.log’);
@array2=@array;
sub sh { my $comm =”@_[0]”; open (command,”$comm |”);
while() { } }
foreach(@array) { sh(“rm -f $log$_”); }
foreach(@array2) { sh(“ln -s /dev/null $log” . $_); }
——–

# perl log.pl

Gentoo Stage 4 for the Raspberry Pi

This is a great guide for getting Gentoo on the Pi. I did not see any stage4 installs available so I wanted to make one for the public to help save time on the Pi. If you follow all the steps on the Wiki yourself, it will take a few hours to accomplish the same steps.

Instructions:

Download the stage 4: https://www.dropbox.com/s/7m0dilz3me76mr8/stage4-01232013.tar

[insert url here]

Partition SD card :
100 MB -> /boot (/dev/mmcblk0p1) (Windows partition)
2GB or more -> / (/dev/mmcblk0p2) (Linux )

mkfs.vfat /dev/mmcblk0p1
mkfs.ext4 /dev/mmcblk0p2

Extract stage4-01232013.tar.gz somewhere

Mount /boot somewhere and copy the files in “boot” to it from the stage4 tar file.
Mount / somewhere and move everything else there.
Download the latest portage snapshot per the Gentoo Guide and extract it to usr/ on your new / .

Unmount everything and turn on your Pi.