Vorne weg: Schwedische ISPs ohne Verbindungsdaten

April 29th, 2009

Ausgerechnet in dem skandinavischen Land, das auch sonst den größten Widerstand gegen die feuchten Träume der Musik- und Filmindustrie leistet, unterlaufen die ISPs von sich aus das Gesetz, das Rechteinhabern den Zugriff auf Verbindungsdaten ermöglicht - sofern diese denn überhaupt gespeichert werden :D

Hierzulande gibt man sich unterdessen schon im vorauseilendem Gehorsam jeglichem Aktionismus bestimmter Politiker hin und implementiert sinnlose DNS-Sperren …

Politics , , , , ,

Home-Server: Music streaming with mpd and icecast2

March 2nd, 2009

Today I want to report on how I configured my home server so that it is able to stream music to my home network.

First of all, I installed the necessary software, i. e. mpd and icecast2 with aptitude install mpd icecast2.

mpd

Then, I configured mpd by editing /etc/mpd.conf as follows:

music_directory     "/var/lib/mpd/music"
playlist_directory  "/var/lib/mpd/playlists"
db_file         "/var/lib/mpd/tag_cache"
log_file        "/var/log/mpd/mpd.log"
error_file      "/var/log/mpd/errors.log"
pid_file        "/var/run/mpd/pid"

The first line sets the directory where mpd will look for music. I just used the default and created symlinks within that directory to my data folders containing my music collection.

state_file      "/var/lib/mpd/state"

This ensures that mpd will remember its state upon restart, so that e. g. the current playlist will be restored.

bind_to_address                 "any"
port                            "6600"

These lines will allow me to control mpd over the network. Later on, mpd clients will be configured to use the address of the server and this port to control mpd.

Now, the core option for streaming the music follows. Since I do not only want to hear music being locally restricted to the room the server resides, I chose an icecast2 server as output.

audio_output {
        type                    "shout"
        name                    "zeus"
        host                    "localhost"
        port                    "8000"
        mount                   "/mpd.ogg"
        password                "********"
        quality                 "8.0"
        format                  "44100:16:1"
}

This configures mpd to output played music in OGG vorbis format with a quality of 8.0 to a shoutcast-compatible server (i. e. icecast2 in this case) running on localhost, port 8000. The password here will also be set in icecast2, so that only we are allowed to output music to the icecast2 server.
The quality of 8.0 is quite high but for a local network bandwidth does not matter.

mixer_type                      "software"

With this option I told mpd to adjust volume not at hardware level but at software level since mpd does not output the music to a hardware device.

replaygain                      "track"
replaygain_preamp               "0"
volume_normalization            "yes"

These three options tell mpd to apply track replay gain so that each track shall have equal volume.

Now, we’ve configured mpd. At last, I created the necessary symlinks in /var/lib/mpd/music, e. g.

ln -s /path/to/my/music /var/lib/mpd/music/collection

Before we create the database for mpd and start the daemon, beware of one bug that’s not fixed in Ubuntu Intrepid’s version of mpd:
mpd will hang while scanning your music if there are .m4a files among them, especially if they are from Itunes. This bug is known and fixed in current mpd releases and therefore will surely be fixed in future Ubuntu versions.

I’ve solved this by setting the permissions of all .m4as in a way that does not allow mpd to read them, e. g.

find /path/to/music -iname "*.m4a" -exec chmod 600 {} \;

Since I am the owner of those files and mpd usually runs as user mpd this works quite well as a temporary fix, although those files cannot be played, of course, which might not suit everybody. So another option is re-encoding them, of course.

Then, I created mpd’s database:

/etc/init.d/mpd start-create-db

And restarted mpd, just to make sure the config is reloaded:

/etc/init.d/mpd restart

Next step is icecast2, then.

icecast2

For icecast2, I just used the default XML config file /etc/icecast2/icecast.xml and adjusted it as follows:

<clients>4</clients>
<sources>1</sources>

This restricts the number of clients to four (suits me) and the number of sources to one (the mpd).

<burst-on-connect>0</burst-on-connect>

This disables burst-on-connect which fills a the buffer of a client that plays the stream with an initial load of data. This reduces latency a bit.

<source-password>********</source-password>

Set to the same password as above.

<admin-password>********</admin-password>

Set to the password I’ll use for the web administration later on.

<hostname>hera.olymp.org</hostname>

The hostname of my home server.

At last, I set in /etc/default/icecast2:

ENABLE=true

and restarted icecast2:

/etc/init.d/icecast2 restart

Clients

As client for mpd I’m currently using sonata since I fancy it’s approach as light-weight client for mpd while still delivering very useful features like automatic cover art, artist info and lyrics as well as last.fm support.

sonata does not play the stream, though, so I still need to start, e. g. mplayer as client for the stream:

mplayer http://hera.olymp.org:8000/mpd.ogg

Sadly, I’ve found not yet a client that integrates controlling mpd and playing a stream concurrently.

Sources

I used these two howtos:

Linux, Music, Tips , , , , , , ,

Lösung linearer Kongruenzen mit nicht teilerfremden Moduln

February 16th, 2009

Bei meiner Klausurvorbereitung galt es u. a. Aufgaben mit Systemen linearer Kongruenzen zu lösen. Der Chinesische Restsatz liefert dabei ein Lösungsverfahren, sofern die Moduln teilerfremd sind, also  \textnormal{ggT}(m_i, m_j) = 1 \forall i,j; i \neq j gilt.

Doch wie löst man so ein System, wenn die Moduln nicht teilerfremd sind? Nach einer langwierigen Suche mit Google bin ich auf folgendes Verfahren gestoßen, dass ich jetzt einmal versuche zu formulieren und ein Beispiel zu geben.

Natürlich muss hier erst geprüft werden, ob es überhaupt eine Lösung gibt, da diese in diesem allgemeinen Fall nicht vorliegen muss (s. auch Wikipedia dazu). Man prüft also, ob für alle  i \neq j gilt:

a_i \equiv a_j \textnormal{mod ggT}(m_i, m_j)

Gegeben sei nun ein System linearer Kongruenzen mit nicht teilerfremden Moduln:

x \equiv a_1 (\textnormal{mod } m_1)
\dots
x \equiv a_k (\textnormal{mod } m_k)

Dann zerlegt man alle nicht teilerfremden  m_i, m_j und die zugehörigen Kongruenzen, so dass man äquivalente Kongruenzen erhält mit den zerlegten Moduln  m_{i_1}, \dots, m_{i_r}, m_{j_1}, \dots, m_{j_s} mit  m_i = m_{i_1} \cdot \dots \cdot m_{i_r} und  m_j = m_{j_1} \cdot \dots \cdot m_{j_s} und es gilt  \textnormal{ggT}(m_{i_k}, m_{j_l})=1 \lor \textnormal{ggT}(m_{i_k}, m_{j_l})=m_{i_k}=m_{j_l} \forall i,j; k = 1, \dots, r; l = 1, \dots, s .

Man erhält dann ein äquivalentes System linearer Kongruenzen, mit nun teilerfremden Moduln.

Ein Beispiel: Gegeben sei das System:

x \equiv 1 (\textnormal{mod } 6)
x \equiv 3 (\textnormal{mod } 14)
x \equiv 10 (\textnormal{mod } 21)

In diesem Beispiel sind alle Moduln nicht teilerfremd zueinander. Man stellt jetzt also das äquivalente System linearer Kongruenzen auf: Zunächst zerlegt man  m_1 = 2 \cdot 3 , womit sich die zu  x \equiv 1 (\textnormal{mod } 6) äquivalenten Kongruenzen  x \equiv 1 (\textnormal{mod } 2) (denn  1 \equiv 1 (\textnormal{mod }2) ) und  x \equiv 1 (\textnormal{mod } 3) (denn  1 \equiv 1 (\textnormal{mod }3) ) ergeben.
Für  m_2 = 2 \cdot 7 :  x \equiv 1 (\textnormal{mod } 2) (denn  3 \equiv 1 (\textnormal{mod }2) ) und  x \equiv 3 (\textnormal{mod } 7) (denn  3 \equiv 3 (\textnormal{mod }7) ).
Und letztlich für  m_3 = 3 \cdot 7 :  x \equiv 1 (\textnormal{mod } 3) (denn  10 \equiv 1 (\textnormal{mod }3) ) und  x \equiv 3 (\textnormal{mod } 7) (denn  10 \equiv 3 (\textnormal{mod }7) ).

Man erhält also (gleiche Kongruenzen müssen nur einmal betrachtet werden) das folgende äquivalente System linearer Kongruenzen:

x \equiv 1 (\textnormal{mod } 2)
x \equiv 1 (\textnormal{mod } 3)
x \equiv 3 (\textnormal{mod } 7)

Die Lösung kann nun mit dem Chinesischen Restsatz erfolgen und ergibt sich zu:

x = 1 \cdot 21 \cdot 1 + 1 \cdot 14 \cdot 2 + 3 \cdot 6 \cdot 6 = 157 \equiv 31 (\textnormal{mod }42)

Ich hoffe, mit diesem Artikel ein wenig Licht ins Dunkel gebracht zu haben, für den ein oder anderen, der auch das Internet nach diesem Verfahren durchstöbert :)

Update

In die Formel mit den zerlegten Moduln hat sich ein Fehler eingeschlichen: Natürlich können diese nicht alle teilerfremd zueinander sein, da dann auch die zusammegesetzten, ursprünglichen Moduln teilerfremd zueinander wären. Daher muss es dort richtig heißen (oben auch korrigiert):  \textnormal{ggT}(m_{i_k}, m_{j_l})=1 \lor \textnormal{ggT}(m_{i_k}, m_{j_l})=m_{i_k}=m_{j_l} \forall i,j; k = 1, \dots, r; l = 1, \dots, s .
Danke an Arne für den Hinweis :)

Science, Tips , , , , , , , , ,

Farewell, my harddisk …

February 14th, 2009

Yesterday, one of my harddisks waved goodbye as some irrecoverable, bad sectors occured.  Today I bought a replacement disk but to my pain my cleanly ordered cables in my new midi tower case were quite a mess after I replaced the disk. So it took me another full hour for reorganizing them, so that I’m satisfied again now.

The software part of the replacement did not cause so much work, the failed disk was part of an RAID-1 disk array, so I simply partitioned the new disk and added one of its partitions to the RAID with the following simple command:

mdadm --manage /dev/md? --add /dev/sd??

Reconstruction of the RAID was immediately started, and now everything is back up and running again.

I admit that I will never regret migrating all sensitive data to RAID-1s. It was quite expensive, sure, but harddisk crashes like this one are no longer a problem nor a cause for lost data. I really do like this comfort.

The next step was to check the warranty of the failed disk, and - lucky me - it got two months left. Actually, I found the process of creating an RMA (returning the drive for replacement by the manufacturer) has become quite easy in contrast to RMAs I had created some years ago. So hopefully, I will get a replacement disk within the next weeks …

Hardware, Personal , , , , ,

Home-Server Teil 3 - Nachtrag

February 13th, 2009

Ich hab es leider jetzt erst geschafft, die Bilder der im letzten Artikel zu diesem Projekt beschriebenen Änderungen von meiner Digicam zu ziehen.

Deshalb jetzt als Nachtrag die Bilder zu dem Artikel:

Hardware, Personal, Photo , , , ,

Cluster neu aufsetzen …

February 13th, 2009

Heute haben wir im Institut begonnen, den Cluster auf Ubuntu Hardy umzustellen. In den Monaten zuvor hatten wir zunächst sämtliche Software - Installation und Konfiguration (von System Imager, Compilern, Queueing-System, etc.) - auf einigen Knoten ausgetestet, der eigentliche Umstieg wurde dann aber auf später verschoben, um zunächst einem neuen Webserver den Vorzug zu geben. Anfang der Woche gab’s plötzlich die Weisung, doch den Cluster zu machen. Noch vor dem Urlaub von meinem Chef. Insofern alles stressig, und in nächster Zeit noch einige Tage im lauten Maschinensaal des Rechenzentrums einplanen …

Achja, und dazwischen auch noch mal Klausur ;). Vorlesungen sind ja zu Ende …

Personal, Trivia , , , ,

Projekt Home-Server - Teil 3

February 12th, 2009

Mein ehemals geplanter Home-Server ist nun schon einige Monate in Betrieb und dient mittlerweile als Datei-Server via Samba (CIFS) und NFS, sowie als Print-Server, Firewall und Router. Wie ich diese Dienste eingerichtet habe, plane ich in der nächsten Zeit hier zu berichten.

Neue Probleme

Doch zunächst galt es letzte Woche ein neues Problem zu umschiffen: Seit gut zwei Wochen gab der auf dem Chipsatz des D945GCLF2-Mainboards verbaute aktive Lüfter erst sporadisch, dann dauerhaft laute Geräusche von sich - vermutlich ein defektes Kugellager. Also den Alternate-Support per E-Mail kontaktiert (dort hatte ich das Board gekauft) und dies entsprechend reklamiert. Schnell bot man mir in einer Antwort die Rücksendung des Boards an, worauf dann der Fehler behoben werden könne. Da ich jedoch nicht mehr auf den Home-Server verzichten kann und auch nicht möchte, habe ich dies entsprechend angegeben. Erfreulicherweise war man daraufhin sofort bereit, mir lediglich einen neuen 40×40mm-Lüfter für den Chipsatz zuzuschicken. Dieser war auch am nächsten Tag da und seitdem werkelt ein Scythe Mini Kaze als aktiver Lüfter des Chipsatz-Kühlers auf dem Board.

Doch wie es das Schicksal so will (oder Murphy mir immer wieder antut), gaben wenige Tage später auch die beiden Gehäuse-Lüfter, die ich in der Zeit des nur noch sporadisch werkelnden Chipsatz-Lüfters reaktiviert hatte, den Geist auf. Also kurzerhand besagte Lüfter von Scythe auch als Ersatz für diese bestellt, ausgetauscht und endlich auch da Ruhe. Einziges Manko dort: Die beiden zuvor verbauten Gehäuselüfter waren zu einem 3-Pin-Molex-Anschluss zusammengedrahtet, einen der beiden neuen musste ich deshalb über einen entsprechenden Adapter direkt vom Netzteil mit Strom versorgen.

Seitdem ist die Geräuschentwicklung des Servers insgesamt deutlich gesunken, was sich hauptsächlich durch die Auswahl der Ersatzlüfter von Scythe begründen lässt. Diese werkeln mit 14 dB(A) deutlich leiser als viele der Mitbewerber, bei gleichzeitig guter Leistung.

Aufrüstung

Außerdem stand, nachdem die verbauten 1 TB Plattenplatz schon nach dem ersten “Betanken” mit Daten schnell erschöpft waren, eine Aufrüstung des Plattenplatzes an. Da mit dem RAID-1-Verbund der beiden 1-TB-Platten bereits alle SATA-Anschlüsse des D945GCLF2 in Benutzung sind, musste also eine SATA-PCI-Karte zur Erweiterung derselbigen her. Ich entschied mich dafür, den einzigen PCI-Steckplatz für diese zu opfern, da sämtliche von mir geplanten Multimedia-Erweiterungen des Servers sich auch gut mit USB-Komponenten realisieren lassen sollten, während ich einen Stapel externe Festplatten neben dem Server (noch) für nicht sehr schön halte ;)

Als PCI-SATA-Controller habe ich einen Wintech SAK-15 verbaut, da bei ihm zum einen der Preis stimmt, zum anderen er mit zwei SATA-I-Ports auch ausreichend Anschlüsse zur Verfügung stellt. Wichtig ist natürlich auch, das der verbaute VIA6421-Chip von Linux nativ unterstützt wird. Dazu gab’s dann noch zwei Samsung Spinpoint F1 (HDJ753LJ) mit je 750 GB Kapazität spendiert.

Beide werkeln wieder in einem RAID-1-Verbund. Der Controller wurde von Ubuntu anstandslos erkannt (Modul via_sata), das RAID war daher schnell eingerichtet.

Hardware, Linux, Personal , , , , , ,

Lunatica: New album

February 4th, 2009

Just found out that Lunatica will release a new album called “New Shores” at February, 27th.

Lunatica are a fantastic symphonic metal band from Switzerland I learned to like a lot during the past years.

On their homepage one cand find samples from their new album and I find them quite promising =)

Music, Trivia , , , ,

Encoding videos in 3gp format with Linux

February 4th, 2009

A few days ago I tried to convert videos I have on my computer to watch them with my mobile, a Samsung SGH-U900 Soul. Some quick tests with videos already encoded for I-Pods with MP4 just gave an “invalid format” error.

Searching the web I found that mobiles most commonly support a codec called 3gp as specified by the 3gpp, an organization that tries to standardize some aspects of mobile phones.

Further reading, especially this howto, revealed that videos of this type can quite easily be created with recent linux librarys and programs.

Running Gentoo with testing amd64 architecture, the following librarys and programs with the accompanying USE-flags are necessary:

  • media-video/ffmpeg [R 0.4.9_p20090201] USE: +amr +encode +x264
  • media-video/mplayer [R 1.0_rc2_p28450] USE: +encode +x264

Of course, additional USE-flags may be required depending on the source videos.

Then, this little script - e. g. saved as 3gp.sh - does the trick for me:

#!/bin/sh

die() {
  echo "Fatal: $1"
  exit -1
}

if [ "x$1" = "x" ]; then
  die "Video missing ..."
fi

if [ -f "./tmp.avi" ]; then
  die "./tmp.avi already exists ..."
fi

if [ -f "./audiodump.wav" ]; then
  die "./audiodump.wav already exists ..."
fi

gp_file=`echo "$1" | sed -e 's/\..\+$//'`.3gp

if [ -f "./$gp_file" ]; then
  die "./$gp_file already exists!"
fi

echo "$1 -> $gp_file"

mencoder "$1" -o ./tmp.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=160 -vf scale=176:-2,expand=176:144 -ofps 20 -nosound
mplayer -vo null -ao pcm -af resample=8000,volume=+4db:sc "$1"
ffmpeg -i ./tmp.avi -i audiodump.wav -b 160000 -ac 1 -ab 12200 -map 0.0 -map 1.0 "${gp_file}"
rm ./tmp.avi
rm ./audiodump.wav

Linux, Programming, Tips , , , , , , , , ,

Your security failed - twice

January 30th, 2009

Let alone Microsoft absolutely fails to provide a secure IE, their security guy now also fails in providing wrong statistics about it. Appearantly following the motto: “I only believe in statistics that I doctored myself.” At least I find it very amusing :D

Trivia , , , ,