Back Dat NAS Up

Things I have learned this weekend:

  • mysqldump is an important part of your backup workflow, but be sure to flush.
  • CRON WILLS IT, but only if you incant the ancient prayer with “-e“.
  • NFS root_squash is not a vegetable, but it can turn a capable man into one.
  • ZFS listens to xattr and ACL, but you probably haven’t heard of it.
  • cp can make hard links automatically, but don’t tell Chris Hansen.
  • backintime is the flux capacitor on the rsync DeLorean, but without the Libyan terrorists.

Plex Transcode, Vex Commode

What good is a streaming media server if it doesn’t stream media? No good, that’s what.

Some time after installing the Plex Media Center plugin on my FreeNAS file server, I tweaked some settings. One of those was “Transcoder temporary directory”, which I set to be some folder I created inside my Plex chroot jail. A few days later, after forgetting all this, I attempted to play some movie through the PlexWeb player, and the player just sat and spun forever. So I opened XBMC and attempted to play; that worked just fine. On a Windows machine, the Plex standalone player worked just fine, also — until I changed the streaming settings to disable Direct Play and Direct Stream and have Plex standalone request a lower bitrate (to go over my cable modem). Playback ceased to function. So, what gives?

Turns out, the transcoder was failing silently, so it wasn’t feeding any lower bitrates to either the Plex standalone or the PlexWeb player. So among the list of settings I was jabbing at I cleared the Transcoder Temporary Directory setting and boom the playback started working again. Huh? It took several minutes of digging into the jail chroot to figure out that the problem all along was a Unix file permissions issue — the folder that I had created through FreeNAS to store the temporary transcode files was owned by a user that wasn’t the Plex software’s user and by a group that the Plex software was not a member of, and the “other” permissions were read-only. Huh! So I chmodded the folder o+w and tried again. Success.

This simple fix was a slap to the forehead after monkeying around with settings for weeks, trying to find logfiles, restarting the jail, even reinstalling the Plex plugin in FreeNAS. It seems the obvious fixes are not so obvious to the oblivious.

Goodbye Evolution

I have a confession. I’ve stopped believing in Evolution. I don’t know how it happened, but it slowly evolved (or devolved) into one shitpile of an email/calendar/groupware application. The latest version packaged with Ubuntu is slower and buggier than ever. It will occasionally crash while using it (some of the controls in the configuration panel will crash it instantly on activation). While running in the background, idle, doing nothing, it will suddenly crash for no reason. As my friend Mike has joked, “They call it ‘Evolution’, because it’s not intelligently-designed.”

This stability problem is untenable. So I’ve decided to migrate to Thunderbird.

For some reason (documented on the dev wiki, I’m sure), Novell has decided to start using Maildir as the backing storage format for emails instead of the venerable mbox format. Maildir puts every message in its own file sorted by folder, whereas mbox stores all messages in a folder into one large file. The benefits of having thousands of small files is obvious if you consider how easy it would be to lose every message contained in an mbox file should it become corrupted. Novell included a conversion module to be run after the Evolution app upgrade that automatically converts the entire mbox store to Maildir. Since it leaves an archival copy of the mbox folders, this is not a problem…as long as you don’t receive any new mail for Evolution to pile into the Maildir folders.

Enter Thunderbird. It doesn’t natively support Maildir (yet), so it requires mbox for its local storage. Normally, I would just take the folder of mbox files and copy them over into the area used by the new mail client, but I can’t do that this time; can’t use the mbox archive without losing all of the mail collected into the Maildir folders since the upgrade back in June. So what to do? I thought about using some scripts to do the conversion, but most of the ones I found online wouldn’t handle the nested folder hierarchies of my emails. Next solution: use Evolution to push my entire mailstore, one folder at a time, up to an IMAP mail server, and then fetch it with Thunderbird. Well, that would swamp the server and take a while to chew through. Lots of hand-work.

Third solution? Set up a local (on this machine) mail server and copy my messages from there. Brilliant! Enter Dovecot, an email server that handles both IMAP (where mail is stored on the server and accessible from anywhere) and POP3 (where mail is fetched from the server by the email client and stored locally on disk). It natively supports different mail stores, is quick, highly configurable, and fits the job nicely. So here’s my migration path:

  1. In Evolution, make a backup of all emails into a tarball (likely named “evolution-backup-<date>.tar.gz”). At this point, stop using Evolution. Configure its email account settings it to leave mail on the server of all the email accounts it accesses. Wash your hands.
  2. Open the tarball and navigate down to “/.local/share/evolution/mail/”; pull out a copy of “local”, rename it “Maildir”, and drop it into your home folder (“/home/<username>/Maildir/”). This is where Dovecot will store your messages.
  3. Install Dovecot (you’ll need root or sudo privileges). It’s preferred to install the dovecot-imapd package since it comes preconfigured for IMAP support.
  4. in “/etc/dovecot/dovecot.conf”, uncomment “listen = *, ::” This tells Dovecot to listen to all network interfaces.
  5. in “/etc/dovecot/conf.d/10-mail.conf”, uncomment “mail_location =” and set the value to “~/Maildir”. This tells Dovecot that each user’s mail is in their home directory in the folder “Maildir”.
  6. restart Dovecot.
  7. Install Thunderbird and configure it to connect to the localhost server using your system username and password. Follow these instructions if you need handholding. Tell Thunderbird to subscribe to all of your mail folders if they’re not visible.

Some finagling later, and I got Thunderbird talking to and browsing all my mail. Success! And it was at this point that I had an epiphany. One of the problems I’ve had over the years is that all of my email (the stuff that wasn’t hosted on an IMAP server somewhere) is stored locally on my desktop’s disk and inaccessible from anything that wasn’t a mail client running on the system. This made it difficult to dig through old messages or check my POP3 mail if I wasn’t at home. So, why did I really need to copy everything from the “temporary” Dovecot server into the “local folders” of my email client? Why can’t I just, I dunno, actually keep using Dovecot as my own email server so I can access it from anywhere? Bully of an idea!

So what I’ve done is set up port forwarding on my home cable modem router to allow inbound connections on such-and-such a port to be routed internally to my desktop. With a little bit of work last night, I was able to install Thunderbird on my laptop and configure it to access emails, hosted in my house, at the cafe. Two birds, one stone.

The next step is to install something like fetchmail to periodically pull all of the mail sent to my POP3 boxes (I have several addresses across all my domains) and drop them into Dovecot’s inbox so I can check for new messages from anywhere.

This is all very rewarding for me. After some time mired in frustration, to have a project finish so successfully is a welcome bit of cheer. And cheer is what I need going into this next year. 2012 was alright, but it ended on a down note. Every day is a rollercoaster ride of neurochemicals and social currency, so any sort of positive news is like a sigh of relief. May 2013 be better for us all.

Roll Indie Fiftee Reap Air

Just so you know, I’ve been nerding out pretty hard this past week.

Last Monday, I picked up a very used Roland D-50 keyboard at the pawn shop. Although it was manufactured in 1987, it still output audio and the MIDI still works, but the poor thing has problems (I should’ve talked them down on price, but even still I got a decent deal). All of the keys on the fingerboard worked, but a few of the keys had screwed-up velocity sensitivity. The pitch bend was busted. And some of the panel buttons either don’t work or require a heavy push to get them to work. This poor piece of gear needed some serious TLC.

Knowing what I was up against, I made the due diligence to get some required tools to do the cleanup and minor repairs. Got some paint brushes for dusting, a wire brush to scrape any rust, some 91% rubbing alcohol (because 70% has too much water), and a can of electronic contact cleaner.

Within an evening I had it taken apart. The damned thing had spiderwebs and cat hair in it. No wonder it half worked. Last owner didn’t give a shit, and it shows. I got most of the crap out of the case in short time, but it took another evening to get the fingerboard completely disassembled, and I mean completely, like down to the frame. Pulled the keys off and soaked them in soapy water; they were as nasty as the bottom of a computer mouse.

It took a few evenings, but I got both circuit boards under the keys cleaned, got the rubber contacts wiped down, all the dust and “water damage” (to doctor the truth) are cleaned up. I found proof that the keyboard has been worked on before by someone who didn’t have the smarts or the tools to do the reworks correctly, and that probably accounts for one of the keys reporting full velocity on each press. I redid the rework; hopefully that fixes that.

Yesterday, I decided that I was tired of having sub-par tools to do electronics work. After having the pleasure of working with professional soldering equipment at work, my piss-poor Radio Shack iron just won’t do anymore, so I went to the electronics store and got a good Weller soldering station, a handful of different tips, a bottle of solder flux, a dispenser, and a cheap multimeter to replace the piece-of-shit I’ve had to use for the past 25 years. Nerding hard core.

This afternoon, I pulled the entire unit apart, taking the boards and cable assemblies off of the master frame. Took them to the balcony for dusting and a heavy session with the contact cleaner. Afterwards, more of the panel buttons went non-functional, so I spent part of this evening tracking down replacement parts. I desoldered and removed one of the switches, and I’ll take it to work tomorrow to get its exact dimensions with some proper measuring tools. If it matches the replacement switches I’ve found so far, I’ll be placing an order for an entire panel’s worth of buttons.

This is all very exciting!

Hopefully by next week’s end, I’ll have a fully-functional Roland D-50, refurbished and ready to go. And then the hard part will begin: writing music. D’oh!

Swap-o-Rama (¡UUID Es Me Llamo!)

(Just for the sake of remembering my own damn self — and maybe helping someone else.)

Earlier, I attempted to hibernate my desktop. Never done it in the 15 months I’ve had Ubuntu 8.04 LTS on here, so I figured “Hell, why not?” I hit the dropdown, and the system commenced its hibernating shutdown action. But it neither shut off nor came back to life. I ssh’d into it to discover via the system logfile that the hibernate was halfway through its operations when the power daemon discovered “Oh Hell! There’s no resume device on this machine!” at which point it ceased and attempted to raise the machine from the dead.

After manually power-cycling the system, I did some digging. Turns out the UUID of the swap/resume partition had been changed somewhere along the way, so both /etc/fstab and /etc/initramfs-tools/conf.d/resume were stuck with the old UUID from way back when the system was installed. That UUID no longer exists.

I’m not sure what caused it to change; such an idea is disturbing, considering this is supposed to be the super-stable, LTS build of Ubuntu. The UUID of the swap partition is usually set with the mkswap -U command, and can be set on an ext2/ext3 partition with the tune2fs command. But anything can go wrong.

So. How to make fix? A quick check with sudo blkid will list the block devices on the system:

oldman@Deskie:~$ sudo blkid
/dev/sda1: UUID="c97b2e80-a5b2-4371-a60e-126a8d1402a5" TYPE="ext3"
/dev/sda5: TYPE="swap" UUID="f3a3cd16-f0c8-40a1-8a7d-578c57296c6b"
/dev/sda6: UUID="775a56e3-0244-453f-8d8a-fd1eb42a82f6" /
SEC_TYPE="ext2" TYPE="ext3"

The swap partition has the UUID f3a3cd16-f0c8-40a1-8a7d-578c57296c6b and is the device /dev/sda5. Copy and paste the UUID into the fstab and resume config files to replace the UUID that was there. Execute sudo swapon -a to mount your swap partition, and you should be golden. Verify with free -m to check for a nonzero swap size.

oldman@Deskie:~$ free -m
             total       used       free     shared    buffers     cached
Mem:          3962       1784       2178          0        154        660
-/+ buffers/cache:        969       2993
Swap:        11601          0      11601

The value 11601 tells me I’m gettin’ my swap on. Aw yeah.