A better, faster way to write a Raspberry Pi SD card image

Created: 31st May 2015 by Administrator

The standard way of writing an SD card image for a Raspberry Pi (or any other purpose that requires writing a whole disk image to the card) from any unix-like system (eg Linux or Mac OSX) is to use the venerable dd(1) utility.

dd has been around, basically unchanged, since the dawn of time. It has an arcane syntax that’s completely different to every other unix command, and its screen output is spectacularly unhelpful. While it’s working, it remains silent. You have no idea how fast it’s going or how long it’s going to take, until it eventually finishes and tells you how many blocks came in and went out – and even that minimal information is presented in a rather obscure format.

On my Mac I found using dd to write a Raspi boot image to an SD card to be very slow and unreliable. For some reason it refused to write to the raw disk device (/dev/rdiskn), even though there were no active mounts. Using the buffered device file instead (/dev/diskn) it took a full 30 minutes to write a 650MB image… and even then, when I pulled the card and put it in my Raspi, somehow it still booted the old OS that was on there before.

Then I discovered a lovely utility called pv, which stands for Pipe Viewer. On a Mac it’s available in Homebrew (brew install pv) and Macports (port install pv).

Using this, instead of dd if=osimage.img of=/dev/diskn (30 minutes, remember), I did pv osimage.img > /dev/rdiskn and it took just over 2 minutes, and the card worked perfectly. (These commands need to run as root, of course).

The other big advantage of pv over dd, is that it shows you what’s going on – it provides a progress bar, data transfer rate, ETA and so on (this is actually its raison d’etre, it just seems to be much more efficient than dd at piping data too) – whereas dd just sits there saying nothing until it’s finished.

pv has a ton of potential uses, and is a shining example of the strength of the UNIX philosophy: a small program that does one thing and does it well, interconnecting with other programs in a standard way to make them better. I don’t know how long it’s been around, but I love the fact that even after 20 years of using Linux I can still stumble upon something new and neat that I know will immediately become a well-used part of my toolkit and make life easier. And I have to laugh, because I’ve just found out it was written by Andrew Wood, an old friend from years ago. Looks like it’s been around for quite a while, and is still being actively maintained. Kudos.


* Wherever you see n in this article, you’ll need to replace it with the appropriate number for the SD card on your system. On my Macbook Pro it’s 2, but your system may be different, and if you get it wrong, you could overwrite a critical system disk. My first ever big data loss event back in 1994 was caused by an error like this, which is why I’ve not put the number in above, I wouldn’t want anyone to blindly copy&paste – find out the correct number for your system, double, triple and quadruple check the commandline before you hit enter, take backups and take care!

Verifying the Tube station “mackerel” factoid

Created: 4th March 2015 by Jamm!n

I’ve heard the following little nugget of information before:

St John’s Wood is the only station on the London Underground network which does not contain any of the letters in the word “mackerel”.

I have never had any reason to doubt this, but neither had I checked it. It popped up again recently on a Facebook thread. Someone suggested that it was not true (or perhaps no longer true) because of Hoxton. However, strictly speaking Hoxton is on the London Overground network, not London Underground.

Anyway, I decided that I should go ahead and check the veracity of the statement. The geeky way.

  1. After a while searching for an existing plaintext list of Tube station names, I couldn’t find one, so instead I downloaded the Wikipedia page List of London Underground stations, had a quick look at the source HTML to see if it would be easy to pull the station names out of the page.

  2. It was; each line of the table starts with <th scope=”row”>, and follows a set pattern after that, as you might expect:

    <th scope="row"><a href="/wiki/Acton_Town_tube_station"
    title="Acton Town tube station">Acton Town</a></th>

    This is all one line in the original HTML, I’ve just broken it to two for display.

    So I can pull out just the lines containing station names using a simple grep.

  3. All I’m interested in is the bit between the opening <a …> and closing </a> tag. At this point I tend to resort to Perl to do anything remotely complex with regex replacement.

    $ grep '<th scope="row">' \
    list_of_london_underground_stations_from_wikipedia.html \
    | perl -pe 's/.*>([^<]+)<\/a>.*/$1/' \
    > list_of_london_underground_stations.txt

    Since I’ve broken out the Perl for this job, I could have thrown away the initial grep and incorporated it into the Perl instead, but this is just a quick hack and it already works, so why bother? I’m not aiming for elegance here.

  4. Verify the list:

    $ cat list_of_london_underground_stations.txt
    Acton Town
    Aldgate East
    Watford High Street
    Watford Junction
    Watford Vicarage Road
    $ wc -l  list_of_london_underground_stations.txt
         275 list_of_london_underground_stations.txt

    Looks good. We have just the station names, one per line, and there are 275 lines, which sounds about right. [The list includes a few planned stations at the end. I decided to keep these in.]

  5. Now I can grep for those station names for those not containing any of the letters in mackerel:
    $ egrep -vi '[mackerl]' list_of_london_underground_stations.txt
    St. John's Wood

And there you have it. Assuming of course that the Wikipedia list is correct and complete, the factoid is confirmed. And it took just a couple of minutes. Plus about 20 minutes writing it up afterwards…

Of course, now I can substitute other words for ‘mackerel’ too. For example, there are three stations that do not contain any of the letters in ‘herring’.

For your convenience and further exploration, you may download my plain text list of London Underground stations. Remember, it includes every station on the Wikipedia page as of 4th March 2015, including several stations that are at the planning stage so do not actually exist yet (or not on the current Tube network anyway); these are at the end of the list and are: Battersea, Cassiobridge, Nine Elms, Watford High Street, Watford Junction, Watford Vicarage Road.

Bring back the Firefox (wait / busy) mouse (cursor / pointer) (hourglass / clock)

Created: 30th January 2013 by Ben

Old versions of Firefox used to indicate when you were waiting for the next page to load, by changing the cursor to one with an hourglass or clock. This provided immediate visual feedback at the screen position where you were already looking that the link click had succeeded and something was happening. This is simply good UI practice.

Some time ago, in version 3.5, this feature got removed, without fanfare. This meant that now, to see if the browser is doing something, the user must look away from where they were looking, either at the tab bar or the status bar. Neither of these have the immediacy of the pointer change, and not everyone has the luxury of having them.

Many people felt this was a bad idea, as did I, but at the time no option was provided to restore it.

However I recently revisited the page, and found that, soon after I reluctantly gave up on finding a solution, they did indeed add an option to restore it. Go to about:config, and set the value ui.use_activity_cursor to true

This is far from the only bad decision that Mozilla developers have made in recent years. Removing the status bar is probably the most ludicrous one (and the one that would have sent me running to another browser immediately had there not been an add-on to bring it back), amd I’m sure I’m not alone in feeling that their current release schedule and version number policy is barmy. Overall, it’s still great, and for modern web development nothing else comes close to Firefox armed with a stack of extensions like Firebug, Web Developer, Tilt etc. But it seems to me that Mozilla have repeatedly forgotten or ignored the diverse needs of their users in a bid to follow idealistic policies like having a “zen” interface, or upping their version number every 2 seconds (slight exaggeration) whether anything significant has changed or not.

Edit: 12 Nov 2014:
Another about:config option I recently discovered is the ability to stop the backspace key from going back a page. I never, ever, ever want it to do that, and whoever decided that was a good keybinding better not meet me in a dark alley lest they have to pay for all the times it’s bitten me. Anyway, fortunately in Firefox you can switch it off easily. The setting is browser.backspace_action and the magic number to change it to is 2. (1 makes it behave like Page Up – less annoying than Back, but still, just why?)

How to reset Viewsonic VP181b EEPROM / DVI

Created: 18th December 2012 by Jamm!n

I’ve long been searching for the method to reset the EEPROM on my Viewsonic VP-181b 18″ monitor. I bought this monitor second-hand and the DVI input has never worked since I got it. This didn’t matter when I was using it with my PC, but now I want to use it on a Raspberry Pi with an HDMI-to-DVI cable, I’d like to get it working.

Research suggested that doing a factory reset of the EEPROM can sometimes fix a recalcitrant DVI input. Unfortunately it doesn’t seem to have worked for my monitor, so it looks like the circuit is actually fried, but just in case it helps anyone else, here’s how you do it.
I got this info from the Service Manual which I was able to download from here (but only after disabling Adblock Plus).

NB: It seems you need the monitor connected to a VGA input which is displaying something, and have that input selected, because it won’t show the on-screen menus otherwise.

First, put the monitor into “burn-in” mode by holding down the “2” and “down” keys while you switch it on (you can use the front-panel power button, no need to resort to the switch)

Second, switch off again and then go into “factory” mode by holding down the “1” key while you switch on. Factory mode is only accessible once you are already in burn-in mode.

Now when you press the “1” key, you should see a different menu than normal. It looks like this:

Use the down button to select the “Initial EEPROM” option and press 2 to activate.

At this point the EEPROM should be reset, but you are still in burn-in mode – if you switch to the DVI input at this point, you will see a white screen and it will say that you’re in burn-in mode.

To exit burn-in mode, you need to power off, and then power on again while pressing the “down” and “up” keys.

Review: Kanger T2 and Vision Vivi Mini Nova clearomizers

Created: 13th November 2012 by Ben

Like many vapers, I started out with a 510-style cartomizer, but soon got bored of the continual refilling, and the fact that there’s no indication of how much is left. As soon as I discovered clearomizers I knew this was the way it should be. But finding a good one has taken a lot longer. The first clearos I tried were the Vision CE4 aka “Stardust”, and several other CE3- or CE4-style clearos from unknown manufacturers being sold by unscrupulous vendors. I was not impressed – compared to my old 510 bottom-coil carto, the clearos were practically flavourless. Sure, they were easier to refill, but they were also prone to leak. The genuine vision CE4 was the best of the bunch, but still very disappointing.

Fortunately, I’ve now found two clearomizers that I particularly recommend. They are both solidly built and “rebuildable” which means that (like the CE4) you can disassemble them for easier cleaning, and the atomizer head can be replaced when it dies without having to replace the whole clearo. The atomizer heads are also available in a range of different resistances.

Kanger T2

The Kanger T2 is an eGo-thread clearo. It has the best flavour by a mile; combined with good vapour and a smooth draw, this makes it hands down my favourite clearo. I’m using “version 2” – other than an “improved mouthpiece” I’m not sure what the difference is from version 1, but from what I’ve read, the v1 had problems which the v2 has fixed. That mouthpiece is lovely, by the way – it’s smooth, and narrows down more than most drip tips so it feels really comfortable in the mouth for someone like me coming from a background of smoking thin rollies. As with most clearos, the mouthpiece screws onto the tank and is specifically designed for it, so you can’t replace it with your own choice of drip tip.

Alas, nothing in this world is perfect, and the T2 does have a few flaws:

I found the draw a bit tight (not quite enough airflow), so I bored the air holes with a needlepoint file to make them a bit bigger. You may not need to do this, I suspect it depends on precisely how the holes sit relative to your battery’s thread.

As with all short-wicked atomizers, you need to tip it to keep the wicks wet; but even though I do this, I periodically get a burnt vape from it, and a couple of times this has become permanent and can only be fixed by dry-burning the ato (if you’re not sure how to do this, there are plenty of videos about it on Youtube. The principle is the same for all clearos).

If you fire it so much that it gets hot (say, several long bursts within 30 seconds) it leaks slightly at the battery end – this manifests as seeming to be “blocked” when you try to vape. If this happens you just unscrew the battery and clean up with a cotton bud, so it’s no big deal as long as you’re using a sealed (manual) battery. But I’ve never had a leak from it in normal use, unlike most other clearos I’ve tried; it’s only when I’m firing it a lot (eg testing a new flavour).

Despite these issues, it’s still my favourite tank because of the superb flavour, especially for fruity/sweet flavours. it’s also the easiest to fill – the ato tube extends above the top of the tank, so you can holding the tank at 45 degrees you can simply dropper the liquid around the tube and into the tank with no chance of flooding the ato. Possibly because of the narrow mouthpiece, and unlike every other clearo, it has *never* spat hot liquid into my mouth.

Because the ato tube goes up that much higher, the ato itself is right at the very top of the tank, which means you can fill it right up. Clearos work best when filled to just below where the wicks enter the ato, and on the Kanger this corresponds almost exactly with the top mark of the scale drawn on its side: 2.4ml. In practice it does bubble a bit if filled precisely to this line, so I’d say the effective capacity is more like 2.3ml.

Of the three resistances available, I like the standard 2.2ohm ato best on this one. It goes superbly with either a fixed or variable voltage eGo battery.

Vision Vivi Mini Nova

The Vision Mini Nova is a 510-threaded clearo. Its flavour is not in the same league as the Kanger, but where it scores is reliability. I’ve never had a single burnt vape from it; never had a leak. Its long wicks feed liquid continually to the atomizer without the need for tipping (though long wicks also mean it takes longer to pick up a change in the liquid, so it’s not so great for tweaking flavour mixtures).

I found the standard ato was almost completely bland and flavourless, even at high voltage on my eGo Twist. It’s a lot better with the lowest-resistance ato (1.8ohm nominal, but it measures much higher), especially at low-ish voltage on a VV battery.

It seems to prefer, and emphasise, throaty flavours like menthol and aniseed, and de-emphasise fruit and sweet flavours. It produces massive clouds of vapour (which means it drinks liquid at a hell of a rate) and a strong throat hit.

There’s a lot more airflow available than the Kanger, and for that reason I always go for the Mini Nova when driving (there’s something different about the way that I vape when driving than at other times; I’m not sure why, but I seem to need an easier / more airy draw).

Most tanks have screw-on drip tips that are specific to that design, but the Mini Nova comes with a standard 510 drip tip, so you can replace it with a funky one if you so desire.

If you tip it upwards past horizontal while vaping, it will drip liquid into your mouth, but otherwise it’s very well behaved.

It has a wide base with a 510 thread that sticks out – this means if you put it on an eGo battery it looks a bit silly (but works fine), unless you also fit a special metal “cuff” or “plinth” to fill the gap (which also reduces airflow). You also can’t stand it upright when it’s off the battery. Personally I wish it had an eGo rather than a 510 thread, it’s really too big for a 510 battery anyway so I don’t understand why they decided to do it that way – but I suspect this is the reason why it has so much more airflow than the Kanger.

Filling requires a fairly thin nozzle on your bottles, or a pipette, to get between the ato and the tank wall, and as with all clearos you only want to fill it to just below where the wicks go into the ato or it will bubble, which makes the effective capacity about 1.75ml rather than the 2ml marked on the tank.

How to revert Firefox 14 awesome bar auto-completion behaviour / switch off URL autofill

Created: 23rd July 2012 by Jamm!n

Firefox 14 introduced a change to how the “awesome bar” (aka location bar) works – it now auto-completes in place. A lot of other browsers do this, so I guess it’s consistent, but I don’t like it – I find it much faster to recall my most commonly visited sites by typing a few letters (usually 3 is enough) which often occur in the *middle* of the URL, while the auto-complete always works from the *beginning* of the URL, and I find it confusing to be offered a suggestion which isn’t what I’m looking for. I’d rather see only the letters I’ve typed in the field, and a list of suggestions below.

I eventually found out how to revert to the old behaviour, but it wasn’t easy and involved being sent round in circles a few times. So, for your benefit, here’s how:

1. Type about:config in the awesome bar / location bar.
2. Use the Search field to locate the preference browser.urlbar.autoFill
3. It is true by default in Firefox 14. Double-click to set to false.