Saturday, 14 May 2016

Upgrading my Raspberry Pi software

In a previous blog post (My first Raspberry Pi - day 3) I described how I'd set up my Raspberry Pi to boot from an external hard disc drive. In that setup I created a "spare" partition to allow easy migration to a new operating system. Now, 2½ years later, it's time to find out just how easy (or not) this is by upgrading the Raspbian OS from "Wheezy" to "Jessie".

I downloaded the Raspbian "Jessie" image from the downloads page and unzipped the file to extract the image file 2016-03-18-raspbian-jessie.img. Then I copied this file to the Raspberry Pi and installed it as follows.

Install kpartx and then use it to access the two partitions of the image file:
sudo apt-get install kpartx
sudo kpartx -a 2016-03-18-raspbian-jessie.img

Create mount points for the two partitions and mount them:
sudo mkdir /mnt/jessie-boot
sudo mkdir /mnt/jessie-root
sudo mount /dev/mapper/loop0p1 /mnt/jessie-boot
sudo mount /dev/mapper/loop0p2 /mnt/jessie-root

Copy the "Jessie" root partition to /spare. This takes some time as there is over 3 Gigabytes to copy:
sudo rsync -av /mnt/jessie-root/ /spare

Copy the "Jessie" boot partition to /spare/boot.bak. Note this is not the actual /boot partition, we don't want to change that until we're ready to boot into the new OS.
sudo mkdir /spare/boot.bak
sudo rsync -av /mnt/jessie-boot/ /spare/boot.bak

Move the "Jessie" home directory's contents to the /home partition:
sudo rsync -av /spare/home/ /home
sudo rm -rf /spare/home/pi

Copy /etc/fstab to the "Jessie" partition and edit it:
sudo cp /etc/fstab /spare/etc/
sudo vi /spare/etc/fstab

After editing the fstab file is as follows:
proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults,ro       0       2
/dev/sda1       /old_os         ext4    defaults,noatime  0       1
/dev/sda2       /               ext4    defaults,noatime  0       1
/dev/sda3       none            swap    sw                0       0
/dev/sda4       /home           ext4    defaults,noatime  0       1
tmpfs           /tmp            tmpfs   size=256M         0       0

Note that /dev/sda2, which is currently mounted as /spare, will be mounted as / and that /dev/sda1, currently mounted as /, will be mounted as /old_os. This requires a new mount point to be created:
sudo mkdir /spare/old_os

Since my original Rasbperry Pi setup the network configuration file has changed from /etc/network/interfaces to /etc/dhcpcd.conf. As I use a static network address on one of my Pis (because it is my network DHCP server) I needed to edit /spare/etc/dhcpcd.conf before attempting to reboot.

Edit the new boot command line and set it to use /dev/sda2 as the root device:
sudo vi /spare/boot.bak/cmdline.txt

Backup the existing /boot partition, then make it writeable and copy the new boot code to it:
sudo mkdir /boot.bak
sudo rsync -av /boot/ /boot.bak
sudo mount -o remount,rw /boot
sudo rsync -av /spare/boot.bak/ /boot

At this stage it should be possible to boot the Raspberry pi into the new operating system and login as pi:
sudo reboot

If I want to go back to the older operating system at any time I should be able to do so by copying /old_os/boot.bak to /boot and rebooting.

All that remains to do is to add my normal user account jim and then install and configure the current versions of all the software I was running — dnsmasq, xinetd, esmtp, nfs-kernel-server, etc. Being able to view the old configuration files in /old_os/etc is a great help when doing this.

Wednesday, 27 April 2016

Titchener vs. Titchener

Listeners to BBC Radio 4's "The Archers" might enjoy this. The rest of you should go and read something else.

Court report.
The case of Mrs. Helen Titchener vs. Mr. Rob Titchener continued yesterday in the Borchester Family Court, Mr. Justice Cocklecarrot presiding. It concerns the custody of the Titcheners' five year old son Henry.

Mr. Tinklebury Snapdriver, appearing for Mr. Titchener, alleged that Mrs. Titchener is unable to provide a safe home for Henry, having shown herself to be incapable of basic motherly duties such as running a warm bath or making custard. Mr. Titchener's parents, Bruce and Arsula, have generously arranged for Henry to attend Narkover Preparatory School For Boys, a prestigious establishment free of any feminising influences.

Mr. Cocklecarrot interjected that he has no idea what a feminising influence is, but Narkover School is well known for the consistency of its custard and the temperature of its showers. Polite laughter was heard from all sides of the court.

Mr. Snapdriver went on to consider protecting Henry's identity, as his mother is soon to be the subject of a high profile case in the Borchester Crown Court that is likely to attract much media attention. As has become normal practice members of the public had been invited to suggest names in an online poll. After discounting frivolous suggestions such as "Henry McHenface", "Titchy McTitchface" and, bizarrely, "Boaty McBoatface" all that remained was "Hoover". Mr. Snapdriver observed that this is a strange choice, but it is at least better than "AB" or "CD".

Dr. Smart-Allick, headmaster of Narkover school, had written to say they already have a boy called Hoover in the school, so Henry would be known as "Hoover Junior" upon his arrival. This revelation provoked much hilarity in the public gallery.

After order was restored Mr. Cocklecarrot asked why the name "Hoover Junior" was the cause of such merriment. At this point twelve red-bearded dwarves arose and began to run haphazardly around the courtroom, holding their hands out in front of themselves and making buzzing, whirring and humming sounds.

After order had been restored for a second time Mr. Cocklecarrot demanded to know how the twelve red-bearded dwarves were involved in this case. One of their number, a Mr. Sean O'Connor, explained that they were due to appear before Mr. Cocklecarrot later in the week, but because on several occasions recently one day's events had been spread over several days they no longer knew what day it was. They were now in the habit of arriving early for appointments to be sure of not being late.

Mr. Cocklecarrot saw no alternative but to clear the court and adjourn for the day.

The case continues.

(With apologies to J B Morton, author of the "Beachcomber" newspaper column.)

Tuesday, 29 March 2016

21st Century Photosniper — improved shutter release

In a previous post (21st Century Photosniper) I described various additions I made to a "Stedi Stock" shoulder brace camera mount. These include a remote shutter release cable to allow the camera to be operated while holding the shoulder brace by its handle.

The commercial cable release I used contains a single switch, so there is no "half pressed" focus confirmation like you get with the camera's shutter release button. Commercial two-stage push switches are uncommon and quite expensive, so I decided to make my own.

Two stage trigger switch

I used two sub-miniature push buttons operated by a trigger made from an old toothbrush handle. A small piece of plastic foam pushes one of the buttons first, then compresses to allow the other button to be pressed. The picture above shows it during construction, before bending the aluminium mounting plate to fit the shoulder brace.

Stedi Stock camera shoulder brace

A cheap audio cable with a 2.5mm right-angled jack plug is used to connect the switches to the camera. As shown below, there is just enough room beneath my 500mm mirror lens to accommodate the thickness of the mounting plate.

Stedi Stock camera shoulder brace

I haven't yet decided if the trigger needs to be shorter. There's plenty of room behind it for the rest of my fingers when using my index finger to operate it.