Whoopsie & how to disable it on Ubuntu 12.04 or Mint 13

New in Ubuntu 12.04 is whoopsie – which sends a crash log to ubuntu. Nice feature? Well no as they don’t tell you about it nor to they ask you, they just do it.

Nice privacy issue guys.

To tell if you have it check the file /etc/default/whoopsie

[General]
report_crashes=true

If you see that then it’s enabled. You’ll also see a process running called whoopsie as well.

To turn it off just change it from true to false & kill the whoopsie process (or reboot).

Note this affects any distribution based on Ubuntu 12.04 including Mint 13 so check you are not infected by whoopsie.

Getting a ubuntu clone in VirtualBox to connect to the network

I’ve spent a large amount of time today trying to get cloning working within Virtual Box with a copy of Ubuntu 12.04 server with limited success.

Now by default a VM is set to use NAT for it’s network interfaces but I needed bridging and this causes a problem – when the clone starts it comes up with no ethernet interfaces, even though the original vm works fine.

In the end it appears to be udev thats causing the problem. The clone gets a new mac address (correctly) but udev knows the original mac address so disables eth0 hence no networking.

The fix is simple – tell udev to bugger off:

$ sudo rm /etc/udev/rules.d/70-persistent-net.rules
$ sudo mkdir /etc/udev/rules.d/70-persisitent-net.rules

Reboot and you should find the network interface reappear. Do this on the original vm and all your clones will work first time.

It’s a bit of a hack but it works – the mkdir simply prevents udev from recreating the rules on startup.

Using the full space on your SD card in the Raspberry PI

If you got your Raspberry PI from RS like I did I also ordered both a power supply & an SD card. Now you’ll probably find that you got a 4GB card. The problem is that the Debian image that you can download for the pi only uses 2GB of it, so you will find that you’ll run out of space pretty quickly. This article shows how you can allocate the remainder of the card so it’s available for use.

You do this at your own risk. Make sure you have backed up everything you need before doing this.

Now there is a good video tutorial on YouTube by RaspberryPiTutorials which shows one method of resizing the image. Now this is fine although it does go through hoops using a VM etc but what about from the pi itself?

Well here I’m not going to resize the root partition. What I’m going to do is to create a new partition using up the remainder of the space and move /home to that new partition.

The benefit of this is that you are freeing up the root partition for just the OS and the remainder of the card for user files.

Finally sorry for the lack of images here, I ran though this prior to writing it & forgot to capture them as I went 😦

Creating the new partition

First log into the pi:

peter@somehost:~$ ssh -Y pi@raspberrypi

Remember from a previous article, the -Y allows the pi to use your local X11 display.

Next we need to run gparted:

pi@raspberrypi:~$ gksudo gparted

You should now see a display with the partitions displayed and a large unallocated section to the right in grey. Select that unallocated space right click and select new.

In that dialog you’ll see aot of boxes. The main two you want are the first one (top left) which says space before the partition, it will show 0 but you need to change it to 1. This follows the layout of the other partitions which have a 1Mb buffer between each partition.

The other one is the file system dropdown. I chose ext4 as thats the same as the root.

Apply these and you should then see the partition is now marked as allocated.

Click on apply. This now applies your changes.

Next right click the new partition, select format to and choose ext4.

Now make a cup of coffee – as it will run for a few minutes as it formats the new drive.

Once it’s done you can close gparted.

Moving home to the new partition

Now at the command line you need to mount the new partition so you can copy your home directories.

pi@raspberrypi:~$ sudo vi /etc/fstab

And add the following to the end of the file:

/dev/mmcblk0p4  /mnt  ext4  defaults  0 0

Save that and exit vi then mount the drive. You should then see the new drive present.

pi@raspberrypi:~$ sudo mount -a
pi@raspberrypi:~$ df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                    95416         0     95416   0% /lib/init/rw
udev                     10240       148     10092   2% /dev
tmpfs                    95416         0     95416   0% /dev/shm
rootfs                 1602528   1311868    209252  87% /
/dev/mmcblk0p1           76186     28549     47637  38% /boot
/dev/mmcblk0p4         1994640     35744   1857572   2% /mnt

Now we need to copy the home directories across:

pi@raspberrypi:~$ sudo su -
X11 connection rejected because of wrong authentication.
root@raspberrypi:~# mv /home/pi /mnt
root@raspberrypi:~# ls -l /mnt
total 4
drwxr-xr-x 12 pi pi 4096 Jun 19 11:57 pi

Next whilst we are still in the root shell we’ll unmount /mnt and move it back to /home:

root@raspberrypi:~# umount /mnt
root@raspberrypi:~# vi /etc/fstab

Now change the entry for /mnt to /home and save it. Next we’ll mount it again this time as /home

root@raspberrypi:~# mount -a
root@raspberrypi:~# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                    95416         0     95416   0% /lib/init/rw
udev                     10240       148     10092   2% /dev
tmpfs                    95416         0     95416   0% /dev/shm
rootfs                 1602528   1305236    215884  86% /
/dev/mmcblk0p1           76186     28549     47637  38% /boot
/dev/mmcblk0p4         1994640     42380   1850936   3% /home

There it’s done, now /home is a 1.8Gb partition whilst root holds the base OS.

Now reboot the pi & log in again. You should now see all your files present but it’s now in the new larger partition.

Getting GPS to work on a Raspberry PI

One of the tasks I want to use a Raspberry PI for is to take over the duties of an existing ITX based linux box running my weather station. Now in theory that should be pretty simple as the current setup uses pywws to connect to the station and as that’s written in python it should work.

Now the Raspberry PI has no onboard Real time clock – which means it needs to use an NTP server to get the time when it starts. Usually you would use the default settings and allow the PI to connect to thenet for it’s time. Now this is fine if you have a working net connection but what if you are not connected to the net? You might be in the field running the PI on batteries.

As the other projects I have lined up for it is to connect my Meade LX200GPS telescope to the local network or to work with my (in prototype) radio telescopes so having an accurate clock is going to be required.

Now the obvious solution here is to use GPS as a time source. GPS works by having a constellation of satellites in orbit and each one carries a highly accurate atomic clock & broadcast both their current position and the time. A GPS receiver then receives these signals and, as long as it has enough satellites and workout where you are by comparing the times from those clocks.

So this article shows how to use A GPS receiver with the Rasperry PI – although these instructions are not specific to the PI.

The hardware

For this experiment I’m using a USB GPS receiver from Maplin – product code A73KF. I bought this several months ago when they had it on special offer for £19.99 – it usually retails for £29.99.

Raspberry PI with the A73KF GPS receiver plugged in

Now it comes with a CD for Windows machines but we don’t need it – as the majority of GPS receivers I know of use serial & this is no exception. When plugged in it appears as a serial port.

Plug it in and run lsusb

pi@raspberrypi:~$ sudo lsusb
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

There the Prolific Technology entry is the GPS appearing as a serial port. If you look in /var/log/syslog you will also notice it will have created the port as /dev/ttyUSB0 as it’s the first serial port.

Using the PI as a GPS Receiver

Now the next step is to get the pi receiving data from the satellites. Now there is a suite of tools available for Linux called gpsd which we’ll install:

pi@raspberrypi:~$ sudo apt-get install gpsd gpsd-clients python-gps

Next we need to start the daemon:

pi@raspberrypi:~$ sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

Ignore any messages from the console or in the log files, you may see it complaining about IPv6 but you can ignore that.

Viewing whats in the sky & your location

Now GPS doesn’t work indoors – as it needs a clear view of the sky so for this I’ve placed the PI on the window sill. Next I ssh into the pi and run cgps.

pi@raspberrypi:~$ cgps -s

The -s flag is there to tell the command not to write raw data to the screen as well as the processed data.

You should then get the following output:

┌───────────────────────────────────────────┐┌─────────────────────────────────┐
│    Time:       2012-06-18T15:05:10.0Z     ││PRN:   Elev:  Azim:  SNR:  Used: │
│    Latitude:    51.231848 N               ││  14    43    249    40      Y   │
│    Longitude:    0.514014 E               ││  25    75    283    37      Y   │
│    Altitude:   132.3 m                    ││   2    26    085    31      Y   │
│    Speed:      0.0 kph                    ││  12    56    070    18      Y   │
│    Heading:    0.0 deg (true)             ││   9    19    133    22      Y   │
│    Climb:      0.0 m/min                  ││  27    09    133    17      Y   │
│    Status:     3D FIX (1 secs)            ││   4    17    045    31      Y   │
│    GPS Type:                              ││  32    05    321    20      Y   │
│    Longitude Err:   +/- 8 m               ││  29    41    192    18      Y   │
│    Latitude Err:    +/- 9 m               ││  31    28    304    42      Y   │
│    Altitude Err:    +/- 27 m              ││                                 │
│    Course Err:      n/a                   ││                                 │
│    Speed Err:       +/- 68 kph            ││                                 │
│                                           ││                                 │
│                                           ││                                 │
│                                           ││                                 │
│                                           ││                                 │
│                                           ││                                 │
└───────────────────────────────────────────┘└─────────────────────────────────┘

Here you can see it’s receiving from 10 satellites and it has the time and your location. The 3D FIX section tells you it has enough data for a 3D fix on your location (i.e. altitude). The Err lines tell you the error in your position. If you leave it running you should see the Err values change every second or so.

Viewing GPS under X-Windows

Now above I showed how the GPS looks from an SSH connection but you can get a graphical display as well using the xgps client thats also been installed. Now if you have a monitor connected to the pi simply open a terminal and run xgps. However as I’ve not got a monitor against the window I’ve used ssh to connect to it from another machine. To get this to work you need to add -Y to the ssh command.

peter@somehost:~ $ ssh -Y pi@raspberrypi
pi@raspberrypi:~$ xgps

You should now get a window like the following open on your local machine – don’t worry if it takes a little while, it might take a second or two:

xgps running on a PI but being displayed on Mac OS-X

Setting the computer time using GPS

Now we have a working GPS we can now get the PI to use it for setting the time. To do this we need to configure ntp to use the GPS satellites as a time source. Now you should already have ntp installed but if not then you need to install it:

pi@raspberrypi:~$ sudo apt-get install ntp

Next you need to edit the file: /etc/ntp.conf and add a few lines to it defining the GPS. This can be either before or after the existing lines beginning with server:

# gps ntp
server 127.127.28.0 minpoll 4
fudge  127.127.28.0 time1 0.183 refid NMEA
server 127.127.28.1 minpoll 4 prefer
fudge  127.127.28.1 refid PPS

Now restart ntp:

pi@raspberrypi:~$ sudo service ntp restart

Now if you query the server you should after a while see it synchronize:

pi@raspberrypi:~$ ntpq -p
remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*ns1.luns.net.uk 33.117.170.50    2 u   54   64    7   65.454    2.666   5.800
+resntp-b-vip.lo 127.151.91.34    3 u   45   64   17   55.704   -5.169   8.482
+bart.nexellent. 194.242.34.149   2 u   17   64   17   76.585   -4.271  57.595
+v01.s01.be.it2g 193.190.230.65   2 u   20   64   37   86.464   -2.374 228.460
xSHM(0)          .NMEA.           0 l   11   16  377    0.000  144.714   3.026
SHM(1)          .PPS.            0 l    -   16    0    0.000    0.000   0.000

A couple of notes:

You might find that ntp doesn’t connect to the gps at first. It appears that it starts gpsd up without the link to the serial port. What I find I have to do is:

pi@raspberrypi:~$ sudo killall gpsd
pi@raspberrypi:~$ sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
pi@raspberrypi:~$ sudo service ntp restart

Once I’ve done this then after it gets a fix then it starts working. Sometimes running cgps and waiting for it to get a fix also fixes this.

I don’t know why this happens but it’s an issue I’ve yet to solve.

Getting SSHD to run on boot

By default the sshd service is not installed in the debian distrubution used on the Raspberry PI. For most uses this isn’t really necessary but if you are intending to use the pi without a screen then you need some way to get into it over the network.

All you need to do is to install ssh & tell debian to run it on boot:

sudo apt-get install ssh
sudo update-rc.d ssh defaults

Now, as long as you know the IP address (or you give it a static one) then you can now ssh into it.

The Grand Unboxing of the Raspberry PI

Finally after waiting for months my Raspberry PI finally arrived:

The unopened box containing the Raspberry PI.

When you open the box & get it out you then realize how tiny the thing is:

The PI out of its box & sitting on the trackpad of my MacBook Pro as a guide on how small the device is

Now when I ordered this I also ordered a PSU (normal micro-USB) and a 4Gb SD card. The other required items like HDMI & USB keyboard/mouse I already had, so the next thing was to download Debian & install it on the sd card.

I followed the instructions on elinux.org as I couldn’t get RasPiWrite to run but then it was a simple task. It will take a while to copy to the card.

Once done plug everything in and start it up. At first you’ll see it boot & it’s pretty quick. Once you get the login prompt login and type startx. You’ll then get the desktop.

The initial desktop

There’s a simple browser provided which works to a point – some things don’t work but it’s early days.

3 browser windows open on the PI

There’s only one thing that’s not right is that the screen doesn’t fit the monitor – but then I blame the monitor than the PI – it’s a cheap TV/DVD from Asda which I know has an odd resolution (1400×900) & the PI is detecting it with a higher resolution, but other than that, initial use shows it’s working pretty well.

How to fix OpenJDK-7 certificates on Ubuntu 11.10 running on Amazon EC2

After a second crash of my EC2 instance which was running Amazon‘s own Linux distribution I had to rebuild so this time I decided to put the latest official Ubuntu AMI on it. Everything ran fine until I fired up an application which takes a feed from Twitter using their stream api.

When I fired that up I got the following stack trace:

17 Feb 2012 21:13:00,790 ERROR [Twitter Stream consumer-1[Waiting for 500 milliseconds]] [in.setra.twitter.TwitterModule] Exception during processing
java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-emptyRelevant discussions can be on the Internet at:
 http://www.google.co.jp/search?q=b5e7486f or
 http://www.google.co.jp/search?q=24943238
TwitterException{exceptionCode=[b5e7486f-24943238 b5e7486f-2494320e b5e7486f-2494320e b5e7486f-2494320e], statusCode=-1, retryAfter=-1, rateLimitStatus=null, featureSpecificRateLimitStatus=null, version=2.2.5-SNAPSHOT}
 at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:200)
 at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
 at twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:102)
 at twitter4j.TwitterStreamImpl.getFilterStream(TwitterStreamImpl.java:290)
 at twitter4j.TwitterStreamImpl$7.getStream(TwitterStreamImpl.java:279)
 at twitter4j.TwitterStreamImpl$7.getStream(TwitterStreamImpl.java:277)
 at twitter4j.TwitterStreamImpl$TwitterStreamConsumer.run(TwitterStreamImpl.java:427)
Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
 at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
 at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1697)
 at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1660)
 at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1643)
:
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
 at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)
 at java.security.cert.PKIXParameters.<init>(PKIXParameters.java:120)
 at java.security.cert.PKIXBuilderParameters.<init>(PKIXBuilderParameters.java:104)
 at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:73)
 ... 23 more

After a brief search I found that for some reason when you install OpenJDK-7-jre-headless you don’t get the certificates installed & most people just switched back to the Sun/Oracle jre.

Now this worked for me – the install was a virgin setup so I hadn’t installed the sun JDK before but I found the Java 6 cacerts installed, so the following two lines fixed the problem:

cd /usr/lib/jvm/java-6-openjdk/jre/lib/security
sudo ln -s /usr/lib/jvm/java-7-openjdk-i386/jre/lib/security/cacerts cacerts

This may work elsewhere, it may not – in this instance it worked & I’m now getting a realtime stream in from Twitter.