Rack PC Build - Part Two

Another rack-PC put together this week. Intel X99-chipset with LGA2011-3 CPU socket. Only PCI-e slots, no legacy PCI-slots.

Again I didn't get the polarity of the HDD-LED and Power-LED wires right on the first try. How come the industry cannot agree on a standard connector for the bundle that has the power-switch, reset-switch, HDD-LED, and Power-LED?

Another glitch was that this board has 8 slots for RAM, and the two RAM-sticks I got need to be installed exactly in the right slots - otherwise it won't even boot into the BIOS. Some reading of the motherboard manual was required.

After installing Ubuntu 14.04LTS (from USB-stick! No CD/DVD required) the NVIDIA-drivers (for the GTX750TI) were not automatically detected. I downloaded the latest driver from NVIDIA and installed it manually. This requires logging in to a text-only console (CTRL-ALT-F1), and then killing X for the duration of the install (sudo service lightdm stop)

NTP failure detection

Update: Here's how the graph looks like when NTP traffic is enabled again:

A computer that doesn't receive NTP traffic for a while will have its system time drift quite a lot.

In the absence of NTP (UDP port 123) traffic, we can try to roughly ask for the current time over HTTP using wget from google with this shell script:

/usr/bin/wget --no-cache -S -O /dev/null google.com 2>&1 | \
    /bin/sed -n -e '/ *Date: */ {' -e s///p -e q -e '}'

This outputs a string such as "Sat, 23 Nov 2013 09:14:45 GMT"

Now we can put together a python script that calls this shell script, converts the text-format time-stamp into UTC seconds, and compares against the system time. For plotting we then store the time-error in an RRDTool database. This script is called once per minute using cron.

import subprocess 
import time
import datetime
import rrdtool
import syslog
args = ['googletime.sh']
datetimestring = subprocess.check_output(args)
syslog.syslog( "googletime {0}".format(datetimestring))
# input: Sat, 23 Nov 2013 09:18:02 GMT
# output: 1385191082.0  (seconds since 1.1.1970)
timestamp = time.mktime( time.strptime(datetimestring, '%a, %d %b %Y %H:%M:%S GMT\n'))
# system time, e.g.: 1385191082.0
stime = time.mktime( time.gmtime() )
# should be zero, if all is well
terror = stime-timestamp
# store the measured error in a database
datastring = 'N:{0}'.format(str(terror)) # 'N:1234'
syslog.syslog( "rrd update: {0}".format(datastring) )
ret = rrdtool.updatev( "time_error.rrd" ,datastring)
syslog.syslog( "rrd updatev: {0}".format(ret) )

Once we have all the values in our time_error.rrd database we can plot them with rrdtool graph. This is what I get:
There is about -4 seconds of drift during 24 hours, or 46 us/s (46 ppm). If the drift is steady we can guess that the computer was on time 14/4 = ~4 days ago.

The script for creating the rrdtool database is this:

import rrdtool
import time
# DS:ds-name:GAUGE | COUNTER | DERIVE | ABSOLUTE:heartbeat:min:max
data_sources=[ 'DS:TERROR:GAUGE:70:U:U']
# RRA:AVERAGE | MIN | MAX | LAST:xff:steps:rows
utcsecs = int( time.time() )
pts_day= 24*60
primary = 'RRA:AVERAGE:0.5:1:{0}'.format(pts_day) # 2016 points
rrdtool.create( 'time_error.rrd',           # filename
                 '--start', str(utcsecs),   # when to start
                 '--step', '60',            # step between datapoints

And the graph is created by this script. I am using the simple python-rrdtool python bindings - the object-oriented python-pyrrd may have neater syntax and be more pythonic.

import rrdtool
import time
graphname = '/var/www/test.png'
day = 24*3600
span = 1*day
starttime = int(time.time()-span)
endtime = int( time.time() + 0.1*span)
updatestamp = time.strftime("%Y-%m-%d %H:%M:%S UTC", time.gmtime(time.time()))
graphtitle = ' System time - google.com time upated: '+updatestamp
rrdtool.graph(  graphname,
               '--start', str(starttime),
               '--vertical-label','Error (s)', 
               '--right-axis', '1:0',

Ubuntu 13.10 notes

Reinstalling Ubuntu on my laptop, a Lenovo IdeaPad Yoga 13".

Creating a bootable USB stick:

  • On another Ubuntu machine, use "Disks" from the menu to remove old partition, create a new one, and format a 1 GB stick
  • Use unetbootin to write the latest ISO from http://www.ubuntu.com/download to the stick

For some reason the driver support for this laptop is not that great. Wifi, bluetooth, screen brightness control do not work with standard Ubuntu. Amazingly the touch-screen does work - but I don't use it much. The wifi driver is an absolute must, since the machine does not have an Ethernet port.

Wifi driver fix:

git clone https://github.com/lwfinger/rtl8723au.git
cd rtl8723au/
sudo make install
sudo modprobe 8723au

Screen brightness fix:

  • Add the acpi_backlight=vendor to your grub default command line in /etc/default/grub, i.e. GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"
  • sudo update-grub
  • blacklist the ideapad_laptop by adding "blacklist ideapad_laptop" to your /etc/modprobe.d/blacklist.conf file.
  • sudo reboot

Useful packages and random tweaks:

  • git
  • build-essential
  • synaptic
  • indicator-multiload
  • flashplugin-installer
  • Firefox plugins: Tab Mix Plus (Why isn't multi-row tabs standard on Firefox?? I NEED about 8 rows of tabs!)
  • geany (simple text editor)
  • Privacy: from the menu "Privacy" then on the second tab turn OFF "record file and application usage"
  • filelight (see where all the diskspace went!)
  • vlc
  • stellarium (star map)

External sources

NTP to keep the system clock on time

  • sudo apt-get install ntp
  • add time1.mikes.fi and time2.mikes.fi to list of servers to /etc/ntp.conf
  • sudo service ntp restart
  • check that it is working: watch -n 2 ntpq -np

Reasons to still have a Virtualbox Win-7 install:

  • PADS schematic and PCB design - but I am trying to learn Kicad now
  • Wireless USB-stick based transfer of GPS data from my Garmin devices (I think this is doable in linux, I just haven't had the time to learn)
  • QuickRoute for plotting orienteering maps/GPS-data (I'ts a .NET application, so maybe would run under mono?)
  • Mechanical CAD applications. FreeCAD is on the way to become usable for serious stuff - but not yet...
  • NI Multisim for SPICE simulations. Is there a good alternative for linux?

Added Silence


Some silence has been added to the desktop machine:

I had a GeForce 9800gt graphics card previously with good performance but bad power-consumption and noise. The new Nvidia GT640 card should be similar-ish in performance but much less power-hungry and completely silent.

Raspberry Pi

Out of curiosity and with a couple of different projects in mind I have been playing with a Raspberry Pi (a cheap, small, but slow linux computer) lately. Some observations:

  • It's small, but it does require quite a few bulky connectors that connect to three different sides of the board. If you wanted to enclose the board and cables in a case the connectors add a significant amount to the footprint.
  • Who came up with the idea of offsetting the two USB-connectors so they extend out of the board? This makes all the cases for the Pi have a funny shape to get the Ethernet and USB connectors flush with the side of the case.
  • It seems to run the raspbian distribution OK. But for a standard debian-desktop it's very slow. There are optimized lightweight X-environments that are supposedly faster and more responsive.
  • Since it's an ARM processor, not every package I am used to using on Ubuntu/Debian is available from the repositories.
  • The modern way to interact with a gadget nowadays is a touchscreen. But there doesn't seem to be any good consensus on what touchscreen to use with the Pi. Could we have something budget-priced with good existing drivers for both screen and touch please. Perhaps use the DSI-connector so the gadget screen won't tie up other resources (USB, HDMI, SPI, or GPIO).

Overall this means my ideas for various real-time instruments & gadgets may be better served by an Atom ITX-sized motherboard. The atom is a standard x86 architecture that runs everything a desktop or laptop will run. It's fast enough to run modern desktop environments. And it has a PCI or PCIE slot for e.g. a Mesa FPGA card. Given the cost of enclosures, (touch)screens, FPGAs, and the analog electronics I have in mind, it really will not matter much if the cost of the motherboard+cpu combo is 40 euros (Pi) or 140 euros (Atom). Someone suggested I'd have a look at BeagleBoard or BeagleBone, but right now I'm leaning towards the Atom.

Ubuntu One is very slow

Update5: Day 4 and it looks like this: laptop 18078 items (5.5Gb), desktop 17803 items (5.5Gb). I wonder why the file-count differs?

Update4: Day 3 of this experiment. Machines have been online for more than 72 hours. In total 50Mb have been uploaded from laptop today (since reboot in the morning). That might be a good sign. All the files should now be in the "cloud". But are they synced to my other machines? Laptop still shows 18800+ files, desktop now shows 17800 files. Getting close...

Update3: Here's another observation, when the laptop, which still has about 11000 un-synced files in the One-folder, boots up, ubuntuone-syncdaemon can take 1-3 minutes of 100% cpu and about 300Mb RAM. After that it settles down, but 100% cpu means the machine is slow and unresponsive for a while 🙁

Update2: Someone at canonical asked for my log-files (they are in ~/.cache/ubuntuone/log/), and I've sent them. Hope they find what is going wrong!

Update1: the sync does seem coupled to a reboot. This morning it appears about 400Mb more was synced after a reboot of the machine. I still have about 11000 files un-synced after 48 hours.

These days data wants to be distributed and in the cloud. This image shows my Ubuntu One folders on three machines. They are supposed to be in sync, but are far from that after being connected to a high-speed network for more than 24 hours 🙁

OK, so let's go buy 20Gb of space on Ubuntu One, and transfer my working-set of work/hobbies/etc files there and see how it goes. I use about three computers regularly, a new laptop at work, and a  desktop and an old laptop at home. The work machine is on the university network where bandwidth shouldn't be a problem, and I have 40Mbit broadband from welho at home. What could possibly go wrong?

Ubunutu One is very very slow. I didn't just dump all my files and pictures into the shared-folder at once, I thought I'd start with a subset which happened to be 18064 files taking up 5.5Gb. It appears that in the first 24 hours roughly 700 Mb of data was synced. Now I have rebooted the primary laptop and it has very rapidly sent out another 500 Mb - but then slowed down to a creep. Is there a bandwidth-cap? For paying users?

Does anyone use Dropbox for lots (10s of thousands) of files? Does it work? Fast?

Quassel notes

To keep myself "forever" logged onto IRC, I wanted to run quassel-core on my isp shell-account, and quassel-client on whatever computer I am using at the moment (home/work/laptop, etc).

I first downloaded the statically linked core quasselcore-static-0.7.3.bz2 and unzipped it onto the server.

To use SSL, a certificate on the server is needed, made by copy/pasting from the quassel-wiki:

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout ~/.config/quassel-irc.org/quasselCert.pem -out ~/.config/quassel-irc.org/quasselCert.pem

Then, my ISP doesn't have the port open that quassel uses (4242), so the connection needs to be tunneled through SSH. For testing a 'local port forwarding' tunnel can be opened like this (this is run on the client machine):

ssh -lmy_user -L 4242:localhost:4242 my.remote.server

If I understand correctly this redirects traffic trying to connect to 4242:localhost through SSH (port 22), and actually connects to 4242:my.remote.server. However it isn't convenient to always have to type in the password when opening the tunnel, so I set up SSH login without password.

Now we can go ahead and start the server, under screen, so that it stays alive when I log out of the server shell. The server-side (quasselcore) needs no further configuration through the server shell.

CTRL-A - d (to detach screen)

Now we can connect with quassel-client, specifying 4242:localhost as the server. When doing this for the first time quassel-client will ask for some set-up data. It's possible to use an SQL server backend on the server-side, but I'm using SQLite.

Then I started googling for advice on how to automatically start and keep alive an SSH tunnel on Ubuntu. There seems to be no consensus on how this is best done, and two or three attempts I tried failed. Most seem to use autossh. Ry4an's blog suggests an upstart script (but I couln't get that to work, and it requires a special user with no password). Or should it be done with a script in /etc/network/if-up.d ? Since I only use the this SSH-tunnel with quassel-client, maybe the easiest solution is to create a launcher-script that first opens the SSH-tunnel, and then launches quassel-client (how do I kill the tunnel when quassel-client exits?). Suggestions? sshuttle?

For now quassel-core has been running OK on the server for a few hours, and everything seems to work. I'll be able to test connecting with more clients from home later... stay tuned.