Tag Archives: linux

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.

Simple iptables tutorial for Linux

File: /etc/sysconfig/iptables :

———————————————————————————–

*filter

#This line will block any incoming connections except for the rules we allow later in this file.
:INPUT DROP [5:574]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [136:13895]

#These two lines are the basics for allowing incoming connections.

-A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT

# This line allows SSH

-A INPUT -p tcp -m tcp –dport 22 -j ACCEPT

COMMIT
*nat

:PREROUTING ACCEPT [468:62332]

:POSTROUTING ACCEPT [252:15827]
:OUTPUT ACCEPT [559:41614]
COMMIT

———————————————————————————–

When your done editing this file run:

# service iptables restart