PostgreSQL, Raspberry Pi, Debian: Locale issues

With the latest “Jessie” Wheezy Debian release on my relatively new R-Pi 2, I was in a hurry to replace my R-Pi original after it failed with a SD card error. Fortunately I was able to recover the config files from the original, as my backups were very much out of date. This system is mail dhcp, dns, mail and asterisk server and it didn’t take a huge amount of time to get everything back together (and faster, too!) but in my haste I did not configure the locale (or the filesystem expansion) in the GUI before I started installing things and got caught with a complaint from PostgreSQL when I tried to connect to the database that it was created with a locale (the default which is Great Britain) instead of the Canadian locale which I’d later configured it to.

Trying the easy stuff first, I removed PostgreSQL and re-installed it but no dice. What worked was the following.

  1. Change directory to /var/lib/postgresql
  2. Remove the 9.4 directory and all of its subdirectories and files with rm -rf 9.4
  3. Log in as user postgres.
  4. Initialize with initdb (I had to locate the executable as it wasn’t in the default path) with the path 9.4/main/ to recreate the master database (i.e. initdb -D 9.4/main/)
  5. Restart postgres

Voila! I am now able to connect.

Posted in Uncategorized | Tagged , | Leave a comment

Status of the Linux Ham Blog

Oh well. Best intentions and all that. Not about writing this blog. It was meant to be sporadic at best, but about using Linux in ham radio. Not that I’m totally devoid of Linux in the shack. I have a pair of Raspberry Pi that run Linux. One does all my household serving, including phone switch (Asterisk), email server (Postfix/Dovecot), DHCP (dnsmasq), NTP, DNS (dnsmasq), and a couple of other things that have slipped my mind. I might turn it into an Echolink/IRLP node as our club’s current ancient server is now singing with the choir eternal.

I’ve also acquired a Synology DSM1813+ which runs BusyBox Linux and have a bit of Python on it to manage my RSS feeds. It backs up my log database and keeps my archived stuff. The other Pi (model 2) is intended for use as an development environment for Atmel microprocessor projects. The build is still going on for that.

The main computer in the shack is Windows. I was already running it and there is just too much useful software that is Windows only. Some of my stuff runs on Linux, like WSJT-X and FLDIGI, but not all of it does, so there you have it. Stuck inside of Windows with the Linux blues again.

Back to writing this blog. All of my ham radio blogging is now over on the York Region Amateur Radio Club blog which is mostly written by me. It also has housekeeping stuff like meeting minutes but I try to keep interesting ham radio things in there. The blog took over from “Splatter” (a.k.a. the Splatter) which was the club newsletter. Since no-one wanted to edit it I decided that if I was going to be saddled with the task I’d make it easier and more fun and make it a blog. So if you want to read what I’m writing, I invite you to stop by.

By the way, right now and for the next 11 months I’m president of the Club like I’ve been for the past 2 years. So it is best that I support my club by writing for the common good. If someone takes over my position (as chief blogger, President, and web site maintainer) then I’ll be back here again.

Until then,

73 and good DX,

Chris VE3NRT

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Synology DS1813+ the scoop so far

So far, it’s been flawless. Since my original post on replacement I’ve added two more 4TB disk drives. They have worked perfectly so far and the system (including the UPS) has lived through several power failures that outlasted my UPS battery and resulted in a controlled shutdown. A nice surprise was that the DS1813+ plays flac files to both my Panasonic television and my Roku Soundbridge 100 despite neither of them having native support for flac.

I have enabled my home brew (Python) RSS video grabber to run nightly to bring down TED talks and other things. The problem I have with TED right now is that my Panasonic Viera TV won’t sort the DLNA video feed by date, and there doesn’t seem to be any way to tell what’s been watched before, so it’s hard to tell the old ones from the new ones. I’ll look for a way to add the date to the mp4 header. I’ve also been unable to figure out how to convert the Reuters RSS video feed (which is in h.263 format, associated with videoconferencing) to something watchable. It’s probably for the best as the feed is very low resolution (around 160×200).

My Raspberry Pi has been pressed into service as a phone switch (Asterisk with software G.729 support) and does mail, ntp, tftp, dhcp and dns services. The latter 2 are done with dnsmasq. It also does a modified version of Ned Batchelder’s green pixel web server which intercepts (thanks to dnsmasq) requests for and the like to just serve a single green pixel saving time and network bandwidth.

Anyway, the device works great, and while a bit on the expensive side make a wonderful home media server that requires a minimum of fuss – quite unlike my old laptop/usb drive based RAID 6 system.

Posted in RAID | Tagged | Leave a comment

G’bye RAID 6

Well yes, and no. My RAID 6 array, which has 8 two terabyte drives all on USB dual-docks, has been nothing but trouble. I finally decided it wasn’t going to work for me unless I used a server instead of the laptop host, so I’m in the process of ditching it.

I bought a nice new Synology DS1813+. It runs Linux under the covers, 8 storage bays, 4 gigabit Ethernet ports, additional USB (2 and 3) ports, and a couple of SATA 3 ports for expansion. So far it has run flawlessly, although I also sprang for 4 four terabyte NAS drives to go with it.

I’m now moving everything over to it from the old array, and have gone with RAID 5 + Full backup instead of RAID 6 + partial backup.

This brings to mind some truths about RAID. Here’s my view…

  1. RAID is mainly about availability, not reliability. If you want your system to be available 24 x 7, you have to do something about disk failures, and RAID is a solution for that.
  2. RAID protects against disk failure, not disk error. Disk errors can still happen so quality disk drives are still important.
  3. In the spectrum of possible bad things that can happen to your files, a disk failure is one of many.
  4. I’m very suspicious of USB controllers.
  5. RAID is no replacement for backup. I know this is what everybody says, but I don’t think it can be said too many times.
  6. A UPS is a very good thing to have (and I do). Most of my data corruption problems were directory files that got messed up after a power failure.


Posted in Linux | Tagged , , , , , | Leave a comment

Asterisk – AGI not working from IAX

This one took me a while to figure out, so I decided to share the solution to my pain.

I have two Asterisk systems connected by IAX2. One system is behind a corporate firewall and I didn’t want to open up the inbound port. So I have it registering and qualifying from behind the firewall to my other (home) system where I have the port open for inbound connections on port 4569 from the other system’s IP address.

The trouble began when trying to make a call from the home system to the corporate system. The well-tested AGI script, written in Python, exited without doing anything. That was surprising because right after I gather up the AGI variables at the beginning of the script, I modify Python’s error class to report exceptions through AGI. So if a run-time error occurs I always see it, as long as no errors occur when the module loads.  I just use the Python interpreter to test whether the AGI module loads OK which it did.

The problem turned out to be in the reading of the AGI variables. I had used the same logic that is provided in “Asterisk: The Future of IP Telephony” – an outdated but still very useful guide. The key was this line which splits the variable into its name and its value:

key,data = line.split(':')

My code was identical. However, there is a serious flaw in it. The channel variable was IAX2/>, where all the x’s represent my home IP address. Notice after the IP address there is an extra colon. That means that the split function will make 3 parts, not 2. Not only does this deliver a bad value, but also throws a ValueError: too many values to unpack exception. As this happened before I changed the error handler to report through AGI, it simply exits without saying anything.

The corrected code is

key,data = line.split(':',1)

This ensures that the text is split only at the first colon, and not at any others. Everything started working after I made this simple change.

Posted in Asterisk, Programming | Tagged , , , , | Leave a comment

A Curious Species of Spam

Recently I’ve been receiving pharma-spam that links to a site that’s been disabled.

Viagra 60 pills 75mg – $156.00 ($2.60 per item)
Prednisolone 120 pills 5mg – $24.00 ($0.20 per item)
Retin-A 5 tubes20g/0.05% – $88.25 ($17.65 per item)
Ventolin 2 inhalers 100mcg – $39.90 ($19.95 per item)
Amoxicillin 90 pills 250mg – $58.50 ($0.65 per item)
Benicar 120 pills 20mg – $130.80 ($1.09 per item)
100% Pure Okinawan Coral Calcium 1 bottle – $34.95 ($34.95 per item)
more info

Seems really stupid to be blasting out advertising for something that doesn’t exist, and because I follow up spam email by tracking down the source through the link I’m stumped on this one.

The email headers point to gmail addresses, so I tried to report this to Google. They advise to report spam to the US Federal Trade Commission, which isn’t realistic for someone living in Canada getting spam from who knows where. So when Google asked for feedback on the page, I rated it “Not at all helpful” and made my comments.

Unfortunately, Google replies “There were problems sending your form. Please try again.” Can’t Google take criticism?

Posted in Uncategorized | Tagged , , , , | 5 Comments

Echo AudioFire 12 – False Advertising? You be the judge

About a year ago I bought an Echo AudioFire 12. The reasons I bought it were as follows:

  1. It had 8 more ins and outs – in this case 12.
  2. Balanced audio
  3. Rack mountable
  4. 192KHz

#4 was mainly because of SDR, not my refined musical sensibilities – although I use it for both purposes. Little did I know that while Echo claims 192 KHz, and also claims Windows 7 support – it cannot do both at the same time!

The release notes for the latest driver say that 192KHz is no longer supported. Yet on their  product page it still claims 192KHz with no caveat. Is this fair? Is this deceptive?

You be the judge. As for me, I find this very disappointing.

Posted in Electronics, SDR | Tagged , , , , , | Leave a comment

A trap in mdadm

My storage array isn’t as robust as one might desire. It uses four two-bay SATA to USB docks, all hanging off a laptop. The laptop bit me by developing a stuck memory bit at around the 300MB mark. It always read zero and corrupted many a directory. Fortunately I didn’t lose a lot of files, and lost none that I wanted to keep. I replaced it with another laptop and the resolve to run regular memory tests on the thing.

Now I’ve got another problem. I decided to move from 6 drives to 8 (they’re all 2 TB), and thus had to do a reshape of the array. This requires removing the bitmap. The bitmap is good because if the array fails a good drive, it can be re-added easily. Without the bitmap a full resync/rebuild is required which on my array takes days.

The reshape was supposed to take about 9 days. Power failures – my nemesis – usually aren’t a huge problem because the rebuild picks up where it left off. However after about 5 days of rebuilding sure enough, even though it is winter where power failures are rare, the power went out for about 60 seconds.

I should have been more careful, but finding the array in a failed state, I rebooted the system. Unfortunately one of the docks didn’t come up with the rest. Because I run RAID 6 and all but 2 drives were available, the array restarted and the reshape operation continued with zero redundancy. With no bitmap, I can’t put the failed drives back in, and they have to be rebuilt. That can’t be done until the reshape is finished.

This all takes days and days. If a drive fails in the meantime, I lose the whole enchilada. I have my fingers crossed. There’s 25 minutes to go on the reshape, then I’ll see if the resync starts automatically, which I think it will.

I think mdadm should have a setting to require a minimum # of drives before it will start. I could have then set it to the full set during the reshape, or at least n-1 which would have been preferable to the unnecessary stress I’m under right now.

OK the array is rebuilding now. A little over 4 days from now I’ll know whether my data are safe once again. A week or so is a pretty long window for 6 drives, although the odds are with me. But those odds are 10:1 or 50:1, not the 100000:1 or thereabouts I’d expect with a fully functional RAID 6 array.

[4 days later] It finally finished and I am safe once again, with new knowledge to prevent potential tragedy in future. I added the write intent bitmap back in so power glitches won’t force another rebuild, and fsck reports the file system as clean which is a bit of a relief. The file system needed to be resized, and that took about 45 minutes and about 8% of the (800MHz dual core) CPU.

Posted in Linux | Tagged , , , , , , | Leave a comment

Email and the Art of Letter Writing

Over the last several weeks I have enjoyed several historical novels about Winston S. Churchill by Michael Dobbs and was inspired to read a biography of his youth (from 1874 to 1900) by his son Randolph S. Churchill. In it, there a many letters written by W.S.C., primarily to his mother.

I wish I’d taken note of the page on which appeared one letter bemoaning the deterioration in the art of writing letters which is put down to the increased speed of mail delivery, which in those times was much better than it is now. (There is a passage in one of Conan Doyle’s Sherlock Holmes novels entreating Watson, I believe, to put a letter in the morning post to ensure that it arrived on the same afternoon).

One could well imagine what Churchill would think of email, although if he could have used it against Hitler, I’m sure on the whole he would have approved of it heartily.

Posted in Operating | Tagged , , , , , , , , | Leave a comment

Com port emulation in Windows 7 64

A useful bit of free software for SDR afficionados is Com0Com (that’s a zero in the middle) which emulates 2 serial ports plugged into each other. Why do that? (you ask). Well when we’re using SDR part of the radio itself is in the computer. One of the challenges is that if you run your favourite digital mode program on the same computer you need to feed the audio that your SDR software produces back into the computer (which can be done with the well-know VAC, or virtual audio cable, or if you have plenty of sound card ports like me, with physical cables). The other challenge is you need a way to key the “transmitter”, which is a program inside your computer.

Most digital mode programs know how to use CAT or modem signals to key a transmitter, but as SDR software tends to want to be keyed the same way, you need to be able to connect the two programs with a physical serial ports, or at least fool Windows into thinking that’s what’s going on.

That’s where programs like Com0Com come in. With it, you can install a pair of virtual serial ports that are (virtually, of course) connected to each other. Then you tell the digital mode software to use one, the SDR software to use the other, and away you go!

Anyway, the reason I write this is that Windows 7 has a quirk (a feature, of course) that requires device drivers to be digital “signed” for security purposes. When a driver is not signed, then the only way you can get it to run is to put Windows 7 into a test mode, which unfortunately removes this security for everything, not just Com0Com. Not only does this compromise security but also an annoying message is forever affixed to the bottom right hand corner of the screen.

I found, though, that a thoughtful ham had used his personal certificate to sign the Com0Com driver, and has released it at

So if you need it, this one is better than alternatives from sourceforge and the like.


Posted in Windows | Tagged , , , , , | Leave a comment