Automount a specific USB drive

Actually this is a straight forward thing, however since it has been a while I had to google it myself, and was astonished about how many non-working solutions I found, besides solutions that simply mount every USB according to their label. So here is the straight forward solution to mount a specific USB device to a specific location on your Unix hierarchical file system, using udev. It assumes that you have a running version of udev, and the udev tools. If not, please consult the distribution specific documentation on the Linux distribution of your choice. This might include recompiling your Kernel, as udev will need the following settings:

General setup --->
[*] Configure standard kernel features (expert users) --->
[ ] Enable deprecated sysfs features to support old userspace tools
[*] Enable signalfd() system call
Enable the block layer --->
[*] Block layer SG support v4
Networking support --->
Networking options --->
<*> Unix domain sockets
Device Drivers --->
Generic Driver Options --->
() path to uevent helper
[*] Maintain a devtmpfs filesystem to mount at /dev
File systems --->
[*] Inotify support for userspace
Pseudo filesystems --->
[*] /proc file system support
[*] sysfs file system support

As for Gentoo Linux, the other things you will want to do, is to add “udev” to your USE-flags (by adding it into your /etc/portage/make.conf), get udev installed (calling emerge -avuD sys-fs/udev), and add udev to your sysinit runlevel (rc-update add udev sysinit).

Now to the fun part. First of all you need to get some information about the device you are interested in. There are a number of ways, like using udev monitor, etc. Most of them, to me however, are too messy. If you have no idea about your device and still need to figure things out, blkid -o list will show you a nice table of all devices, their device file, file system type, label, mount point and UUID – everything you need. For me, I know I have a stick with the label “Public” on an OS X with file system type exFat, and now I inserted it into a dual boot Linux with a number of partitions:

ancalagon ~ # blkid -o list
device                            fs_type      label         mount point                           UUID
/dev/sdb1                         vfat                       /boot                                 58FB-332D
/dev/sdb2                         swap                       [SWAP]                                73db158f-0e19-4d17-8c88-a8b0c1dff1f3
/dev/sdb3                         ext4                       /home                                 355af6d8-6f03-4a98-9a45-edafc3ccedde
/dev/sdb4                         ext4                       /                                     63be67f3-5c7c-48ea-a8b3-58dff9da1737
/dev/sda1                         ntfs         Wiederherstellung (not mounted)                     562065062064EF05
/dev/sda2                         vfat                       (not mounted)                         6265-B138
/dev/sda4                         ntfs                       (not mounted)                         6C58731C5872E46C
/dev/sdc1                         exfat        Private       /media/private                        56B6-CE90
/dev/sdd1                         exfat        Public        (not mounted)                         56BE-6477
/dev/sda3                                                    (not mounted)

If you want more information, with the device file you can get it with:

ancalagon ~ # udevadm info /dev/sdd1

I want the stick to be mounted at /media/public, so I need to create a rule file; on Gentoo it lies under /etc/udev/rules.d/90-local-usb.rules. Actually the name is totally arbitrary, except for the number at the beginning, and the extension that always has to be .rules. The number should be something high, because we want udev to first run all other rules (e.g. the ones that assign the device to a device file) before running ours. 90 is a good value for that.

So in my case, this is what I added:

SUBSYSTEMS=="usb", ENV{ID_FS_UUID}=="56BE-6477", ACTION=="add", RUN+="/usr/bin/logger --tag udev Mounting public", RUN+="/bin/mount -o umask=0077,nosuid,uid=1000,gid=1001 '%E{DEVNAME}' /media/public"

We need to provide the system or subsystem, which for an USB device is usb. The UUID comes from blkid and identifies the device. The action triggers when to run the command. In our case, when a new USB device is added and it has the UUID we want. And finally the mount command. I’ve added another command such that there is a log entry but thta is no need. And as I want it to be accessible as user, I added uid and gid accordingly. If you need to find out your user and group id, just run:

ancalagon ~ # id -u 
ancalagon ~ # id -g 

And that’s it. If you want to see if the rule triggers, just run

ancalagon ~ # tail -f /var/log/everything/current

It should output:

[udev] Mounting public

somewhere. And you can <em>simulate</em> the USB event with udevadm, by triggering the rule you just wrote (although this is rather interesting for more general rules that should fit more than just one device). This is how it’s done:

ancalagon ~ # udevadm trigger --action="add" --property-match=ID_FS_UUID="56BE-6477"

El Capitan es una mierda

… or to put it in English: Mac OS X 10.11 – called „El Capitan“ sucks. Now while you won’t see much of the changes in your everyday life, if you are just an email, internet and office application user – once you drill down a bit, there are a huge bunch of problems.

First, and that is one that deeply annoys me: Photos. Before Yosemite there was iPhoto which was pretty neat already, with all the functions that a hobby photographer would enjoy – face recognition, tags, meta data information, a map pinpointing every photo you took (you could actually click on it and then click on the location and see all photos). It was great.
If you wanted more: Aperture was the power app – being basically like iPhoto, but allowing for more and specialized photo editing, support of multiple libraries, etc.

All that was gone with the last updates. Instead of iPhoto and Aperture, Apple decided to introduce Photos. It is basically the same app that runs on iPhone, and besides a minimum basic things it does not allow you to do anything. All the cool features from iPhoto and Aperture are missing. And while Photos might be great on an mobile device – on a laptop or stationary device this sucks. No album support, just the zoom in and out into a stream of photos, hardly any editing support, no batch support (I mean, wtf? You seriously believe that Aperture users will dig this?). But it get’s worse. While first applauding the simplicity and pointing out that now you only need to know one app, that works on all devices the same – with El Capitan they introduce new features, that distinguishes the OS X version from the mobile version again. And guess what. A few selected features that we knew from Photos and Aperture are now being sold as new innovative ideas. NOW you can filter your photos by location – seriously? Who the hell are you trying to kid, Apple?!

So the new features in El Capitan are – hold your hats – the ability to add and edit location information, to edit meta data in batches, and they re-introduced the sidebar with some „new“ features, including – finally – the ability to have third party editing plug-ins if you are not happy with the limited filters, Apple provide.

But actually I digress. I didn’t want to talk about Photos, and if you are interested in that, there is a tons of places on the net, where professional photographers that where content with iPhoto and Aperture express their feelings towards the new Photos.

Although I handle a lot of photos, that is just a hobby, and if there is some serious editing needed there are alternatives like Photoshop.

Continue reading

[Ruby] Equal is not always equal

The reason for this blog article is a question that dealt with the different ways of checking equality in Ruby, or more specifically the so called “threequals” operator method. You might have come across it, it is the three equals sign ===, a very Ruby specific thing. Even though everybody calls it operator, I think for the understanding it is crucial to be specific here – “threequals” is a method (of an object), not an operator. I stress this, as this is not true for other object oriented languages, such as Java, in which all infix operators (such as ==) are simply part of the language, i.e. their definition exists outside the object world.

After the before mentioned question I struggled myself of finding any good explanation of the different methods Ruby provides of comparing things, which is why I decided to write down the things I told him; and additionally place it into the context of all four methods, Ruby offers. Yes, there are four ways of comparison, which is twice as much as languages such as Java or Smalltalk offer (and think of C++ which just knows just the == comparison). To fully appreciate the differences, let me start of with the first and typical stumbling block, every novice programmer encounters: value equality vs. reference equality (skip this if you are familiar with the concept).

Continue reading

FATAL: modpost: GPL-incompatible module nvidia.ko uses GPL-only symbol ‘flush_workqueue’

I got the above error message after reinstalling my Gentoo Linux on a new harddrive. Untypical for a Gentoo distribution user I still fetch my Linux Kernel from the official website and compile it,

  1. because you get a Kernel unmeddled with by any distributor
  2. you have to compile it manually anyways (because genkernel sucks)
  3. because back in the old days, the Kernel sources where not in portage and therefore I am used to fetching it by hand

So my last Kernel was still a 4.0, while the new one now is a 4.2. I love Linux and distributions like Gentoo because they are text-based – I just copy and paste my configs and everything runs smoothly. Well – in theory.

The reallity of course often looks different. And this error is one example. It occurs for instance when you try to get the nVidia drivers on Gentoo with the current Kernel 4.2 – distribution independantly (as you can see here for instance).

So, when you look into the error and what’s causing it, it seems that in version 4.2 the Kernel developers assigned a different copyright license to the flush_workqueue function, i.e. usage allowed for GPL software only. And as the nVidia drivers are closed source…

Now there is an easy way to surpass this problem (see below), which would allow you to install the nVidia drivers anyway. However this would be a deliberate breach of the copyright license and would be at least rude to the developers.

Yet it seems like even the developers are not sure if that was a good idea – it rather looks like a refactoring error, that is probably being reversed any time from now. There is at least a message patching it for the unstable 4.3, and it was suggested as patch for 4.2-r5, but even in 4.2-rc8 this patch has not been included yet. So it’s now at least two months that neither nVidia nor the Linux Kernel have reacted to the problem; so either you downgrade the Kernel (which is a bunch of work), or simply patch it yourselfe 🙂 Even though one might argue that it is a license breech, I do not believe that it is the intention of Linux to render your machine useless (or give you extra work by downgrading) and it probably will be reversed soon – and if not, nVidia will react with a new driver version. Until then this workaround will allow you to use your nVidia graphics card with the Linux Kernel 4.2

You just need to open the file /usr/src/linux/kernel/workqueue.c in your favorite editor and search for the line


(in my Kernel sources it’s the linke 2617).

The extra _GPL part is responsible that the compilation crashes when the function is used in code that is not GPL licensed. So just delete it, so the line looks like this:


Now just recompile your Kernel. If you haven’t changed anything else, it should be suffice to call:

/usr/src/linux $ make clean && make && make install

and reboot your system. If you however have problems with modules afterwards (e.g. because you activated hashes for your modules so they don’t work with other Kernel builds), then do a

/usr/src/linux $ make modules_install

And there you go. Now your nVidia drivers should install and run smoothly.

On a side note:

Continue reading

Mercurial style aliases in git – and far more!

A cool thing that I really liked on mercurial and that I miss in git is the possibility of using shortcuts. Mercurial has them hard-wired. For instance, instead of typing hg status you could also type hg st or if you want to commit something: hg ci -m "Commit Message", which comes far handier than using hg commit and then waiting for the editor to start up and save the commit message file. There is also su for summary, and co for checkout. And this really saves you a lot of typing time, as these are the common tasks you want to use.

Git doesn’t come with that possibility, and while I wasn’t using it more often than Mercurial I didn’t bother to figure out how I could make git use some shortcuts. That’s of course possible, as Git is highly configurable. Now, I looked it up and I found out that there’s a highly sophisticated way of doing so.

Just open up your ~/.gitconfig. In it you will already find something like this. You’ve set this up for your first git usage – if you haven’t used git you’ll need to do it, otherwise git won’t work:

   name = Your Name
   email = youraddy@yourprovider.tld

What we’ll add is a new section, starting with [alias]

Now for each alias we want to set up, we write “alias = command”. So, this is basically exactly the way you would do your custom aliases in Mercurial if you ever did any. If you haven’t, for instance let’s get a shortcut for status:

  st = status
  name = Your Name
  email = youraddy@yourprovider.tld

We can even add flags, if we want. So if status is too chatty for you, try using the short flag:

  st = status -s

Now when calling git st you get something like:

A cli_ruby.bibtex
?? code/01_have_a_purpose/todo/

with A being a file added, D a file deleted, M for a modified file and ?? for untracked files. If you at any time prefer the chatty version for just this time, telling you how many commits your local HEAD is away from origin, and how to reverse changes, just use git status again.

Of course, the power comes, when using highly sophisticated commands that you cannot possibly type every time you want to use them. For instance, here’s a shortcut that not only sets the graph, abbrev-commit flags, but also sets date to relative and formats the message in a short and neat way and presents them in custom colors:

  st = status -s
  lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %Cblue<%an>%Creset' --abbrev-commit --date=relative

The above I found at Shawn Biddles git config. He’s really a great guy, you should visit his site and YouTube channel, as well as his dotfiles on GitHub – there’s a lot to learn. One great additional feature of aliases is that you can even execute shell scripts or use other aliases. One example:

You work with a team on a project and you only want to display your own commits in the log. One can achieve this by hardcoding the name into the alias:

  my = log --author='Your Name'

That’s handy, but if you want to share your config with friends, they will have to alter the config. And even you might have different users and want to keep it flexible. So instead you could use the git function to get certain lines of your config, and execute it inside your alias

  my = log --author="$(git config"

So that’s already neat, but let’s go further: Say you have different aliases that all need to use the current username, for instance you might want to get all the commits done by you today. Now you know a good programmer is a lazy programmer, so rather than retype “config” so many times, let’s use an alias for it:

  me = config

And now we can do:

  me = config
  my = log --author="`git me`"
  today = log --since=midnight --author="`git me`"
  yesterday = log --since=day.before.yesterday.midnight --until=midnight --author=`git me`

Pretty neat, huh?


This topic is so important that I will cover it in both, German and English. Please scroll down, for the English version. And there will be no tl;dr! If you are too lazy to read on something that important, but keep on using the Internet, you probably deserve to be hacked! Please pay special attention on what to do and what don’t to do, if you aren’t interested about my media critics part!

Es herrscht doch einige Verunsicherung bezogen auf die Schwachstelle, welche sich Heartbleed nennt. Was soll das überhaupt sein? Ich nutze diese Software – OpenSSL – garnicht! Ich muss jetzt SOFORT alle Passwörter ändern! etc.

Gerade die viel gelesene SPON zeigt mal wieder, was unsere Medien am besten können: Panik machen! Anstatt aufzuklären geht es um Verschwörungstheorien, Fingerzeigen und schwachsinnigen Aufforderungen. SPON sei hier nur exemplarisch zu nehmen – auch wenn die meiner Meinung nach den Vogel mal wieder vollends abschießen.

Das Problem

Warum Heartbleed potentiell jeden betrifft? OpenSSL ist ein sogenanntes Framework, d.h. es ist Software, die dafür gedacht ist, dass sie von anderer Software eingebunden wird. Dies wird gemacht, da es zum einen blödsinn ist, wenn jeder das Rad neu erfindet. Gerade bei Sicherheitssoftware ist das auch schwer möglich, denn mathematisch sichere Verfahren sind sehr kompliziert und die wenigsten Firmen haben das Know-How, dass für so etwas notwendig ist. Und so nutzen nach Schätzungen 2/3 der Webdienste OpenSSL für die sichere Übertragung von Daten. Deswegen ist tatsächlich so gut wie jeder betroffen.

Continue reading

SERIOUS: Update your iDevice and don’t use Safari!

In case you haven’t heard: There is a SERIOUS Bug in iOS/OS X, which is affecting SSL/TSL and basically rendering it ineffective. SSL/TSL is used to encrypt and protect data send via secure connections, e.g. using HTTPS to shop with Amazon, or for your online banking, or sending your passwords encrypted to the networks, e.g. Mail passwords, etc. You are especially vulnerable if you’re outside your secured network (e.g. office or home network), i.e. in a shared network, such as wireless hotspots, mobile network, etc.

Both iOS and OS X are affected, for iOS Apple has already released patches, and they even include the devices that are officially not supported anymore, i.e. 3GS and iPod Touch. For those devices you are to UPDATE to version 6.1.6, all newer devices are to UPDATE to version 7.0.6.

Unfortunately for OS X the patch is still developed, so here you’ll want to check your software status regularly and untill then DO NOT use the Safari browser. You’ll be fine using Firefox, Opera or Chrome, which offer their own implementation of SSL/TSL.

Other applications affected are:

  • Calendar
  • Facetime
  • Keynote
  • Twitter
  • Mail
  • iBooks
  • Software Update

Or to put it short: all Apple software (and third-party software using the Apple Security Framework) that provides ways to connect to servers. It should be relatively safe using these applications at home, but UNDER NO CIRCUMSTANCES should you use them in wireless networks that other people can use as well, i.e. anywhere outside your secured home network.

For more information also read the article Why Apples Huge Security Flaw is so Scary!