error: btn: invalid btn_btree.bt_key_count

I recognised the symptoms:

  1. Excessive disk trashing.
  2. General slow down.
  3. Backblaze and Time Machine causing the rainbow spinner.

My filesystem needed first aid. I think I can trace this back to the latest macOS update. I swear that half the updates cause filesystem corruption of some sort, but it also feels like I’m running First Aid at least once a month anyway!

Unfortunately for me, the error this time was:

error: btn: invalid btn_btree.bt_key_count

Apparently Diskutil can’t fix that error. The only thing you can do is erase the drive, reinstall MacOS and then restore your data. I was dreading it.

I have a Time Machine backup but I decided to make another backup of my home directory, while logged into another account. Lucky I did as an IO error showed up in Library/Caches/ – thankfully I think in an Apple app I don’t use.

I expected the business of restoring everything to be awful, but in the end the MacOS installer fired up Migration Assistant which let me restore my last Time Machine backup.

With that done it was time to install Brew again. The first package to go back in was coreutils but “brew reinstall” has a bug where it won’t accept parameters. I should have used “install” but “reinstall” with  “–with-default-names” doesn’t work. Also coreutils and related packages are “keg-only” now so no symlinks to /usr/local/bin are made. You have to run “brew link” to link all the commands. It was a simple job then to rename each file, removing the “g” prefix.

I’ll find more things as I go that aren’t configured I’m sure, but thankfully restoring from Time Machine made the job much easier!

High Sierra and coreutils

Since MacOS High Sierra has been out for a long time this is probably old news to the tiny minority using coreutils. When you upgrade you might find that “df” and other commands don’t work properly.

Every time I opened a terminal after upgrading I saw errors saying commands had been aborted. When I ran “df” it would abort immediately.

I thought the upgrade had damaged my filesystem, especially since it introduced APFS. I ran “First Aid” in Disk Utility several times, both live and in recovery.

It then occurred to me to try the MacOS df in /bin/. It worked!

Coreutils is the package that includes lots of command line tools like “df”. I installed it using brew so the following fixed the problem:

brew reinstall coreutils

I noticed it put everything in /usr/local where my original commands were in /opt/ so changing the PATH in my .zshrc was necessary too. Everything was back to normal again! 🙂

EDIT: Some other commands were messed up. “find” had changed, but then I realised it probably isn’t in coreutils and I was using the MacOS version. This page led me to the right package names and the following command line:

brew reinstall coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt --with-default-names

The “–with-default-names” parameter restores the original filenames, removing the “g” prefix. Everything outside of the coreutils went in /usr/local/bin/ which I made sure was added to the path too.

Ages …

Time Machine Initial Backup

Well, look. At least it’s not like in Windows where it tells you it’ll be done in ten minutes and then five minutes later it’s gone up to twenty ..

I expect this will take a few days.

Some tips to make Mac OS X Finder easier to use

Making the switch from Windows or Linux to Mac OS X is not without pain. The extra CMD key plays havoc with muscle memory, and the “Windows Explorer” of Mac OS X, Finder, is quite a different beast to what you might be used to in the Windows or Linux worlds.

About two weeks ago I decided to make the switch again to Mac OS X and I lamented the difficulty in using Finder to do simple tasks. I’m still not 100% happy with Mac OS X it but the tips on the following pages made things easier:

  • Home and End keys work on a line, not a document, silly.
  • Disable natural scrolling.
  • Switch CMD and ALT if you’re using a PC keyboard. I have a lovely split keyboard but the default configuration hurt my fingers.
  • Change the keyboard layout if your keyboard doesn’t work the way you’re used to. I still haven’t got this set up exactly as I want it to. In my terminal some keys act differently I think but I haven’t set aside time to work out which. I need to swap ” (shift-2) with @ (key to the top/left of right-shift). My muscle memory gets them mixed up all the time.
  • Automount SMB drives automatically. I haven’t been able to get the fstab method to work yet because my password has spaces but the “User Login” one works well enough.
  • Change Finder search so it searches the current directory by default.
  • Type the path into Finder.
  • 9 tips to improve Finder.
  • Sorting and arranging in Finder.
  • Right click on the directory name in Finder and show a dropdown of the path to that directory.
  • Install Mac Ports to get a working copy of Rsync and a better ls that lets me put parameters after the filename.

There are still oddities. When Mac OS X mounts an SMB share it does so with permissions that only allows the current user to edit files in the share. That’s perfectly understandable but it messes things up for Rsync when I’m syncing directories with a remote host. I’ve had to resort to using the “–size-only” parameter of Rsync so it won’t attempt to sync every file each time. I need to figure out if that can be fixed somehow.

I’ll update this post from time to time as I come across more oddities.

Windows screenshots on a Macbook Pro laptop

Creating a screenshot in Windows is normally simple. Press Print Screen, fire up paint and paste it in. However what do you do when you have a laptop keyboard without a PRT SCN button?

It’s rather simple actually, thanks macrumors people.

To create a screenshot on a Macbook Pro laptop press either fn+shift+F11 or fn+ALT+F11. The latter one grabs a single window. Fire up paint and CTRL-v those pixels in!

Crash Different

An oldie, but as they say, “a goody”. For all the Mac fans who are sick and tired of their computers crashing. (Hey Mark!)
Found this on a CD while sorting through my CDRs and music collection. Most are now ripped to MP3 and the physical media is heading into the attic for safe storage.

Why is it that most of my compilation CDs are from about 10 years ago? Does music become less relevant the older you get? I’ve never bought music online but if I do, Blue Lights on the Runway by Bell X1 will probably be the first album I buy. Love “The Great Defector”, their current single.

Mac OS X Leopard and Nokia N73 Bluetooth Problems

When I got my new Macbook a few weeks back I thought I could use the Bluetooth functions to browse and copy files from my Nokia N73. It worked just fine on my previous Macbook, an old 2 year old machine destroyed by a cup of tea, so I wasn’t expecting any problems.

Unfortunately it seems that Mac OS X Leopard and the latest firmware of the Nokia N73 just do not like each other. No matter what I did, I could not get the Macbook and N73 to pair. The configuration tool stopped every single time on the “getting more information” part of the wizard. I’m not the only one experiencing problems. There’s a long thread on the Apple website. Both Apple and Nokia have been informed and are aware of the problem but I suspect it’s something in Nokia’s latest N73 firmware.

I have a card reader, now to find the SD sleeve that came with my Sony Ericsson phone. Nokia didn’t include one with their phone.

PS. does anyone else find the keyboard of their Macbook isn’t as responsive as it should be? I have to really hit the y and Enter keys to make sure. It is very annoying!

How to win an Apple Mac Air

  1. Join Twitter.
  2. Follow @wubud.
  3. Tell your friends.

@wubud (pronounced woo-bud) is where Paul Walsh will reveal his next venture. You may remember Paul from a previous post here about his qik adventures when he missed his flight home because he was talking to people on the Internet. He landed a bed in a penthouse suite so don’t be too sorry for him!

Anyway, he explains on his blog why he’s going down the Twitter route and it’s an interesting experiment. It certainly caught the imagination of several people we both follow and I know others are blogging it too. Nice way to spread the word, eh? I think the incentive to win a Mac Air helps too, don’t you think?

So far only 203 people are following @wubud so it may take a while to get to the 5,000 followers Paul wants.

Paul’s in San Francisco next weekend, so you never know, he might reveal the master plan to you if you ask nicely if he hasn’t done it before then!

What about me? Do I want to win a Mac Air? ‘Course I do! My Macbook died this evening. A cup of tea spilled on it while I was feeding the baby. I quickly dried it off as best I could with paper towels but the screen was black and the thing is dead. Luckily backuppc had done a backup 6 days ago so I doubt I lost much stuff.