Just a quick hint when you experience corrupted data on your Synology NAS: make sure to use the newest DSM version available.

By “corrupt data”, I mean one or more of the following (rather easy to spot on image files):

Files of length zero (0 bytes) after copying to the Synology NAS

Incomplete copies (i.e. JPGs with only half of the image data present)

Corrupt data formats (i.e. Finder doesn’t show a preview or thumbnail of the file)

I just noticed this on my Lightroom archive (which sits on my NAS), and I could reproduce it consistently when copying a directory with about two hundred JPGs from my Mac to a network share on the NAS using either AFP or SMB – some of the files just appeared with a size of 0 bytes. Also, when importing images into my Lightroom archive (which is done via NFS), the import got stuck halfway and only showed about a third of the images imported.

I first suspected my recent upgrade to OS X Mavericks (10.9), but a fresh install with Snow Leopard (10.8) showed exactly the same. My wife’s Macbook Pro (also on 10.8) didn’t do any better, whereas my Windows 7 box had no trouble at all (and was almost twice as fast, but that’s another story).

It turned out that my Synology was still running DSM 4.3-3211, and an upgrade to the newest version (4.3-3827) did in fact fix the issue. So, three things to learn here:

Check the integrity of your file archives regardless of where they are stored (external disk, NAS, cloud backup, …)

In theory, the a digital camera, an Eye-Fi wireless SD card, and a Synology NAS running Photo Station, should be a terrific combination for quickly putting snapshots online without giving up control over the image files (like you would with flickr, 500px, and friends). One would only need to put together some kind of server software on the NAS that accepts new images taken with the Eye-Fi card and puts them right into Photo Station.

Seriously, how hard can it be?

DISCLAIMER: As always, I take no responsibility for anything that happens because you follow these instructions – but you probably knew that. This is by no means a secure, production-level setup, but just me playing with stuff. Messing with your NAS’s root filesystem, as described below, is always done at your own risk, and the eyefiserver2 python script is not guaranteed to be secured against attacks, either. Don’t blame me. For anything. Ever.

The idea of hosting your own Eye-Fi server without having your pictures transferred all over the internet is not new – and thanks to the work of Jeff Tchang, David Grant, and others, there’s a Python-based piece of Ey-Fi server software that is able to link with an Eye-Fi card and download JPGs straight from the camera to a directory of your choosing. Detailed information about eyeserver2 can be found at http://code.google.com/p/eyefiserver2/.

Installing eyefiserver2

To set up eyesfierver2 on you Synology NAS, you need to

Install and set up PhotoStation (if you haven’t already) via the Package Center

Install the Python 2.7 package via the Package Center

Enable SSH access and login as ‘root’ (same password as ‘admin’)

Download eyefiserver2-DEV.tar.gz, untar it, and copy the files to their locations in the Synology’s file system; or simply

You’re looking for a 12-digit hexadecimal number (the MAC address) and a 32-digit hexadecimal number (the upload key).

Edit /etc/eyefiserver.conf on the NAS to reflect the MAC address and upload key you just found out (mac_0 and upload_key_0, respectively). Don’t put any separators between the bytes of the MAC address, just 00deadbeef00 to represent 00:DE:AD:BE:EF:00 is fine. Also, change the dir, uid, gid, file mode, and dir mode as follows:

Reboot your NAS, and you should be set. When taking a new picture, you should see appropriate activity in /var/log/eyefiserver.log.

Indexing new pictures

With the above steps, new pictures recorded on your Eye-Fi SD card will be transferred directly into the ‘new’ directory of the ‘photo’ share on your NAS. However, they will not yet show up in a ‘new’ album on your PhotoStation, because the NAS hasn’t included them in the media index yet. Files transferred via CIFS/SMB or AFP are automatically added to the index, but files coming in via NFS or from a program running on the NAS itself (like eyefiserver) are not.

To fix this, add the following to /usr/local/bin/eyefiserver.py:

Somewhere among the import statements at the top of the file (e.g., around line 60), add

import subprocess

After the line reading os.chmod(imagePath, string.atoi(file_mode)) (somewhere around line 609), insert the following:

Now, whenever eyefiserver is writing an image file to disk, it calls synoindex to immediately add it to the index, which in turn makes it appear in PhotoStation as well.

You may also want to set up appropriate permissions within PhotoStation to the ‘new’ album.

A word on performance

Eyefiserver2 shouldn’t be a drain on your NAS performance at all – but adding images to the index could be. This is because the media indexing service on the DiskStation will automatically create thumbnails and preview-sized versions of your images, so that they can later display quickly within PhotoStation. In the short-term, this causes significant load on the NAS’s CPU.

On my web-facing DS112j, which is about the slowest DiskStation you can buy from Synology, adding a 12MP JPG to PhotoStation including indexing at “normal” quality, takes roughly a minute – enough for casual pictures taken during an afternoon with the kids at home. If you come home with a card loaded with several dozens of pictures from a day out at the zoo, be prepared to wait a bit until they appear on your PhotoStation. Of course, a higher-spec Synology will help there, too.

If indexing lots of image files slows down your DiskStation (e.g. when moving them from your PC or Mac over to PhotoStation), you might also want to have a look at Michael Medin’s article about creating thumbnails via NFS.

Well, not really, but still here’s the gist of how you can take a Raspberry Pi, hook it up to your network, and set up cacti on it to monitor your devices. I’ll even throw in some SNMP goodness for Synology DiskStations in the next post.

Actually, most of this post is a shameless copy from n00badmin (http://n00blab.com/cacti-pi/), with the SQL part moved from the Raspberry Pi to my Synology NAS, but more on that below. Make sure to visit his site on more Pi/cacti optimization goodness.

For those of you not in the know, cacti is a web front-end to rrdtool, which you can use to track any time-series data (network traffic, disk usage, CPU load, but also outside temperature, your power meter readings, or even stock market data) and draw pretty graphs like the one shown above. Further, a Raspberry Pi is a small form-factor computer designed by the Raspberry Pi foundation, mainly intended for educational use, but more than capable enough for running a webserver (provided you don’t want to serve too large an audience) or cacti, for that matter.

DISCLAIMER: As always, I take no responsibility for anything that happens because you follow these instructions – but you probably knew that. This is by no means a secure, production-level setup, but just me playing with stuff. Especially, you should take care not to enable SNMP access outside of your network, as Bad Things Can Happen(TM).

cacti (I use version 0.8.8b, others may work as well – will be downloaded in the steps below)

Some devices or data sources to monitor (I track the network stats of my router and a couple of Synology NASs, so far)

Setting up Raspbian on the Raspberry Pi

Raspbian is a Debian-derived linux distribution for the Pi, with the major benefit that it does include apt-get, so installing additional packages is a breeze. You can follow the official guide at raspberrypi.org to install Raspbian, but here’s the short version:

Hook up a monitor, mouse, and keyboard to your Raspberry Pi, stick in the SD card, network connection, and plug in the power

Choose to install Raspbian from the menu, and follow the on-screen instructions

Complete the Raspbian setup and login (username’s “pi”, you set the password during installation)

Installing cacti

The actual installation is covered pretty well by n00badmin (http://n00blab.com/cacti-pi/). Because I already have a MySQL server running as part of the official packages on my Synology NAS, I skipped the MySQL installation and configuration part and used phpMyAdmin on the Synology instead.

So, if you want to host your MySQL server on your Synology NAS as well, do this:

Enable WebStation and MySQL on your Synology NAS (sorry for the German):

Install phpMyAdmin on your Synology NAS to create the databases for cacti:

Login to phpMyAdmin (user ‘root’, no password) and change the password! Especially if you’re running web services on your Synology (like a Photo Station) that are accessible from the internet, as phpMyAdmin runs on the same web server.

You could additionally restrict access to phpMyAdmin to you local network, by adding

<Directory /var/services/web/phpMyAdmin>
Order Deny,Allow
Deny from all
Allow from 192.168.1.0/255.255.255.0
</Directory>

to /usr/syno/apache/conf/httpd.conf-user on your Synology (of course, you need to change 192.168.1.0 to your actual subnet).

Run the following command to confirm required php modules are present:

php -m

mysql (For configuration, see note below)SNMP (For configuration, see note below)XMLSessionSocketsLDAP (Required only when using LDAP authentication)GD (Required only for some Plugins)

Edit php.ini to point to extension directory found in:

cd /usr/lib/php5/

The name of the extension directory which will likely be a number/date ie 20090626 or 20100525+lfs depending on your distro. My Raspberry Pi had the following:

vi /etc/php5/apache2/php.ini

extension_dir = /usr/lib/php5/20100525+lfs/

Edit Apache2.conf to point to php.conf:

vi /etc/apache2/apache2.conf

Include conf.d/*.conf

Create php.conf:

cd /etc/apache2/conf.d/
vi php.conf

Paste this in the file:

# PHP is an HTML-embedded scripting language which attempts to make
# it easy for developers to write dynamically generated webpages.
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter to handle files with a .php extension.
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as
# directory indexes.
DirectoryIndex index.php

Set the appropriate permissions on cacti’s directories for graph/log generation. You should execute these commands from inside cacti’s directory to change the permissions.

shell> chown -R www-data rra/ log/

Add a line to your crontab file:

vi /etc/crontab

*/5 * * * * www-data php /var/www/cacti/poller.php > /dev/null 2>&1

Restart apache:

service apache2 restart

Point your web browser to http://your-server/cacti/. Use ifconfig if you are unsure of your Raspberry Pi’s IP address

Log in the with a username/password of admin. You will be required to change this password immediately. Make sure all of the path variables show found on the following screen.

At this point you should have an operational install up and running with the default localhost being monitored for basic system info. In order to gather more info including processor and interface traffic edit the following:

The most annoying thing about putting your Squeezebox into your bathroom is the fact that you need to manually turn it on or off. Wouldn’t it be awesome if your Squeezebox turned itself on when you switch on the light in the bathroom, and turn off when your leave and switch off the light?

Enter bathroomd, a hugely sophisticated quick hack which reads out your Squeezebox’s ambient light sensor and mutes the playback volume when the ambient brightness falls below a certain threshold, as well as turning the volume back up when the brightness rises above a (second) threshold.

I’m often wrongly accused of commended on appearing to own an example of every single Mac ever produced. The actual truth is, that, over time, I have accumulated a sizable zoo of Intel-based Macs, all running OS X 10.6 (Snow Leopard). And, with this week’s release of the latest iteration of Mac OS, Lion, I most certainly wanted to upgrade as many of these machines as possible, if only to have the same scrolling direction on all of them.

However, it appears that that’s not always as easy as Apple wants to make us believe. For example, I have a fairly recent 13,3″-MacBook Pro, which should be supported, but refuses all straightforward attempts to upgrade its operating system and just boots into the old one. Also, my (Lion-supported) media-center Mac mini crashed twice halfway into the upgrade process. To make things more complicated, my old 2006 MacBook Pro (featuring a 32-bit-only Core Duo processor) is not officially supported by Lion. In fact, it was only my Mac Pro that was fine with the “just download the Lion Installer through the App store and run it” approach.

In this post I’d like to share a number of different ways to install Lion that I found (mostly on the web) as solutions to very different installation problems.

The regular method

Usually, you just need to follow these steps to upgrade to Lion from Snow Leopard – which is the officially recommended way to get Lion onto your system and worth trying – you might be one of the lucky 99,5%:

Install Snow Leopard, if it’s not already there

Use Software Update to update to the latest version (10.6.8 as of this writing) – don’t forget to also install the update to the Migration Assistant; you might need it later

Launch the Mac App Store, buy and download the €23,99/$29.99 upgrade to Lion

Optionally, make a copy of the Lion installer (located in /Applications), since it will be deleted after the upgrade process

Run the Lion installer, and follow the (very few) instructions to upgrade.

Now, as I mentioned, this might not always work. My Mac mini, for instance, failed two times about a third into the installation process; however, after such a crashed installation, the installer will try again after a (forced or soft) reboot – and, alas, on the third attempt it went through. So be persistent.

If this doesn’t work though (or you don’t want to install Snow Leopard before installing Lion), you can try

The DVD or USB stick method

It actually is possible to create more-or-less-regular installation media from the Lion installer, which you can use to boot your Mac (e.g., after you just wrecked your hard drive). For this, you need to extract a disk image called ‘InstallESD.dmg’ from the Lion Installation app’s package (the image is located in the ‘Contents/SharedSupport’ directory – you did make a copy of the installer, right?), and either directly burn it to a DVD (using Disk Utility) or restore it to a 4GB+ USB stick (also using Disk Utility). Detailed instructions can be found here – they should reportedly work (but actually didn’t for me – give them a try, though).

Note that this should work either on an existing Snow Leopard install (I actually didn’t test that), but also allows you to first erase the target disk before installing a fresh and clean copy of Lion onto it (that’s what I finally did). There is, however, another way to do that (which doesn’t need any additional media but involves a FireWire cable):

The target-disk-mode method

My 2010 MacBook plainly refused to boot the Lion installation program – after running the Lion installer, it rebooted straight into the existing Snow Leopard instance. Trying to boot from a Lion installation DVD or USB stick didn’t work, either – though it booted into the installer alright, it didn’t go anywhere from there.

Target Disk Mode to the rescue!

What I finally did was hook up the notebook in target disk mode to another Mac already running Lion (though one with Snow Leopard should work as well). Here, again, it comes in handy if you saved the installer…

You enter target disk mode by holding down the ‘t’ key while (re)starting your Mac. It then effectively behaves like an external FireWire drive, which you then connect (using a FireWire cable) to the other Mac – the target-disk-mode’d Mac’s hard drive(s) should show up as external drives on the desktop.

Then, just run the Lion installer on that Mac and select the boot disk of your target-disk-mode’d Mac as the installation target. Your other Mac will reboot and complete the installation; I recommend to disconnect the FireWire cable after the second reboot and restart your previously-target-disk-mode’d Mac, which will then prompt you to setup the new Lion installation.

Finally, if you are stuck with an Intel-based Mac that isn’t officially supported by Lion (such as a MacBook, MacBook Pro, or Mac mini from 2006/early 2007 originially using a Core Duo or Core Solo CPU) that has been upgraded to a 64-bit CPU, there’s

The unsupported method

Actually, this is similar to the target-disk-mode method (or any other method where you don’t use the actual target Mac for installing Lion – think, for example, of installing to an external disk then used by another Mac). All you need to do is to delete the file ‘/System/Library/CoreServices/PlatformSupport.plist’ within the new installation before booting it on the target Mac. This disables the platform check performed by the operating system on boot. You still need a 64-bit-capable CPU, though – so this apples only to Core Solo / Core Duo Mac minis that have been upgraded by their owners with a Core 2 Duo CPU. My 2006 MacBook Pro is out of luck.

What we don’t know, however, is wether this will reliably work in the long run (e.g., with software updates) – Apple may actually have a reason why these machines are not officially supported…

Recovering a wrecked Lion installation

Once you’ve installed Lion at least once (or actually have one of those new MacBook Airs released alongside Lion), there are other methods to recover from a messed-up installation are described in this Apple support document.

Replacing a dead battery can be a costly exercise, especially with Apple laptops. Even those user-serviceable batteries feature a hefty price tag in the Apple store, and on-line merchants aren’t significantly cheaper, either. Add to that the blogosphere’s widespread opinion that Apple’s batteries tend to fail three and a half seconds (on average) after your warranty has run out, and the “rising energy costs” everybody is talking about quickly apply to your very own notebook.

Surprisingly (and here’s the actual informative content of this post), it is cheaper to get an appointment at your local Apple Store’s Genius Bar and have them swap in a replacement battery for you, than actually ordering one from the ‘net (or Apple’s own webstore) and doing it yourself. This, of course, requires that you live somewhere near an Apple Store, which in Germany (unlike the US) is rather unlikely, but it can save you about 25% compared to online prices.

Also, to delay having to drop money on a new battery at all, it might pay off to have a look at Apple’s battery calibration recommendations. I’ll give it a shot in the hope that this one survives more than 111 cylces.

The movie “Inception” seems to have gathered quite a following among the technology-affine crowd, similar to what happened when Matrix came out — which is not all that surprising since both movies have quite a bit in common.

Now, however, some very dedicated folks have implemented Inception’s plot as a multithreaded C application, where characters are represented by separate but interacting threads, sharing functions (the dream levels) but performing different actions within the dreams. Analogous to the movie, the code actually uses x86 code morphing techniques to “implant” modified instructions into the Fischer thread’s instruction stream.

This is crazy on so many levels. And to think that I already had trouble following the movie…

Working with complex reconfigurable SoC designs in Xilinx EDK can be a tedious process — especially, when you’re tweaking single VHDL source files of a single pcore, just to have all the pcores resynthesized by a twitchy makefile within the EDK build process.

To cut down on design turnaround times, we’ve written a simple Python script called xstcache, which does the same what ccache does for C sources. It looks at the input files, synthesis parameters and the environment, and, if the same combination has been used for a previous synthesis run, re-uses the result (the netlist) of that synthesis iteration without actually running XST.

For typical EDK projects, this reduces the time for the syntesis step considerably, as most pcore sources do not change between synthesis iterations.