Persistant enumeration of network interfaces across hardware addresses

If you’ve ever created a Linux virtual machine image for distribution, you have probably encountered this problem. The Virtualization is not really important – the problem exists on VirtualBox, VMWare, KVM, Xen and others supporting Linux guests.

So, what is the issue exactly?

The problem is that when you recreate a a virtual machine using an existing image, a new MAC address is generated. Udev sees this new address and creates a static name for it – e.g. eth1. Keeping the original – now removed – eth0 in the persistant naming file.

This interface typically does not exist in the /etc/network/interfaces file, and therefore is never “upped”. This leaves you with a machine that has no network connection out of the box.

Well, how do I fix it then?

The simple solution is to remove the /etc/udev/rules.d/70-persistent-net.rules file and reboot.
This means you have to remove the file as the last thing you do before shipping the image. I you make changes to the image, and reship it – you must do this every time. Plus it prevents easy redistribution of your image.

So, I’ve placed a small bash script at /usr/local/bin/reenumerate_interfaces and called it from /etc/rc.local.

This script also have the advantage, that you do not have to reboot the machine for the changes to take effect.

#! /bin/sh
 
echo Re-enumerating the network interfaces...
 
# Stop networking
/etc/init.d/networking stop
<pre lang="bash">
# Get the drivers and bounce the NICs
lspci -nnv | awk '{
if ($0 ~ /^$/) { getDriver = 0; }
if (getDriver == 0 && $0 ~ /.*Ethernet controller.*/) { getDriver=1; }
if (getDriver == 1 && $0 ~ /.*Kernel driver.*/) { printf ("%s\n", $5); }
}' | sort | uniq | while read a; do
 
echo Unloading network module $a from kernel space
rmmod $a
done
 
# Remove the static enumerations
rm /etc/udev/rules.d/70-persistent-net.rules
 
echo Reloading driver via udev
# Tickle udev
/sbin/udevadm trigger
 
# Start networking
/etc/init.d/networking start

SPARK toolkit

Last year I completed a report the SPARK toolkit. For those interested, I have now made it available for download.

Enjoy reading!

spark_overview.pdf

Modløsheden melder sig

Jeg har i sidste uge modtaget et nyt uddannelseskort – på trods af jeg ikke har bestilt det. Der er oprettet en betalingsaftale, så de trækker beløbet direkte – uden godkendelse.

Jeg har ingen forelæsninger i december måned, så jeg havde egentlig ikke nogen planer om at bestille et kort.

Efter sidste omgang har jeg simpelhen ikke mod på at prøve at få refunderet beløbet.

Thinkfan on a Lenovo T420

Warning: tampering with the fan control on you laptop is potentially dangerous, and I will not take any responsibility if anything happens to your machine. With that being said; I have used Thinkfan for various Thinkpads (7 I think) with no problems at all. Just be warned.

A lovely Lenovo T420 has recently dropped into my possession – not the worst thing that can happen. Well, actually it is a company laptop – but enough with the chit-chat.

Linux support on this machine is far from perfect, but one of the most annoying things about it, is the fan noise. It is constantly on at ~3500rpm and very noticeable (read: annoying).

First, install Thinkfan. (I owe my sanity to these developers!)

$ sudo aptitude install thinkfan

To enable fan control, the kernel acpi module must be enabled with explicit support.

$ sudo su -c "echo \"options thinkpad_acpi fan_control=1\" > /etc/modprobe.d/thinkfan.conf"

And reload the module.

$ sudo modprobe -rv thinkpad_acpi && sudo modprobe -v thinkpad_acpi

We also need the coretemp module, which is not autoloaded.

$ sudo modprobe -v coretemp

To make it autoload, append it to /etc/modules.

sudo su -c "echo \"coretemp\" >> /etc/modules"

Now, edit /etc/default/thinkfan to enable the thinkfan service to start. There are a lot of precautions here :-|

START=yes

Then, the following to /etc/thinkfan.conf, just after the comments – before the threshold declarations.

sensor /sys/devices/platform/coretemp.0/temp1_input
sensor /sys/devices/platform/coretemp.0/temp2_input
sensor /sys/devices/virtual/hwmon/hwmon0/temp1_input

Finally, start Thinkfan.

sudo /etc/init.d/thinkfan start

And.. Enjoy the silence :-)

Heads up for the people who led me to the solution:
[1] http://ubuntuforums.org/showthread.php?t=1749186#9
[2] http://thinkpad-wiki.org/Thinkfan

 

Malet op i et hjørne

Jeg har altid godt kunne lide at skille ting ad og finde fejl og mangler i systemer – indrømmet.

Og nu har jeg vist gjort det igen. Jeg har fået inde-klikket mig i et digitalt hjørne af www.uddannelseskort.dk systemet.

Hvordan så det? – Følg med, det er lidt indviklet.

Jeg har sidste gang jeg bestilte kort, fået bestilt to kort; et der løber fra 1/10 til 31/10, og et der løber fra 1/10 – 30/11. Det førstnævnte er godkendt hos DSB og betalt, det andet har fået “afvist” status i DSB’s ende.

Jeg kan ikke bestille et nyt via hjemmesiden, da en patching runde her i mandags (systemet siger det er Version: 4.4.1.g (18-10-2011)) angiveligvis har rettet fejlen med at man kan bestille overlappende kort. Dette betyder i praksis at jeg ikke kan bestille et kort til perioden 1/11 til 30/11, da dette kort har status “aktiv” hos uddannelseskort, og status “afvist” hos DSB.

Hvordan finder man så ud af det?

- Man ringer til DSB, sidder i kø, og får at vide aben ligger hos uddannelsesstyrelsen (som driver uddannelseskort). Så ringer man til uddannelsestyrelsen, sidder i kø, og får at vide at de intet kan gøre, men man derimod skal kontakte DSB.

Kan i se mønsteret?

DSB får andet opkald, og efter den obligatoriske kø, får jeg overtalt den rare DSB medarbejder til kontakte en specialist (hendes ord), for så kontakte mig igen.

Her ligger den så. Jeg ved ikke om jeg er købt eller solgt. Men for at historien ikke skal ende i meningsløs brok, har jeg desperat forsøgt at få henholdsvis uddannelsesstyrelsen og DSB til oplyse kontaktinformation for de drifts-eller udviklingsansvarlige. Det er selvfølgelig den samme mudderkastning; uddannelsesstyrelsen siger at det er DSB der driver hjemmesiden, og DSB siger det uddannelsesstyrelsen.

Whois siger det er uddannelsesstyren, så de fik min mail. Jeg syntes selv den er ret nøgternt formuleret:

 

 

Hej Uddannelseskortfolk

Nu har jeg gang på gang oplevet særheder/fejl med mituddannelseskort.dk
systemet (hjemmesiden).

Da jeg er klar over at i ikke har noget med det tekniske aspekt af
systemet, vil jeg gerne i kontakt med dem der har.

Det er ikke for at brokke mig, det er for at få afleveret min liste over
fejl og mangler – rent konstruktivt.

Det kan kun være i jeres interesse at få strømlinet systemet og rettet
fejl i det, da dette drastisk vil nedsætte antallet af henvendelser pr. dag.

Jeg har haft kontakt til DSB der har oplyst mig om at det ikke er dem,
men jer driver hjemmesiden.

Mvh
Kim Rostgaard Christensen
(Selvstændig IT-ingeniør, og studerende ved DTU)

Ada libusb-0.1 bindings (initial release)

The initial release of my Ada bindings for the generic USB library libusb. The bindings are done towards the old 0.1 library to provide maximum portability.

Bug reports are welcome. And, as always, use on your own risk.

Download here: ada-libusb_thin latest

Yet another goodbye

For those who are about to halt -p, we salute you.

I’m moving out – of my first vserver that is.

I have had the server running for, well

lucretia:~# uptime
 19:19:59 up 700 days, 22:51,  2 users,  load average: 0.02, 0.06, 0.02

Wow.. Time flies.

I have been migrating the services running in the machine to another, server. Not is the time to do the inevitable.

Sorry old chap, better you than me.

lucretia:~# halt -p

Broadcast message from root@lucretia (pts/1) (Fri Sep 30 19:23:24 2011):

The system is going down for system halt NOW!
lucretia:~# Connection to lucretia.greenpc.dk closed by remote host.
Connection to lucretia.greenpc.dk closed.

Of course, prior to this, I made sure to make a complete copy of the file system like so. Isn’t rsync the best tool?

rsync --progress -poazuHK -e ssh --delete --exclude /proc --exclude sys --exclude dev / home.greenpc.dk:/mnt/primary/backup/lucretia.greenpc.dk

Letting go

It pains me to let my N900 go. We have been together for almost two years now – but I have to move on.

I can still remember the unwrapping of the shiny Nokia box back in that gentle, fresh late-autumn morning back in November ’09.
Moving from a Sony Ericsson K800i, this was a large leap for me, and the N900 would be the phone that introduced me to the world of smartphones.

Suddenly I could do anything! I had a big screen where I could surf the high seas of the treacherous internet. And even with Flash content.
I was able to check anything, anywhere. I was king of information and technology.

As the N900 was build around my favourite Linux distribution; Debian, I felt right at home. A had a busybox and and xterm. This was not just a phone – it was a mini-computer with a built-in phone.

N900 and me hit it off – big time. We went everywhere together, did everything together.

Until…

I was appointed project manager of an Android programming project. I obviously needed a device for the development process (at least that was what I told myself).
For that purpose I bought a HTC Wildfire. This was the first step towards the end.

I could not help being drawn towards the much smoother interface of the HTC phone, despite the lower resolution on the Wildfire compared to the N900.

Suddenly my N900 did not seem so smart anymore. A lot the tasks that was difficult and hacky to do on the N900, was integrated in the to the user interface of the Wildfire.

Last week we broke up definitely. I found my new phone at a cheap Danish phone reseller, at lowered price.
Now I have a HTC Desire Z, because I would the Qwerty keyboard too much.

Still, I is  sad – to let a trusty life companion go.

Is ZFS overly hyped?

When ZFS first appeared, it was well received and praised.
The time was ripe for a modernization of file systems to eliminate the tedious task of having to plan and create volume groups.

My first experience with ZFS was when I was hired to build a NAS for a small business.
Initially, I chose to go the tradtional way and make the raid as a raid5. This took ages (about a day) to complete.
I therefore quite surprised when I saw the difference between creation time of a traditional raid5 and a raidz. The raidz was ready seconds after I had created it.

Also, when my server drowned ZFS helped my to salvage my data very easily .

So, what are the cool things about ZFS:

  • Creating raids take seconds insteads of hours (days)
  • It has filesystem level data integrity
  • Built-in snapshots that uses copy-on-write to preserve disk space. It’s like Apple’s Time machine – only on filesystem level
  • The L2ARC feature is brilliant. I have not yet had a chance to try it out yet though.

I know btrfs is said to be the upcoming zfs killer, but from what I have read, it still lacks most of the features that are fundamental for zfs now – and has been for some time.
The advantage of btrfs is that it has the potential of being a clean room implementation of zfs, addressing some of the design flaws that zfs has.

I’ve only seen the tip of the iceberg, and for all my usage it has proved itself more than worthy. I am still trying to convince a business partner to engage in a more bold and lager scale zfs implementation, but this is still in the idea stage.

The next step for file systems will probably be more from the userspace perspective. Modern computers, like the ipad requires a different filesystem layout – or none at all. The next evolutionary step for file systems will be metadata-driven, and storage will be a large pool distributed over different mediums, like cloud based storage.

The applicability of ZFS is enormous – and in my opinion the only thing holding people back is the lack of trust in the technology.
Even though, its technology as I like it best. Complexity made simple – with rich opportunity to dive into the sea of technical details. So to answer my own question; no, I don’t think

Endnu en ubrugelig valgprognose

Som tidligere omtalt byggede vi på min tidligere uddannelse et stemmesystem med det formål at stille entry- og exitpolls tilgængelig ved et lokalt valgmøde.

Valgmødet foregik i Nykøbing F. og var primært rettet mod unge under 18. Det var altså rent teoretisk.

Vi gjorde os dengang følgende observationer:

Resultat før mødet

Man kan tydeligt se en tendes til en højredrejning i prognosen baseret på stemmer indsamlet ved indgangen.
Til gengæld bliver billedet markant anderledes ved udgangen. Det skal bemærkes at stemmeterminalerne først blev aktiveret ved mødets afslutning, og derfor kun repræsenterer meningsfordelingen hos de “vælgere” der deltog i hele mødet.

Resultat efter mødet

Ud over at en stor del (ca. 50%) af deltagerne har forladt mødet viser tallene også at der nu er en kraftig venstreskæv fordeling – især til Enhedslisten der er gået markant frem.

Både Venstre og Socialdemokratiet er gået tilbage. Dansk Folkeparti er det parti der har lidt størst tab under mødet; ud af de 114 stemmer de fik ved indgangen, er 100 vælgere enten udvandret eller har skiftet mening.

Jeg syntes observationene er interessante, men de har jo intet at gøre med det forestående valg. Måske andre kan hive flere spændende konklusioner ud fra disse tal?

Til de kodeinteresserede kan serverdelen og kommandolinje klienten hentes her:

valgsystem.tar.gz