Enabling USB 3.0 in already existing Virtualbox VMs

Just a quick note on how to get USB 3.0 in Virtualbox for VMs that were created with USB 1.1 support only.

First, download VirtualBox Extension Pack from here.
Install it.
Then quit Virtualbox completely.
Go to your directory that contains your virtual machine and edit .vbox file.
Replace the whole <USBController> section with the following:

          <Controller name="xHCI" type="XHCI"/>

That’s it, let me know if it works for you !

Flattr this!

When life gives you temp space – make lemonade !

Some VPS providers, e.g. Azure (I know..) provide you with 2 disks for your VPSes. One, of very limited size, system disk, and the other one, spacy but with not guarantees that the data survives reboot. Basically it means that you can have a small VPS, with a small amount of RAM but large temp disk space. Why this could be useful ? Imagine tasks with lots of mem requirements but that not need to be extra fast, where swapping is allowed. Like complex nightly builds. Here is a set of super simple scripts I’ve come up with to quickly boot up a system, and then in the background add a new swap file on the temp drive there. The temp drive is assumed to be under /mnt.

root@someazurehost:~# cat /etc/rc.local
#!/bin/sh -e
set -v

# do not wait for swap to become online,
# proceed with the boot further, 
# with swap being created in the background
/etc/make_and_enable_swap &

exit 0
root@someazurehost:~# cat /etc/make_and_enable_swap
set -e
set -v
# create new 2GB swap file
dd if=/dev/zero of=/mnt/swap bs=1M count=2048
chmod 0600 /mnt/swap
mkswap /mnt/swap
swapon /mnt/swap

Don’t forget to make /etc/make_and_enable_swap executable !
Do not add this swap file to fstab, as it is being read before rc.local, and this may certainly result in a boot failure, as the swap file would not be ready yet.

Flattr this!

Containerized zombie spawner

Recently I was playing with a fully Dockerized setup of Jenkins at work and found a curious issue there. Whenever Jenkins was polling the git server the side effect was that it created a zombie ssh process. The issue is actually remediated by the Jenkins team now by explicitly using a tiny init system called … tini, started as the main container’s process instead of just starting Jenkins there. This tiny tini thing can properly adopt and reap the children. I was all like – wow, what a great blog entry is coming at me. I was planning to describe how zombies come to existence on Linux and why Docker should, in my opinion, provide an adopter-reaper by default and other very interesting things ! But then I found a really excellent article by the Phusion team here explaining all that and more. It is very good. You should read it. That is it. The end. Happy reaping !

Flattr this!

My CNC machining workflow

Hello !

Today we’ll talk about driving CNC machines, toolpaths and Debian, so stay tuned !

I have a separate old PC for driving the CNC machine via parallel port. This is, as they say, the Only Proper Way and It Was Always Like That. I’m thinking about changing this to usb+grbl in the future then 😉 Up till now, my workflow went as follows;

Do the research and drawing/parts modeling in FreeCad, on my main workstation
Export to e.g. DXF
Import in HeeksCad
Design machining operations, export gcode
Copy gcode to a network drive
Switch the monitor and keyboard to the one of the old PC
Open gcode in LinuxCNC and go

What happens if it’s not perfect at first try though ?! Most commonly the issue  is with the toolpath, like I want to change feeds or speeds or depth of cut, rarely it is with the part itself, fortunately. It may have something to do with the fact that I’m mostly working with other people’s parts for now 😉 Anyway, to do any correction I need to switch back to the main workstation, correct in Heeks, re-export to the network drive and switch back, reimport. Not very annoying but not very convenient either.

But wait. What if…I install Heeks on the old PC ?! It’s running LinuxCNC realtime distro, which is based on Debian wheezy. Heeks packages are available prepackaged for Ubuntu only. With the help of the documentation and the comments there and in other corners of the internet I was able to get this little script done:

set -e
set -v

sudo apt-get update
sudo apt-get -y install liboce-visualization-dev libwxgtk2.8-dev libgtkglext1-dev python-dev build-essential bzr git libboost-dev libboost-python-dev subversion debhelper cmake liboce-ocaf2 liboce-ocaf-dev oce-draw
mkdir heeks_build
cd heeks_build
svn checkout http://libarea.googlecode.com/svn/trunk/ libarea
cd libarea
dpkg-buildpackage -b -us -uc
cd ..
sudo dpkg -i libarea*.deb python-area*.deb
svn checkout http://heekscad.googlecode.com/svn/trunk/ heekscad
cd heekscad
dpkg-buildpackage -b -us -uc
cd ..
sudo dpkg -i *heeks*.deb
svn checkout http://heekscnc.googlecode.com/svn/trunk/ heekscnc
cd heekscnc
dpkg-buildpackage -b -us -uc
cd ..
git clone https://github.com/aewallin/opencamlib.git
cd opencamlib
bzr branch lp:~neomilium/opencamlib/packaging debian
dpkg-buildpackage -b -us -uc
cd ..
sudo dpkg -i python-ocl*.deb
sudo dpkg -i heekscnc*.deb

Run this on your LinuxCNC machine and that’s it. It will download and build all the dependencies and Heeks CAD and CAM packages.

This way, my current workflow goes more like this:

Do the research and drawing/parts modeling in FreeCad, on my main workstation
Export to e.g. DXF to a network drive
Switch the monitor and keyboard to the one of the old PC
Import in HeeksCad
Design machining operations, export gcode
Open gcode in LinuxCNC and go
Repeat last 2 steps if necessary - no machine switching

Flattr this!


Grafana + influxdb

TL;DR – go to data.cyplo.net

Some, rather long, time ago I’ve added a custom python-driven data acquisition and graphing to my sunpowered RaspberryPi installation on the balcony. Since then I’ve upgraded it to Raspi2 and ported the data thingy to influxdb + grafana.
All 3 of those things I am very positively surprised by.

RaspberryPi2 – definitely worth the upgrade – it’s a speed daemon now.  Small caveat – I recommend installing raspbian from scratch, especially if you had some custom overclocking config, as these do not seem to be compatible between 1 and 2. Also RasPi2 needs a microsd card instead of full-sized one.

As for the software – since everything went suprisingly smoothly this post is not much of a tutorial. Just go to influxdb and Grafana and go through the respective installation documentation. You need x86 64bit server to host this, so unfortunately no self-hosting on RaspberryPi – at least I wasn’t able to compile the software there.

I’ve changed the original python scripts slightly, to upload the data to influxdb instead of graphing directly via matplotlib. Then configured grafana to display some cool graphs and that was pretty much it – you can see the result at data.cyplo.net.

IMG_1291Right now I’m testing 2 different sizes of solar panels and batteries, hooked at the same time. The ADC is connected as it was before though, so a TODO is to add more measurements, to see how the individual  panels’ output change during the data and how does it affect each of the batteries.

Flattr this!


CNC router arrives

After 2 months of waiting – my CNC router arrives. 8 weeks lead time they said – 7 weeks and 4 days it was ! Who are they ? TanieCNC people [CheapCNC in Polish :]. Although it may look like they don’t know how to make websites AND their name does not instill a lot of confidence – but girl, they certainly know how to weld and make precise machinery !

The size of the package caught me off guard, I’ve spent an hour disassembling the crate in full sun. After that I wasn’t able to get it through the stairs myself, fortunately a friendly neighbour gave me their pair of hands. Lifting the machine by 2 people is okay, it’s still not lightweight, but bearable. Putting it on the table was a different affair entirely. Careful not to damage anything, especially the motor assemblies – we’ve put it on a improptu wood ramp. Using heavy duty straps, we’ve lifted it up little by little. Then some inspection – the quality is really superb, especially of the metal frame ! After that I got an old PC with Windows XP and parallel port running Mach3 software – I wanted to set it up as in any other shop at start. Later on I’m planning on moving to LinuxCNC and then gradually off parallel port on to a USB stack, something more like an arduino parsing gcode and driving motors instead of relying of the accurate timing of the PC.


  • add an MDF bed layer on top of existing bed
  • get better clamps
  • get more router bits
  • get a vacuum attachment for the spindle
  • move to LinuxCNC
  • move off parallel-port driving

Flattr this!

Tools: PCB holder

I thought it would be cool to share with you the tools I find surprisingly useful.

Behold the first in the series: the PCB holder !

I cannot overstate how much is that of a difference from the ‘third hand’-type of holders. The grip is very firm but won’t scratch the surface nor short anything because the jaws are made from a soft plastic.
And the whole thing ROTATES !

Flattr this!

Backing up and restoring whole block devices

SD cards are not really a reliable storage, especially when used constantly e.g. while sitting in always powered-on Raspberry Pi. Because of that I’ve recently needed to perform lots of backup/restore operations 😉

I wrote this script for backing up:


if [[ -z $1 ]]; then
    echo "usage: $0 device_to_clone"


timestamp=`date +%Y%m%d`

echo "about to clone $device to $dest_file"
echo "ctrl-c or [enter]"

sudo umount $device?
sudo umount $device

sudo sync
sudo pv -tpreb $device | dd bs=4M | pixz > $dest_file
sudo sync

And this one for restoring:


if [[ -z $1 ]] || [[ -z $2 ]]; then
    echo "usage: $0 restore_file.xz device_to_restore_to"

if [[ ! -f $source_file ]]; then
    echo "cannot open $source_file"


echo "about to restore $source_file onto $device"
echo "ctrl-c or [enter]"

sudo umount $device?
sudo umount $device

pv -tpreb $source_file | pixz -d | sudo dd bs=4M of=$device
sudo sync
sudo eject $device

Some of the more fun features include progressbars and making sure you’ve unmounted the device properly before 😉
This also uses parallel threads to deflate the data, so the XZ compression should not be a bottleneck on any modern machine.
The scripts above were used to backup and restore SD cards but will work for any block device, be it an external or internal disk drive, etc.

usage example [remember to use the whole device, not just its partition as an argument]:

./backup_sdcard /dev/sdc
about to clone /dev/sdc to /tmp/20150214.dd.xz
ctrl-c or [enter]

[sudo] password for cyryl:
umount: /dev/sdc1: not mounted
umount: /dev/sdc2: not mounted
umount: /dev/sdc: not mounted
19,6MiB 0:00:02 [9,72MiB/s] [>                                                                                                                                               ]  0% ETA 0:52:26

Flattr this!

Tilted to support 3D printer

Standing desk

It was some time since the last photo-story so, please accept these pictures of my standing desk.

On the actual desk, there is a laptop stand serving a role of a keyboard and mouse rest. Laptop itself is flipped on its back, motherboard attached to the back of what once was a lid. The whole thing is flying on standard monitor desk mount, using custom vesa-to-acrylic mounting system 😉

Flattr this!