Posts tagged Debian

Mac OS X Time Machine backup on a Debian server

December 2015: I just wanted to note that the solution below stopped working for me after a while. However I recently purchased a Synology NAS and configuring as a Time Machine backup destination is fairly easy.

I just got a MacBook Air and had already read about how you can setup your own network based Time Machine backup on a Linux server. The problem is that there is some outdated information floating around, which caused me some headaches getting it to work with errors such as “The network backup disk does not support the required AFP features” and “backup failed with error 45” (in Console).

First: you need version 2.2.x of the “netatalk” package. Debian 6.0 (Squeeze) comes with 2.1 by default, which won’t work (with Mac OS X 10.8 “Mountain Lion” at least). Second, lots of how-to information includes instructions on creating a /etc/avahi/services/afpd.service file. With netatalk 2.2, this file is redundant: you do not need to create it.

Back to netatalk. Really old information will talk about needing to compile it from source to have it support the required authentication protocol. That is no longer relevant with the most recent version. If you are still running Debian 6.0 (still the stable version at time of writing) you can get netatalk 2.2 from Debian 7.0 (Wheezy) by doing the following (all as root): first add the following line to /etc/apt/sources.list

deb-src http://http.debian.net/debian wheezy main contrib non-free

Then run the following commands:

aptitude update
apt-get build-dep netatalk
apt-get -b source netatalk
dpkg -i netatalk_2.2.2-1_amd64.deb

Change the filename accordingly if the version number has slightly changed. With netatalk 2.2 installed, follow other guides on the net (such as this one or this one) to configure a Time Machine AFP share on your Debian server.

Solving “IPv6 addrconf: prefix with wrong length 48” permanently

If you have a recent distribution of Linux, you might find the message “IPv6 addrconf: prefix with wrong length 48” repeated a lot in syslog. If you Google this error message you’ll quickly find that this is because IPv6 auto configuration (sort of like DHCP) is failing. Now if you don’t want to bother with IPv6 yet or if you use static IPv6 (like my servers do) you don’t need IPv6 auto configuration.

A quick fix to solve the problem (as mentioned on sites like these) is to run the following commands:

echo 0 > /proc/sys/net/ipv6/conf/eth0/autoconf
echo 0 > /proc/sys/net/ipv6/conf/eth0/accept_ra

And yes, that solves the problem – until the next reboot that is. The permanent solution mentioned on that site however, does not work (as also confirmed by this IPv6 howto). The reason is that referring to all network interfaces using “all” in the following lines in /etc/sysctl.conf somehow doesn’t work:

net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.all.accept_ra = 0

The simple solution is to refer to each network interface specifically. My servers have both eth0 and eth1 (2 NICs) so I setup /etc/sysctl.d/ipv6.conf as follows:

net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.eth0.accept_ra = 0
net.ipv6.conf.eth1.autoconf = 0
net.ipv6.conf.eth1.accept_ra = 0

If you have only one network interface, you can omit the “eth1” lines. Alternatively you can use pre-up commands as described in the IPv6 howto, though I think my solution is prettier.

How to prevent cron & PowerDNS clogging syslog

On a default Debian installation both cron and PowerDNS will log into /varlog/syslog. If you are running very frequent cron jobs (like every 5 minutes) or an active PowerDNS server (or recursor), you’ll find syslog will be completely clogged with mostly unimportant messages. The solution of course, is to have these two services output log messages to their own log files.

In Debian Linux, you’ll need to change a few configuration files. First in open /etc/rsyslog.conf and change the following line:

*.*;auth,authpriv.none          -/var/log/syslog

into this (basically add local0 and cron to the list of things not to log into syslog):

*.*;local0,cron,auth,authpriv.none          -/var/log/syslog

Then uncomment the line just below that (remove # sign):

cron.*                         -/var/log/cron.log

If you do not run PowerDNS you can skip to the end of this post. If you do run PowerDNS (server or recursor) create the file /etc/rsyslog.d/pdns.conf (for example using the command nano -w /etc/rsyslog.d/pdns.conf) with the following contents:

local0.* -/var/log/pdns.log

Then update your PowerDNS configuration to make use of this file by changing the following section in either /etc/powerdns/pdns.conf and/or /etc/powerdns/recursor.conf

#################################
# logging-facility      Facility to log messages as. 0 corresponds to local0
#
logging-facility=0

As you can see, uncomment the logging-facility line and set it to 0. After this reboot PowerDNS.

In order for the PowerDNS log file not to grow out of control, you might want to add it to the list of log files that should be rotated by editing /etc/logrotate.d/rsyslog and adding /var/log/pdns.log to the list of log files (I typically add this line below /var/log/messages just before the opening { bracket):

/var/log/messages
/var/log/pdns.log
{

Finally restart rsyslog by running /etc/init.d/rsyslog restart

How to enable TRIM for SSDs in Debian 6.0 “Squeeze”

Modern SSDs support the TRIM command for long-term sustained performance. However for TRIM to work right, the OS (and file system) must have support for it. In the case of Linux, you’ll need kernel version 2.6.33 or newer, use ext4 as file system and also tell the kernel to use TRIM using the “discard” mount option.

By default the Debian installer tends to prefer ext3, so be sure to change this to ext4 on a fresh install. If you have already installed Debian on a SSD with ext3, you will need to convert it to ext4 – I will not cover this here.

Debian 6.0 includes kernel version 2.6.32 by default. To use a newer kernel you do not need to turn to the testing or even unstable (Wheezy) distributions; just enable the (official) Squeeze Backports by adding this line to /etc/apt/sources.list

deb http://backports.debian.org/debian-backports squeeze-backports main contrib non-free

Then run aptitude update to get the new package list. To upgrade to the latest kernel included with the backports that does support TRIM (2.6.39 at the time of writing) run:

aptitude install -t squeeze-backports linux-image-2.6-amd64

(change amd64 to i386 if you’re still running the 32-bit version of Debian)

To enable TRIM support then add the “discard” mount option to /etc/fstab: change the default “errors=remount-ro” into “errors=remount-ro,discard”. Reboot and you’re done.

Note! Do not add the “discard” option when your drive is formatted as ext3: not only will it not work, but it will prevent the OS from booting properly.

Go to Top