Musicbrainz – Using picard

Picard, available here or maybe in the repository of your linux distribution (Arch Linux has it), is a great tool to tag your mp3-collection (if you don’t use beets), but it’s not very intuitive, so here are the instructions.

Click “Add Folder” to add a folder, oder “Add Files” to add single files. Most of the time they’ll show up under “Unmatched Files” on the left. Then select “Unmatched files” and click the button “Lookup”. Now Picard contacts musicbrainz.org and searches for the album.

After a while you should see the album name on the right pane. If you get an error that it couldn’t load the album information, fret not. Just hit CTRL-R until the error is gone.

Expand the album information. Now drag and drop the filenames from the left pane to their respective tracks on the right. Yes, there’s no other way to match the files! Once you’re done, click “Save” to tag.

If you want Picard to move and/or rename the files according to their track title and number, check Options -> Move Files and Options -> Rename Files. Select a destination folder in Options -> Options… -> File Naming, and a pattern in “Name files like this”.

The pattern controls how the files are named. I like this one for USB-Sticks (all in one line):

%albumartist% - %album%/$if($gt(%totaldiscs%,1),%discnumber%$num(%tracknumber%,2) - %title%, $num(%tracknumber%,2) - %title%)

Guess what it means 🙂

Telekom VDSL2 100/40

Bestellung und Auslieferung

Am 27.04.2016 habe ich via Internet Magenta Zuhause L bestellt (100/40 Mbit). Als Neukunde hat man sich geradezu rührend um mich gekümmert. Am 09.05.2016 wurde ich angerufen, um die Details der Installation abzuklären. War ganz gut so, denn aus den zahlreichen E-Mails habe ich nicht erkennen können, ob ein Techniker kommen muss oder nicht.

Es musste ein Techniker kommen. Das Zeitfenster war grandios: zwischen 8 und 16 Uhr. Allerdings hat er angerufen, bevor er losgefahren ist und angekündigt, dass er in 20 bis 30 Minuten vor Ort sei. So war es dann auch.

Als Erstes hat er ein Gerät an die TAE in der Wohnung angenöppelt, danach ging es in den Keller zum Hausanschluss. Dort hat er zwei Drähte rausgerupft und zwei andere aufgelegt. Wieder in der Wohnung hat der den Anschluss durchgemessen: 109Mbit/s Downstream. YEAH!

Das war Kundenservice par Exellence, muss ich sagen. Kann mich nicht beschweren!

Hartware

Da ich einen Router wollte, den man als Modem betreiben kann, habe ich den angebotenen Speedport-Trum nicht bestellt, da die Telekom den Modem-Modus aus der Firmware entfernt hat. Nach ein wenig F&E hat sich das Draytek Vigor 130 als Waffe der Wahl herausgestellt. Kostenpunkt: 103,92 € bei Amazon.

Laut Beschreibung vectoring-fähig, hat allerdings nur einen LAN-Anschluss. Egal, Karl. Hadante soll es routen 🙂

Voller Erwartung habe ich das Teil also angenöppelt und auf den Sync gewartet. Als er denn endlich da war, kam die große Enttäuschung: Lediglich 16Mbit/s, es sprach nur ADSL2+ 🙁 Also noch mehr F&E…

Dabei stellte sich heraus, dass ich eine spezielle Firmware benötige, damit das Teil VDSL spricht. Die bekommt man hier: Vigor130_v3.7.9_modem7.zip ist das Archiv der Wahl. Das ist die Version für G.Vectoring. Nach dem Firmware-Update hatte ich endlich die erwarteten 100/40 Mbit, Juchuu!

Modem-Betrieb

Um das Teil als Modem zu betreiben, muss man folgende Einstellungen vornehmen:

Internet Access -> General Setup
DSL Mode: Auto
VLAN Tag insertion (ADSL): Disable
VLAN Tag insertion (VDSL2): Enable
 Tag value: 7
 Priority: 0

PPPoE läuft auf VLAN 7, VLAN 8 ist IPTV, AFAIK. Abspeichern + Reboot des Modems. Dann:

Internet Access -> MPoA / Static or dynamic IP
MPoA (RFC1483/2684): Enable
Bridge Mode: "Enable Bridge Mode"

Abspeichern und obligatorischer Reboot des Modems. Danach darf man den “Roaring Penguin” bemühen.

Linux-Setup

Ich habe mir eine 1Gbit/s NIC von Intel gekauft: Die Intel EXPI9301CTBLK PRO1000 (Kernel Module e1000e). Die ist direkt mit dem Modem verbämselt. Wenn man den Benutzernamen unfallfrei zusammen klöppelt, ist der Rest ziemlich schmerzfrei. Der Benutzername lautet: <Anschlusskennung><Zugangsnummer>#0001@t-online.de. Die Daten stehen in den Einrichtungsunterlagen. Also:

# pppoe-setup

und die Daten eingeben. Danach

# pppoe-start

um zu testen, ob es funxioniert. Wenn ja, kann man den Service adsl aktivieren:

# pppoe-stop
# systemctl enable adsl
# systemctl start adsl

Um auch Pakete zu routen, muss die MTU für TCP komischerweise auf maximal 1382 festgetackert werden:

# iptables -t mangle -A POSTROUTING -o ppp0 -p tcp -m tcp \
--tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1382

Habe erstmal fertig. Das Policy Routing ist leider schwieriger als gedacht, und IPv6 mit wechselnden Prefixen ist mehr oder weniger nutzlos 🙁

Agents, systemd and More

How to start {gpg,ssh}-agent with systemd

To get rid of the convoluted and error prone start_agent function in .bashrc, just start ssh-agent and gpg-agent as user service with systemd. A big, fat warning before: Don’t even try to use gpg-agent as a replacement for ssh-agent! It’s so buggy that it won’t work!

To start the agents as user service, you have to create the following services in $HOME/.config/systemd/user (create the directory if it doesn’t exist):

gpg-agent.service:

[Unit]
Description=GnuPG private key agent
IgnoreOnIsolate=true

[Service]
Type=forking
ExecStart=/usr/bin/gpg-agent --daemon
Restart=on-abort

[Install]
WantedBy=default.target

ssh-agent.service:

[Unit]
Description=SSH key agent

[Service]
Type=forking
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
ExecStart=/usr/bin/ssh-agent -a $SSH_AUTH_SOCK

[Install]
WantedBy=default.target

Then enable them:

$ systemctl --user enable gpg-agent.service
$ systemctl --user enable ssh-agent.service

Now add

export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket"

to your .bashrc, .profile or whatever and re-login. If the agents linger (i. e. aren’t restarted), add the following entry in /etc/systemd/logind.conf:

KillUserProcesses=yes

and restart systemd-logind. This kills all processes started on login, including kdeinit4 and stuff. Warning: This may kill your current X-Session!

Now you have to ssh-add your key every time you log out, but you don’t have to kill all the KDE-cruft any more. There always is a tradeoff 🙂

SDDM and keyboard layouts

Creating a config snippet with localectl doesn’t work, but lo and behold, there’s a workaround. Just add

setxkbmap de,us nodeadkeys

to /usr/share/sddm/scripts/Xsetup

To change the X-Server layout, create a xorg.conf that does it right.

Restore KDE-Session

Well, that’s a problem. Most KDE-Apps remember their position, even their screen, but chromium does not. The closest thing to get it right:

  1. Go to System Settings -> Startup and Shutdown -> Desktop Session and set it to “Restore manually saved session”
  2. Place your programs and windows
  3. Save session
  4. Go to Startup and Shutdown -> Autostart and add chromium as command. Then edit Properties… -> Application and change the command to:
 chromium --disable-session-crashed-bubble --restore-last-session

This restores the last session without telling you that chromium crashed. Unfortunately, all windows appear on the current desktop, so you have to move them manually. AFAICT they keep their position, so defining keyboard shortcuts to move windows to another desktop, e. g. Meta-2 for desktop 2, makes this easy.

 

Hetzner – kVkm

How to get the vKVM console @Hetzner to work? It ain’t much of a surprise that it doesn’t work out of the box, because the advertised link directs you to a Java applet. That only displayed the header for me, on Linux and Windows 10. But fret not: there is a solution.

Fortunately, when vKVM is running, you can access it via SSH on Port 47772 with the given password. VNC should be listening on Port 47774, but it’s stunnled, so you can’t access it directly. QEMU-VNC is actually listening on Port 5901/tcp, so you have to tunnel you way in.

# ssh -L 5901:<remote_ip>:5901 -l root <remote_ip>

That should forward remote 5901/tcp to something you can access. Now run:

# vncviewer 127.0.0.1::5901

And no, the double colon is no typo! Now go, fix your problems and have fun!

IPv6 configuration Hetzner

(obsolete, superseded by https://tollana.d-tor.org/notes-to-self/?p=585)

Well, another issue I just noticed after the recent reboot of valhalla. When bridging, do never, ever use IPv6 autoconfiguration on the actual ethernet interface or the bridge itself. That will totally screw up the routing!

Disable it by adding the following lines somewhere in /etc/sysctl.d:

net.ipv6.conf.wan.use_tempaddr = 0 
net.ipv6.conf.wan.autoconf = 0 
net.ipv6.conf.br0.use_tempaddr = 0 
net.ipv6.conf.br0.autoconf = 0

You can change it directly by echoing the values to the respective proc files. Unfortunately, the changes only take effect after shutting down and taking the interface up again. So be really, really careful! Be warned: The interface won’t have an IPv6 address any more, so make sure that you have IPv4 connectivity!

You can do this with e.g. screen:

# screen
# ip link set down wan ; sleep 1; ip link set up wan

 

Kernel 4.4.1-2-ARCH and libvirtd

Well, well, well… What a fuckup! As of this writing [2016-03-03] the current versions of the Archlinux Kernel and libvirtd are not working at all. Took me almost a week to figure this out.

There are two issues:

  1. The Kernel package 4.4.1-2-ARCH (which is actually 4.4.3 with patches) crashes silently if you try to start a VM from libvirtd (if you even get so far, but that’s covered below). Honestly, I have no idea why, because it doesn’t sputter an OOPS. What I know: Downgrading to 4.3.3-3-ARCH fixes that issue.
  2. libvirt-1.3.2-1 is broken, or rather libvirtd.service is… It says that libvirtd is of type notify. That may be true, but it doesn’t work. Don’t even bother to fiddle around with polkit rules: It doesn’t work. IMHO polkit is over-engineered.

To fix (1.): Downgrade the Kernel to 4.3.3. If you don’t have a copy, download it here. Install it with:

# pacman -U linux-4.3.3-3-x86_64.pkg.tar.xz
# systemctl reboot

When the older kernel is running (confirm it with uname -a), we can fix (2.) by turning libvirtd.service from Type=notify to Type=simple. Be warned: It may have serious side effects! You’re on your own when you do this!

# cp /usr/lib/systemd/system/libvirtd.service /etc/systemd/system

Now edit /etc/systemd/system/libvirtd.service and comment out Type=notify. This turns libvirtd into a “simple” service, not forking, no authentication, nothing. Then reload everything and start libvirtd, virtlockd and virtlogd:

# systemctl daemon-reload
# systemctl start libvirtd virtlockd virtlogd

Finally (re-)start your virtual machines. Share and enjoy!

Mount partition from qcow2-image

It’s surprisingly easy if you have the right tools. That would be:

  • The kernel module nbd (Network Block Device)
  • qemu (specifically qemu-nbd)

To expose the whole image as /dev/nbd0:

# qemu-nbd -c /dev/nbd0 </path/to/qcow2>

If you only want a specific partition:

# qemu-nbd -c /dev/nbd0 -P 2 </path/to/qcow2>

gives you the 2nd Partition on /dev/nbd0. If it contains a valid filesystem, mount it with:

# mount /dev/nbd0 /mnt/point

To get rid of it:

  • Unmount it
  • kill the according qemu-nbd process

Share and enjoy!

Mail from systemd-timers

If you want to mail the output of a systemd-timer unit by redirecting STDOUT to /usr/bin/mail or something: forget it. For a long time SysAdmin used to good old crond it definitely doesn’t work as expected. As long as you redirect STDOUT in your script or program, you won’t get any output, because systemd redirects STDOUT to the journal by default. It’s documented behavior, you just have to read the fine print in man systemd.exec (StandardOutput=).

It’s rather counter-intuitive and has been discussed on systemd-devel, but in the end it’s “the right thing” ® to do. Systemd PID 1 should not care nor can it know where STDOUT is currently connected to.

So, how to work around it? Most likely your timer-thingy is a script wrapped in a service unit with Type=oneshot and ExecStart=/my/script. If so, just create a helper script that mails the output of journalctl -u <unit> –since today or something. Just don’t read the output of journalctl via a pipe!

My solution is a little perl script: mail-unit.pl

Just add StartExec=mail-unit.pl <my unit name> after your actual script.

Restore files from obnam

Well, well, well… Seems I just fucked up:

  1.  I should have remembered that tc can only control outoging traffic. So changing /etc/network-scripts/tc.sh for incoming rates was just stupid.
  2. I wrote the file to disk without keeping the original, working lines commented out.
  3. I didn’t remember the proper bandwidth values.

Fortunately, I keep an obnam-backup. To recover files from e.g. /etc, do the following:

# mount /dev/mapper/obnam-c /mnt/backup-obnam/
# obnam restore --to=/tmp/restore\
 --config=/home/am/.config/obnam/etc.conf

That restores all of /etc to /tmp/restore. Add a file or directory the end to only restore that file or directory, or leave out –to to restore in place.

Do not forget to umount /mnt/backup-obnam afterwards!

Another thing: If obnam complains about locking errors, do the following:

# mount /dev/mapper/obnam-c /mnt/backup-obnam/
# cd .config/obnam
# for i in *.conf ; do obnam force-lock --config $i ; echo $i ; done

Shit gebeurt 🙁