Archive for the 'MacOS / OSX' Category

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

Sunday 31st May 2015

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.

Links

* 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!

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

Wednesday 30th January 2013

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?)

OSX: Setting a global shortcut key to open a new Finder window

Tuesday 9th March 2010

Given that the Finder is central to many tasks in Mac OS X, I’m surprised that there is no global keyboard shortcut to call up a new Finder window. Well, that’s not strictly true — there’s alt-cmd-space, which will bring up a new window to start a Spotlight search. But most of the time I want to open my home directory, so I’d rather have a shortcut which jumps straight there.

Googling for the answer to this problem turned up lots of out-of-date suggestions to use Clearsilver and the like, but it seemed to me that a solution could be found using only what OSX provides. And indeed it can. The following has only been tested in 10.6 Snow Leopard. (more…)