Category: Linux

My convoluted Subsonic server setup

By , 2016-05-15 21:23

Since ending my colo server plan, my Subsonic server hasn’t been running. I used to just have all my media synced to the Proxmox server I had in colo, then bind-mounted that folder to the OpenVZ container that was running Subsonic.

I’ve now moved my Proxmox/Subsonic server to a little Zotac ZBOX on my LAN that only has one local disk so I figured I wouldn’t sync all my music over locally when it could just directly access it from my new FreeNAS box. Turns out this is a little bit more complex than I thought – here are the steps I did to get it working:

  1. Get all music onto the FreeNAS box. For this I’m still using BTsync. One client is on my Mac, sharing my iTunes library, the other is in a FreeNAS jail.
  2. Install Subsonic in an LXC container on the Proxmox server.
  3. Create an NFS export on the FreeNAS server and mount it as storage on Proxmox. I just used the “Add storage” option in the Proxmox Web UI rather than adding it to fstab, because I was lazy.
  4. Configure the LXC bind mount. Essentially, in /etc/pve/104.conf :
     mp1: /mnt/pve/freenas,mp=/mnt/freenas
  5. Set up Subsonic to scan the /mnt/freenas/music folder.
  6. Realize that Subsonic has issues with non-ASCII characters in filenames. Fix it by adding “export LANG=en_CA.UTF-8” to the start script.
  7. Realize that Subsonic has no access to write to the NFS share, since the GIDs on the FreeNAS box and the Subsonic container don’t match. I use GID 500 = users as my main group on FreeNAS, so I created a group freenasusers with GID 500 in the Subsonic container and added the subsonic user to this group.

Probably missed some steps, but that’s the gist of it. I really need to get my blogging and documentation back on track.

Enabling DVD playback on Ubuntu 14.04

By , 2014-08-02 21:37

I don’t really play DVDs on my PCs much anymore, but my brother have me the full boxed set of Freaks and Geeks (great show, cancelled too soon). Running on a fresh install of Ubuntu 14.04, I popped in the DVD and was prompted by “Video Player” aka Totem to install some additional codecs. I obliged, but after the installation, the DVD still wouldn’t play. It turns out that because of legal issues, the libdvdcss2 library is no longer included in the Ubuntu repositories. However, the libdvdread4 package does provide a script to easily install it.

Once you have libdvdread4 installed, run following script:

# sudo /usr/share/doc/libdvdread4/

Restart your video player and enjoy your DVD.

Screenshot from 2014-08-03 01:35:17


By , 2014-07-31 15:32

I noticed that my workstation has been up essentially since I made my last blog post.
129 days and counting.

 $ uptime
 15:22:40 up 129 days,  2:41,  5 users,  load average: 1.88, 1.91, 1.93

This system also hasn’t been re-installed since November 2012. The initial install was done using the Ubuntu 12.10 “Quantal Quetzal” CD on November 20, 2012. I’ve since upgraded to every interim release – 13.04, 13.10 and now 14.04, and used a host of different desktop environments and window managers (currently using i3). The PC actually hasn’t been rebooted since installing 14.04; I only restarted X.

matt@work:/var/log/installer$ ls -l
total 1532
-rw------- 1 root   root   1303 Nov 20  2012 casper.log
-rw------- 1 root   root   3856 Nov 20  2012 debug
-rw-r--r-- 1 root   root 420116 Nov 20  2012 initial-status.gz
-rw-r--r-- 1 root   root     59 Nov 20  2012 media-info
-rw------- 1 root   root 747016 Nov 20  2012 partman
-rw------- 1 syslog adm  377562 Nov 20  2012 syslog
-rw------- 1 root   root     17 Nov 20  2012 version
matt@work:/var/log/installer$ sudo cat media-info 
Ubuntu 12.10 "Quantal Quetzal" - Release amd64 (20121017.5)



two-line bash script to extract all rars in a given folder

By , 2013-02-15 12:15

This script will find all .rar files in a given directory and extract them into the specified directory. Requires the unrar binary installed in PATH.

usage: [directory to scan] [extraction destination dir]

  • Running the script without arguments will search for all .rar files in the current directory and subdirectories and extract them all to the current working directory.
  • Running the script with only 1 argument will search for all .rar files in the specified directory and extract them into the same directory.
if [ "$#" -eq 0 ]; then dest=$1; else dest=$2; fi
find $1 -type f -iname "*.rar" -exec unrar e {} $dest \;


Atheros AR5005/5212, WPA encryption

By , 2012-11-07 22:08

I have a few old reliable AR5005G (5212, PCI 168c:0013) cards, both MiniPCI and Cardbus from the heyday of Wireless-G back in the early ’00s. Back then, Atheros 500x series cards were THE cards to have if you wanted to have some fun with aircrack, or if you just wanted your WiFi to actually WORK, especially under Linux. The madwifi (aka ath_pci) drivers were probably the most stable wireless drivers at the time. Even on Windows, you could use 3rd party drivers to put the cards in monitor mode and capture packets.

Times have changed and madwifi has been superseded by ath5k (and indirectly ath9k).

For some reason I decided to install Ubuntu 12.04 on an old Fujitsu Lifebook (Pentium III 600MHz, upgraded 512MB RAM, ATI Mobility Radeon M4) without built-in wireless, using a Netgear WPN511 Cardbus adapter. I expected everything to work as it did in the old days, but for some reason the WiFi wouldn’t stay connected.

It seems the hardware encryption capabilites on the card don’t quite support WPA2/CCMP-AES, even though the ath5k driver says it does. So the solution is to disable hardware encryption support:

echo "options ath5k nohwcrypt=1" | sudo tee /etc/modprobe.d/ath5k.conf

Then reboot, or reload the ath5k module (modprobe -rv ath5k, modprobe -v ath5k).

Now I can enjoy my surprisingly not-extremely-slow 10-year old laptop wirelessly.


Useful apt commands

By , 2012-10-29 14:46

apt-cache search [searchterm]

search local apt-cache for a package  containing [searchterm]

apt-file list [packagename]

lists all files associated with [packagename], even if the package is not installed

apt-file search [/path/to/file]

search for the package that “owns” [/path/to/file]

apt-cache madison [packagename]

displays all available versions of [packagename]

apt-get install [packagename]=[version]

force apt to install a specific version of a package

Automatic vpnc connection on DD-WRT

By , 2012-09-24 18:34

I sometimes have to work from home, which means using VPN. Cisco VPN works quite well, but it’s just not the same as being on the corp network.

Using a spare DD-WRT router (ASUS WL-520GU) running the VPN build of DD-WRT, I set up a persistent VPN connection. Now when I connect my work PC to this router, it behaves just like it’s on the corporate LAN.

How to do it

  1. First, get the recommended DD-WRT VPN build from and flash the router.
  2. Connect the VPN router’s WAN/Internet port to your home LAN.
  3. Make sure your router’s LAN IP doesn’t conflict with any subnets in the corp network or your existing home LAN. I used
  4. Add your corporate domains and DNS servers to the dnsmasq config (Services tab)
  5. Next, customize the script at the end of this post and paste in the Administration>Commands section. Click Save Startup.
  6. Reboot the router. Wait about 5 minutes (it takes a while to start up) and verify you can ping/access servers on the corp LAN.
  7. Done!

This isn’t exactly the most stable solution, but it works and I haven’t had any disconnects so far. Also much cheaper and much less trouble than setting up a site-to-site VPN using a real Cisco router.

One sticking point is that from now on any changes to router config (DHCP, WiFi, etc.) will require a reboot. Otherwise your VPN tunnel will die and won’t come back for some reason.

Also, speeds are limited by the router’s processor. Mine is only a 266MHz ARM, so IPsec puts quite a load on it, meaning I can only sustain speeds of about 2Mbps – sadly still better than some of our WAN sites that are using T1 lines.


mkdir /tmp/etc/vpnc
rm -f /tmp/etc/vpnc/
#Create the VPNC startup script in /tmp
echo '
vpn_concentrator="your.vpn.gateway" ##enter ip or hostname of your Ipsec vpn concentrator
vpn_keepalive_host1="some.server.corp"        ##enter the ip or hostname of a computer that is only reachable if vpn connection is established.
vpn_keepalive_host2="other.server.corp"        ##enter the ip or hostname of a computer that is only reachable if vpn connection is established.
vpn_groupname="groupname"  ##enter the group name here
vpn_grouppasswd="grouppass"   ##enter the group password here
vpn_username="user"       ##enter your username here
vpn_password="pass"        ##enter your password here

#--do not edit this--
#Written by Alain R. 28.Sep.2007
#updated by Matthieu Y. 2012-09-24
rm -f /tmp/etc/vpnc/vpn.conf
#Create vpnc config file
echo "
IPSec gateway $vpn_concentrator
IPSec ID $vpn_groupname
IPSec secret $vpn_grouppasswd
Xauth username $vpn_username
Xauth password $vpn_password
" >> /tmp/etc/vpnc/vpn.conf
# allow dnsmasq to forward dns replies for LAN subnets
sed -i "s/stop-dns-rebind//g" /tmp/dnsmasq.conf
killall dnsmasq
dnsmasq --conf-file=/tmp/dnsmasq.conf 
#Check if we can ping the IPs specified above
pingtest1 () {
 ping -q -c1 $param1 >> /dev/null
 if [ "$?" == "0" ]; then
       echo 0 #reachable 

	echo 1 #not reachable

pingtest2 () {
 ping -q -c2 $param2 >> /dev/null
 if [ "$?" == "0" ]; then
       echo 0 #reachable 

	echo 1 #not reachable

while [ $doloop==true ]; do

			if [ "`pingtest1`" == "0" ]; then
				sleep 300
				if [ "`pingtest2`" == "0" ]; then
					sleep 300
					vpnc /tmp/etc/vpnc/vpn.conf --dpd-idle 0
					sleep 1
					if [ "`pingtest1`" != "0" ]; then
						sleep 10
					tundev="`ifconfig |grep tun |cut -b 1-4`"
					iptables -A FORWARD -o $tundev -j ACCEPT
					iptables -A FORWARD -i $tundev -j ACCEPT
					iptables -t nat -A POSTROUTING -o $tundev -j MASQUERADE
					sleep 9

return 0;
' >> /tmp/etc/vpnc/
chmod 700 /tmp/etc/vpnc/




Enabling “swap” in an OpenVZ container

By , 2012-03-23 19:28

Oracle client for Linux for some reason requires 1GB of swap space, and will refuse to install, even if you have 9999999999TB of RAM, but 0 swap. Go figure.

Anyway, an OpenVZ container created with Proxmox will by default have 0 swap allocated, despite the Web UI allowing you to specify swap space.

In order to add swap to the container, from a shell prompt, run

On a somewhat related note, here’s how to install oracle client on Debian:

vzctl set 213 –swappages 262144 –save


Where 213 is your CTID, and 262144 is the amount of swappages you want. 1 page=4096 bytes , so 262144 = rougly 1024MB.

Also, Oracle installer detects 262144 swappages as 1023MB and change, so you will have to put something like 262200 instead.


ALSA: cannot find card ‘0’ when using USB sound card

By , 2012-02-24 10:16

I was trying to get my Alix board to properly output audio. It has no VGA and no onboard sound card, so I’m using a USB to audio adapater. The card was detected, all appropriate snd- modules loaded according to lsmod, and it showed up in /proc/asound/cards. Problem is it was card1, and alsamixer and most programs use card0 by default.

It seems that Debian configures snd-usb-audio in /etc/modprobe.d/alsa-base.conf with the index=2 option to prevent it from being the primary card. To disable this behaviour, simply comment out the line.


Original answer:

So are you using a USB sound card as your audio device?It looks like you might have removed some audio device from your computer, that is why card0 is missing, where as usb card is configured as card1.

Edit /etc/modprobe.d/alsa-base.conf, include/modify the line for snd-usb-audio

snd-usb-audio index=0

This would update snd-usb-audio to card0, in case you want that as the first card.

via Debian User Forums • View topic – ALSA: cannot find card ‘0’.

Missing shutdown button – lightdm-unity-greeter

By , 2012-02-02 15:13

Found the problem! Your log says ‘/usr/lib/indicators3/6/ does not exist.’ That file is part of the ‘indicator-session’ package, which provides the shutdown buttons for Unity and Lightdm.

via AUR en – lightdm-unity-greeter.

Custom theme by me. Based on Panorama by Themocracy

%d bloggers like this: