It's not possible? Says who?

Archive for September, 2009

AVM Fritz!Card USB and Linux – an odyssey

with 3 comments

I want to send and receive faxes and I have a AVM Fritz!Card USB (v1). For sending I could just hook it up to my Windows XP machine, but my XP machine isn’t running all the time. My only computer running 24/7 runs Linux (Ubuntu Server Edition 9.04).

So, how hard can it be?

Let’s see: AVM has a driver from Jul 07, 2005 for SuSE. I don’t use SuSE, but I think there have been some releases since 2005. Then I found a RPM from Oct 08, 2007 containing a few patches to the AVM version.

So I download the RPM, apply the patches, install kernel-headers for my current kernel and try to compile the glue code for this kernel module. And it fails. Surprise, surprise.

Apparently there have been some API changes, let’s try to address them. First I had to replace DECLARE_MUTEX_LOCK with DECLARE_COMPLETION. Then it complained about this line:

if (NULL == find_task_by_pid (thread_pid)) {

After some searching on Google I replaced it with:

if (NULL == find_task_by_pid_ns (thread_pid, 0)) {

It also complained about not finding the header file asm/semaphore.h, which I found in linux/semaphore.h.

Then there was a problem with several USB functions not working. Apparently somebody was (understandably) fed up with non-free modules using their GPL code, so some checks concerning MODULE_LICENSE were introduced. Of course there are some tricks around this, but almost nobody is comfortable to distribute a patch containing such silly shenanigans.

So now I have a kernel module I can’t redistribute, but it loads. And it still doesn’t work. capiinfo returns a lot of fields containing just 00000000. This can be tracked down to the use of strncpy instead of lib_strncpy in src/driver.c. After changing this I can finally send and receive faxes with capisuite.

Conclusion: Getting older hardware with out of date and non-free drivers to work under Linux is possible but very annoying and time consuming.

Written by johnLate

September 25th, 2009 at 3:12 pm

Posted in Uncategorized

Automatically mounting a USB HDD with udev

with one comment


I have an external USB hard disk. It’s permanently connected to a box running Ubuntu Server Edition 9.04. The only partition on the USB disk should be mounted automatically at system startup. However, if I just add the partition to /etc/fstab it doesn’t work. At the time the system tries to mount all partitions the USB HDD isn’t available yet. So I needed to delay the mounting of the partition until it becomes available.


I tell udev to mount the partition as it becomes available.

First I configure the partition in /etc/fstab:

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx    /media/external-usb-disk    ext3    noauto,noatime,errors=remount-ro    0    0

(replace “xxxxxxxx-xxxx-[…]” with your own, real UUID). I used mounting by UUID instead of device name to avoid problems when the name changes (e.g. due to another USB storage being connected). The noauto option prevents the system from automatically mounting the partition on system startup.

Then I create a new file in /etc/udev/rules.d/ called 80-external-usb-disk.rules:

ACTION=="add", ENV{DEVTYPE}=="partition", ENV{ID_FS_UUID}=="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", RUN+="/bin/mount -U $env{ID_FS_UUID}"

Finally, to tell udevd to reload the rule configuration:

sudo udevadm control --reload-rules

Now every time a new partition with the specified UUID is added, it is mounted.

Some Notes

I should have read /etc/udev/rules.d/README earlier. It says “Files should be named xx-descriptive-name.rules, […]”. At first my file didn’t have the “.rules” suffix – it took me some time to figure out why it was ignored. I don’t know whether 80 is a good priority for my rules file – but it works for me.

I could have told udev to assign special device names, like /dev/usbhdd and /dev/usbhdd1. But what for? I can identify the partition by the UUID, the mount point has a fixed name and usually you have symlinks under /dev/disk/by-uuid/ whose name won’t change.

Commandline to get some information about a device:

udevadm info --query=all --name=/dev/sdx1

Commandline to watch udev events live:

sudo udevadm monitor --environment

Written by johnLate

September 19th, 2009 at 5:04 pm

Posted in Uncategorized