What is a JSON feed? Learn more

JSON Feed Viewer

Browse through the showcased feeds, or enter a feed URL below.

Now supporting RSS and Atom feeds thanks to Andrew Chilton's feed2json.org service

CURRENT FEED

Zanshin.net - Technology and Life

A feed by Mark H. Nichols

XML


A Script to Install My Dotfiles

Permalink - Posted on 2017-06-01 03:29

A year or so ago I created a script that allowed me to quickly install my dotfiles on a new computer. The script wasn't terribly sophisticated, but it got the job done. Called make.sh it takes an all-or-nothing approach to setting up my configurations.

Recently I ran across a Bash script that serves as a general purpose Yes/No prompt function. Using this script as a jumping off point I was able to create a more sophisticated install.sh script that allows me a more granular approach to setting up my dotfiles.

Ask

The ask function lets you create Yes/No prompts quckly and easily. Follow the link above for more details. I was able to default some of my configurations to Yes or install, and others to No or don't install.

Key/Value Pairs

In order to keep my script DRY I needed to have a list of the configuration files paired with their default install/don't install setting. Turns out you can do key/value pairs in Bash. It works like this:

for i in a,b c_s,d ; do 
  KEY=${i%,*};
  VAL=${i#*,};
  echo $KEY" XX "$VAL;
done

The key/value pairs are comma separated and space delimited, e.g., key,value key,value key,value. By using Bash parameter substitution it's possible to separate the key and value portions of each pair.

My list of pairs looks like this:

tuples="bash,Y gem,Y git,Y openconnect,Y tmux,Y slate,Y hg,N textmate,N"

The loop the processes these pairs looks like this:

for pair in $tuples; do
  dir=${pair%,*};
  flag=${pair#*,};
  if ask "Setup $dir" $flag; then
    echo "Linking $dir files"
    cd $dotfiles_dir/$dir;
    for file in *; do
      ln -sf $dotfiles_dir/$dir/$file ${HOME}/.$file
    done
  fi
  echo ""
done

Each key/value pair is a directory (dir) and a install/don't install flag (flag). My dotfiles repository is organized into directories, one for each tool or utility. The fourth line is where the ask function comes into play. Using the flag from the key/value pair it creates a prompt that is defaulted to either Y/n or y/N so that all I need to do is hit the enter key. Within each directory there are one or more files needing to be symlinked. The inner loop walks through the list of files creating the necessary symlink.

Linking Directories

Some of my configurations have directories or are trageted at locations where simple symlinking won't work.

Neovim, for example, all lives in ~/.config/nvim. Symlinking directories can produce unexpected results. Using the n flag on the symlink statement treats destination that is a symlink to a directory as if it were a normal file. If the ~/.config/nvim directory already exists, ln -sfn ... prevents you from getting ~/.config/nvim/nvim.

My Vim setup contains both directories and individual files.

My ssh config needs to be linked into the ~/.ssh directory.

The linking for each of these three exceptions is handled outside the main loop in the script.

The install.sh script

Here's the entire install.sh script.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Vim Macros Rock

Permalink - Posted on 2016-02-12 00:23

Today I had to take a two column list of fully qualified domain names and their associated IP addresses and reverse the order of the columns. Using Vim macros I was able to capture all the steps on the first line and then repeat it for the other 80-odd lines of the file.

Here's a sanitized sample of the data:

as1.example.com , 10.600.40.31 ,
as2.example.com , 10.600.40.32 ,
db1.example.com , 10.600.40.75 ,
db2.example.com , 10.600.40.76 ,
db3.example.com , 10.600.40.79 ,
db4.example.com , 10.600.40.80 ,
db5.example.com , 10.600.40.81 ,
dr-as1.example.com , 10.600.40.43 ,
dr-fmw1.example.com , 10.600.40.44 ,
dr-oid1.example.com , 10.600.40.39 ,
dr-web1.example.com , 10.600.40.45 ,
fmw1.example.com , 10.600.40.33 ,
fmw2.example.com , 10.600.40.34 ,
oid1.example.com , 10.600.40.29 ,
oid2.example.com , 10.600.40.30 ,
web1.example.com , 10.600.40.35 ,
web2.example.com , 10.600.40.36 ,

What I wanted was the IP address first, surrounded in single quotes, follwed by a comma, then follwed by an in-line comment containing the FQDN. This crytpic string of Vim commands does that:

vWWdf1i'<esc>f i', #<esc>pd$

Let's break that down.

v - Enter Visual mode
W - Select a Word, in this case the leading spaces before the FQDN
W - Select a Word, in this case the FQDN, including the trailing comma
d - Put the selection in the cut buffer
f1 - Find the start of the IP address, they all start with 1 in my data set
i'<esc> - Insert a single quote and escape from insert mode
f  - Find the next blank, or the end of the IP address
i', #<esc> - Insert the closing single quote, a space, a comma, and the in-line comment character, escape insert mode
p - Paste the contents of the cut buffer, the FQDN
d$ - Delete to the end of the line to clean up the errant commas from the cut/paste 

To capture this command string in a macro you need to record it. Macros and You is a really nice introduction to Vim macros. To start recording a macro you press the q key. The next key determines the buffer or name for the macro. Then you enter the command string. To stop recording press the q key again. For simplicity sake I tend to name my macros q, so to start recording I press qq and then enter the steps outlined above, followed by q to stop recording.

Playing back the macro is done with the @ command, followed by the letter or number naming the macro. So, @q.

Macros can be proceeded by a number, like regular Vim commands. In my case with 80 lines to data to mangle, I'd record the macro on line one, and then run it against the remaining 79 lines with 79@q. There is a problem with my command string though, it works on one line only. I need to add movement commands to the end of it to position the insertion point to the beginning of the next line. The updated command sting would be this:

vWWdf1i'<esc>f i', #<esc>pd$j0

The j0 jumps down a line and goes to the beginning. Now when the macro is run, it will march down through the file a line at a time, transforming the data. Here's the result.

'10.600.40.31', #   as1.example.com
'10.600.40.32', #   as2.example.com
'10.600.40.75', #   db1.example.com
'10.600.40.76', #   db2.example.com
'10.600.40.79', #   db3.example.com
'10.600.40.80', #   db4.example.com
'10.600.40.81', #   db5.example.com
'10.600.40.43', #   dr-as1.example.com
'10.600.40.44', #   dr-fmw1.example.com
'10.600.40.39', #   dr-oid1.example.com
'10.600.40.45', #   dr-web1.example.com
'10.600.40.33', #   fmw1.example.com
'10.600.40.34', #   fmw2.example.com
'10.600.40.29', #   oid1.example.com
'10.600.40.30', #   oid2.example.com
'10.600.40.35', #   web1.example.com
'10.600.40.36', #   web2.example.com

While it may take a little trial and error to capture the right set of commands in the macro to accomplish the transforms you want, the time and effort saved over a large file is well worth it. That watching your macro work through your file is fun too, is icing on the cake.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Fun With Bash Shell Parameter Expansion

Permalink - Posted on 2016-02-09 04:45

Recently I switched back to bash from zsh for my shell environment. I needed a consistent shell on my local machines as well as on remote servers. One aspect of my bash environment that wasn't working the way I wanted was displaying the current Git branch and Git status information when the current directory was Git controlled.

In my original attempt at building my prompt I combined PS1 and prompt_command. This worked on OS X machines, but not on Linux-based operating systems. After splitting apart the line of information I wished to display via the prompt_command from the actual prompt (controlled by PS1), none of the PS1 substituitions were working. Here's the line before:

function prompt_command {
  export PS1="\n\u at \h in \w $(git_prompt_string)\n$ "
}

And here's the code after:

function prompt_command {
  printf "\n$(id -un) at $(hostname) in ${PWD} $(git_prompt_string)"
}

The PROMPT_COMMAND is set to the function above, and the PS1 prompt has the $:

export PROMPT_COMMAND=prompt_command
export PS1="\n$ "

Instead of using \u for the current user, I'm using id -un. For the hostname, hostname rather than \h. And PWD displays the current working directory in place of \w.

The problem with PWD is that it displays the full path, and I wanted a ~ when in my $HOME directory. Fortunately Steve Losh has already solved this puzzle in his My Extravagent Zsh Prompt posting.

Here's the solution:

${PWD/#$HOME/~}

It's deceptively simple, and took me a few minutes to understand, with the help of the Shell Parameter Expansion section of the Bash Manual.

The pattern ${parameter/pattern/string} works in the following manner.

The pattern is expanded to produce a pattern just as in filename expansion. Parameter is expanded and the longest match of pattern against its value is replaced with string. If pattern begins with ‘/’, all matches of pattern are replaced with string. Normally only the first match is replaced. If pattern begins with ‘#’, it must match at the beginning of the expanded value of parameter. If pattern begins with ‘%’, it must match at the end of the expanded value of parameter. If string is null, matches of pattern are deleted and the / following pattern may be omitted. If parameter is ‘@’ or ‘’, the substitution operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with ‘@’ or ‘’, the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.

What all that means is $HOME is expanded and if it matches the expanded $PWD, starting at the beginning of the string, then the matching characters are replaced with a ~. The key is the # before $HOME.

Here's the final printf line:

printf "\n$(id -un) at $(hostname) in ${PWD/#$HOME/~} $(git_prompt_string)"A

You can see the complete .bashrc file in my dotfiles repository.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Installing My Dotfiles Via A Script

Permalink - Posted on 2016-01-30 21:47

For too long now I have been putting off creating a script to setup my collection of dotfiles on a new machine. My excuse has always been, "I don't need to set them up on a new machine that often." Still it would be nice to run one command rather then enter multiple ln -s ~/.dotfiles/... ... commands in a row.

Here's my make.sh script:

#!/usr/bin/env bash

#
# This script creates symlinks for desired dotfiles in the users home diretory.
#

# Variables
dotfiles_dir=~/.dotfiles
dirs="bash gem git openconnect tmux"

# Update dotfiles to master branch
echo "Updating $dotfiles_dir to master"
cd $dotfiles_dir;
git pull origin master;
cd;

echo ""

function makeLinks() {
  # For each directory in dirs, make a symlink for each file found that starts
  # with a . (dot)
  for dir in $dirs; do
    echo "Linking $dir files"
    cd $dotfiles_dir/$dir;
    for file in *; do
      ln -svf $dotfiles_dir/$dir/$file ~/.$file
    done
    echo ""
  done

  # Handle odd-ball cases
  # Vim files¬
  echo "Linking vim files"
  ln -svf $dotfiles_dir/vim ~/.vim;
  ln -svf $dotfiles_dir/vim/vimrc ~/.vimrc;
  ln -svf $dotfiles_dir/vim/vimrc.bundles ~/.vimrc.bundles;

  # ssh
  echo ""
  echo "Linking ssh configuration."
  ln -svf $dotfiles_dir/ssh/config ~/.ssh/config

  echo ""
  echo "Caveats:"
  echo "Vim:  If remote server, rm .vimrc.bundles"
  echo "Bash: If local server, rm .bashrc.local"

  echo ""

  echo "Finished."
}

if [ "$1" == "--force" -o "$1" == "-f" ]; then
  makeLinks;
else
  read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1;
  echo ""
  if [[ $REPLY =~ ^[Yy]$ ]]; then
    makeLinks;
  fi;
fi;
unset makeLinks;

Some Caveats:

  • This script works for the way I have my dotfiles arranged in ~/.dotfiles. Each tool has a directory containing the file or files that make up the configuration. None of the files are preceeded by a dot (.) in my repository, so the link command adds that.

  • My Vim configurtion and my ssh config don't follow this pattern, so they are handled separately.

The dirs variable has a list of the configurations I want to setup using this script. All of the files in each of those directories is symlinked in turn. I'm using the -svf flags on the ln statement.

  • s for symlink, of course
  • v for verbose
  • f for force if the link already exists

To make the script a scant more friendly it offers a --force option, that eliminates the "Are you sure?" prompt.

As with any script you find laying around on the Internet, read the source and understand what it's doing before unleashing it's awesome powers on your computer.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Bash History Search Bind Keys

Permalink - Posted on 2016-01-27 00:02

I recently switched back to bash shell from zsh and in doing so I lost zsh's history search. From your zsh prompt if you type in part of a command and then press the up arrow, you'll be shown the previous occurrence of that command. Repeated up arrows walk you through all previous occurrences. A very handy tool, and one I grew fond of.

Here's how to have this history search in bash.

First use the read command to learn what code is transmitted by the up or down arrow key press.

$ read
^[[A  # up arrow
^[[B  # down arrow

Control-c will return you to your prompt from the read builtin command.

Parsing the up and down arrow strings reveals that they both start with an escape character ^[ and then the key value itself: [A or [B.

The bash function to search history is history-search-backward or history-search-forward. So binding ^[[A to history-search-backward and ^[[B to history-search-forward emulates the arrow key behavior from zsh.

Here is what I have in my .bash_bindkeys file, which is sourced from my .bashrc file.

bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'

The \e is the escape character (^[) from the read builtin output. With these bindings in my .bashrc I can enter part of a command and search back through my history using my arrow keys.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


2015 Books

Permalink - Posted on 2015-12-30 21:22

I read or listened to a total of 123 books in 2015. 40 were brand new to me, the other 83 were rereads or re-listens.

The longest book was Neal Stephenson's "Seveneves: A Novel" at 880 pages.

The shortest was "The Countess of Stanlein Restored: A History of the Countess of Stanlein Ex Paganini Stradivarius Cello of 1707", a history of a Stradivarius cello at 120 pages.

In total I read 39,160 pages, or 108 pages a day average for the year.

17 of the titles on my list were audio books. The longest of these was (again) a Neal Stephenson book, "Reamde" at 38 hours and 34 minutes.

The shortest audiobook was a mere 9 hours; "The Hanged Man's Song" by John Sandford.

In total I listened to 249 hours and 41 minutes of audio books this year. Which works out to 41 minutes per day average.

Ten of the books were non-fiction, eight were science fiction, one was historical fiction, and the rest fiction. Thirty-one of the books were from our local public library, the rest I own in one format or another.

Out of all the books I read or listened to this year, Andy Weir's "The Martian" was far and away my favortie book. Not only did I read it multiple times, I listened to the audio version. And I saw it in the theater when it came out. And I bought a copy on iTunes that I've now watched twice in a row. It's easily one of the very best books I've read in a long, long time.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Solidarité

Permalink - Posted on 2015-11-14 17:50

solidaité


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


How to Spell Check with Vim

Permalink - Posted on 2015-10-02 19:47

I have never been a good speller, therefore I rely on spell check to help ensure that my writing doesn't contain basic spelling errors. Most modern software that is centered around text provides spell checking. However I do most of my writing, including all of the posts on Zanshin.net, using Vim - a decidedly un-modern text editor.

Fortunately Vim is incredibly flexible and it is relatively straight-forward to enable spell checking.

Enable spell checking

You can turn spell checking on or off with

set spell
set nospell

Default language

The default language used is US English. You can change this to another language with

set spelllang=en_gb

The above example sets the language to British English.

In my .vimrc I have a number of file type specific settings, including spell checking. I only enable spell checking for a limited number of file types, as spell checking code isn't very useful. The three autocmd entries I have are:

autocmd FileType mail setlocal spell spelllang=en_us
autocmd BufRead COMMIT_EDITMSG setlocal spell spelllang=en_us
autocmd BufNewFile,BufRead *.md,*.mkd,*.markdown set spell spelllang=en_us

The first is for when I'm using mutt for my mail - it turns spell checking on while I'm composing or replying to messages. The second activates spell check for Git commit messages. The last autocmd set spelling on for Markdown files.

Your own dictionary

It is possible to add words to your own dictionary using the zg key combination. You can undo the add with zug. It is also possible to mark a word as incorrectly spelled using zw. zuw undoes the incorrect marking.

Find misspelled words

You can jump forwards or backwards through the buffer to the next flagged work using

]s
[s

Once you've located a word, z= will bring up the list of suggested words, pick the associated number and press return and the new word will be substituted in for the old one.

Help

All of this and more can be found in the Vim help pages

:help spell

You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Change sshd Port on Mac OS X El Capitan

Permalink - Posted on 2015-10-01 22:01

Previously I had written about how to change the sshd port for Mac OS X Lion and Mountain Lion. The basic premise is still the same, but the introduction of El Capitan's System Integrity Protection (SIP) requires a slightly altered approach to having sshd running on an alternate port.

In a nutshell the controlling plist, /System/Library/LaunchDaemons/ssh.plist, can no longer be edited. So instead you need to make a copy of this file and store it elsewhere. In my case I put it in /Library/LaunchDaemons. Then using launchctl you can cause your new plist to be started whenever the computer is booted. The detailed steps follow.

Create a copy of the plist

Copy ssh.plist using sudo and rename it to ssh2.plist. The renaming is important, otherwise launchctl won't discriminate between your plist and the official one, which will result in your alternate port not being visible.

$ sudo cp /System/Library/LaunchDaemons/ssh.plist /Library/LaunchDaemons/ssh2.plist

A new Label and a new port number

There are two changes to make in the plist. First it needs a different label to distinguish it from the original, and second it needs to specify the alternate port you wish to use.

Provide a different Label for the plist by changing this:

<key>Label</key>
<string>com.openssh.sshd</string>

to this:

<key>Label</key>
<string>com.openssh.sshd2</string>

Setting the port number to your alternate by changing the SockSeviceName string (ssh) to the port number you want to use. In other words, change this:

<key>SockServiceName</key>
<string>ssh</string>

to this:

<key>SockServiceName</key>
<string>99999</string>

where 99999 is a valid port number.

Activate your new sshd port

Using launchctl you can launch a new instance of the sshd daemon, one that listens to your alternate port. The launchctl command to do this looks like:

$ sudo launchctl load -w /Library/LaunchDaemons/ssh2.plist

If you ever wanted to unload this plist, run this command:

$ sudo launchctl unload /Library/LaunchDaemons/ssh2.plist

To verify that your new port is being listened to, run

$ netstat -at | grep LISTEN

Your new sshd port should be listed.

Caveats

As always, making changes to the murky innards of your operating system and its supporting configurations can be risky. Make copies, backup before making changes, and proceed with caution. It is worth noting that this setup does not turn off port 22, it merely allows access on an alternate port. The machine I did this to is behind my employer's boarder and firewall which blocks port 22 traffic.

References

I made use of the following resources for this posting.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Power to Weight

Permalink - Posted on 2015-08-31 02:43

With a new 2016 MINI Cooper S making its way to me I've been thinking a lot about cars lately. The Cooper S has a reputation for being quick and nimble. It boasts a sub-seven second zero-to-sixty time. I was curious how the MINI compared to the other cars I've owned. Some Internet searching and a spreadsheet later and I had my answer.

Year Make/Model Engine (cc) Weight (lbs) Horsepower Torque (ft-lb) lb/HP
1984Pontiac Fiero247124629213426.76
1987Honda Prelude1958241011011421.91
1992Mazda Navajo3958398015522025.68
1994BMW 318i1796335213812924.29
1992Lexus ES 3002959336218519518.17
1999Nissan Altima2389285915015419.06
2000Lexus ES 3002995335121022015.96
2001Audi TT Coupe1781320818017317.82
2001Lexus LS 4304300395529032013.64
2010Honda Insight133927349812327.90
2016MINI Cooper S2000278518920714.74

With the exception of the 2001 Lexus LS 430, the MINI Cooper S has the best power-to-weight ratio of any car I've owned. The 430 had a monster 4.3 liter engine, more than twice the size of the MINI's 2 liter engine, but it's also roughly 1200 pounds heavier. I think the MINI will feel faster, and it'll certainly corner better.

The best power-to-weight ratio vehicle I've ever owned was a 1987 Suzuki Katana 1100F. With a dry weight of 537 pounds and 136 horsepower, it's ratio is 3.95 pounds-per-horsepower. Incredibly fast with instant acceleration at any speed. Not much fun in the winter though, and no room for a cello.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


32 Years of Cars

Permalink - Posted on 2015-08-16 14:35

I bought my first car 32 years ago, and I am buying my 11th car in a few weeks. Here is a list of all the cars I've owned.

  1. 1984 Pontiac Fiero
  2. 1987 Honda Prelude
  3. 1992 Mazda Navajo
  4. 1994 BMW 318i
  5. 1992 Lexus ES 300
  6. 1999 Nissan Altima
  7. 2000 Lexus ES 300
  8. 2001 Audi TT Coupe
  9. 2001 Lexus LS 430
  10. 2010 Honda Insight

Car number 11 will be a 2016 MINI Cooper S in Volcanic Orange with a black roof and mirror caps. The car has been built and is currently be loaded on a ship for transport to the US. The dealer thinks I'll have it by early September.

For completeness sake I've also owned three motorcycles.

  1. 1986 Yamaha Riva 180
  2. 1988 Yamaha Radian 600
  3. 1988 Suzuki Katana 1100F

You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Buying a Car Via Email

Permalink - Posted on 2015-08-14 03:03

Buying a car can be stressful. It's a lot of money and, unless you are very well off, a financial obligation for years to come. American dealerships have a checkered past when it comes to the whole buying experience. Everyone has heard horror stories of hours-long slogs through high-pressure sales tactics. Buying our 2016 MINI Cooper S involved none of that.

The MINI USA website has a wonderful Build and Price a MINI tool that lets you select the model car you want and then tweak endlessly the options, packages, and dealer add-ons you desire. Best of all you can save these builds in your own online garage for further tweaking later.

As a part of the saving process you can produce a PDF file with all the details of your MINI -- interior and exterior options, colors, fabrics, wheels, you name it -- and a specifications sheet that lists the cryptic dealer codes for those options. After days (weeks, really) of tweaking and tuning, I had the set of options I wanted. With an email to the dealer I was able to initiate a new car order, I just attached the PDF.

The dealer sent me a deposit authorization form that I filled out and faxed back, along with my credit card number, and the car was ordered. No pressure, no hassel, no "what will it take to get you into this car today" tactics. After the order was placed the saleswoman sent me a scanned copy of the order to confirm the vehicle was what had been ordered. Except for the delivery time (6 - 8 weeks) it was almost Amazon-like. One-click, prime delivery cars would be amazing.

We did make a trip to the dealer about 10 days after the order was placed to have our trade-in appraised and to ask some questions about finance options. The dealer was informative and casual, no pressure whatsoever.

In (hopefully) a few weeks the car will be delivered and we'll make a final trip to sign papers and collect our new MINI. Concluding the easiest new car purchase I have ever made.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


MINI Statuses

Permalink - Posted on 2015-08-12 12:31

Updated: 8/21/2015 - En Route status reached
Updated: 9/2/2015 - At Vehicle Distribution Center status reached
Updated: 9/8/2015 - At Your MINI Dealer status reached

After a lot of shopping we've decided to get a new car. We're replacing our 2010 Honda Insight with a 2016 MINI Cooper S. To say that I am excited by this is an understatement. Ever since the "new" MINI was released in 2000 I've been a huge fan, and, after test driving one last November, I haven't been able to stop dreaming about one.

I'll write more about the MINI itself after it gets here, right now I'm having fun with the MINI Owner's Lounge website, which allows you to track your car's progress through the building and delivery process. Currently our MINI is "awaiting transport". Here are all the statuses, in order.

On Order - July 23, 2015

Welcome to the MINI clan. The order for your new MINI is in and waiting to be scheduled for production While you await the day that you will be united with your MINI, you can come back here to check on how it's doing and what stage of the process it has reached.

Scheduled for Production - July 29, 2015

Your MINI has been scheduled for production and will begin to move through the "birth canal" at our Oxford plant, one of the most modern and advanced production plants in all of Europe. With out extremely rigorous quality control standards in place, you should rest well knowing that your baby is in the best of hands.

Awaiting Transport - August 11, 2015

Congratulations! Your healthy and handsome new MINI has been built. A wee bit heavy for any stork, your MINI will now be loaded onto a ship to make its way across the pond. At night, we're sure it'll be dreaming of tearing through twisty turns with aplomb and glee.

En Route to Vehicle Distribution Center - August 21, 2015

Though still adjusting a bit to its sea-wheels, your new MINI wants you to know that so far the cruise has acutally been a blast - great buffets and lots of partying with its brothers. But still, your MINI can't wait to dock, hit the road, and chew up solid ground again.

At Vehicle Distribution Center - September 2, 2015

Your MINI has arrived on U.S. shores and is going through one of its final stages of training and qaulity control at a MINI Vehicle Distribution Center. The center servers as yet another chance for a comprehensive, bumper-to-bumper inspection. It's also where your MINI will be taught not to make fun of Americans who call the "bonnet" a "hood" or the "boot" a "trunk".

At Your MINI Dealer - September 8, 2015

Your MINI is now being transported to your MINI Dealer. We know it's hard, but please be patient just a bit longer. Once it arrives, your dealer wil give it one last shine and a clean bill of health. Then they will call you and set up a time for you to stop by and happily head home in your new MINI.

Last weekend we visited the MINI dealer and learned that our MINI was nearly through the construction process, so I was pleased to get the "awaiting transport" status last night. The dealer said that the usual trans-Atlantic trip is three weeks. I'm hoping that time includes the "awaiting" and "vehicle distribution center" portions of the process. She thought we'd get the car in early September.

Is it September yet?


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Automobile Dealer Experience

Permalink - Posted on 2015-07-19 04:31

My wife and I are contemplating getting a new car. Last weekend and again today we did some test drives. At the first dealership we visited today we had a very good, low-key experience. The salesman met us in the lot, answered our questions, and wasn't overly pushy. Nor did he try to be familiar or ingratiating. After making a copy of a driver's license he let us test drive the vehicle we were interested in.

At the second dealership we had to go inside to find someone, and were then lead to a pint-sized office where a mild interrogation began. Where did we live? Would we be buying the vehicle together or just one of us? After giving the salesman my phone number I watched him access some kind of public records database service to pull up information about me. When he tried to circle back around to the finance question again, I explained that I knew he had a boss and a script, but that we were only interested in test driving a vehicle and that all the other items on his list could wait. He relented and got us a demo model to drive.

One of the dealers was Nissan (where we drove a Rogue) and the other was Ford (where we drove an Edge and an Escape). Prior today I would have bet money, upon hearing a tale like this one, that Ford was the invasive dealer and the Nissan was the low-key one. It was exactly the opposite. Ford was relaxed and pleasant while Nissan felt invasive and heavy handed.

As a member of the information technology industry I am very well acquainted with the idea of user experience. Car dealerships have a history of very poor, adversarial, user experiences. Particularly American marquee automobiles. After today's experience I am ready to believe that American car companies have improved their approach to treating customers, and that the off-shore brands are falling behind.

At least for the two dealerships we visited today, the Ford dealer beat the Nissan hands down for the user experience.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Apple Watch

Permalink - Posted on 2015-04-12 03:48

After getting up at 2 am on Friday to purchase a 42mm Space Gray Sport Watch with the black band, I scheduled an appointment to see the Apple Watch in person for Saturday at my nearest Apple Store, some two hours drive away.

This was my first time buying an Apple product at the moment of its release and I made a tactical blunder that cost me about 2-4 weeks delivery time. I forgot to change the credit card on my Apple account ahead of time and therefore had to make that change at 2:01 am when the store came back up. At first I tried to make this update via my iPad Air 2, but I couldn’t get past the phone number formatting, so I ended up wasting more time doing it on my laptop.

My order was placed at 2:09 am and already the shipping date had slipped from April 24 to at least May 13. I will be taking pains to have my account ready ahead of time this autumn when the new iPhone goes on sale.

The Country Club Plaza Apple Store was fairly crowded when I arrived about 15 minutes early for my try-on appointment. However I only had to wait a few minutes before I was led over to the side of the store for my trial. I requested to see a 42mm Sport watch with the black fluoroelastomer band, and one with the leather loop band. The Apple Store employee (whose name has escaped me) first put the sport band watch on my arm and then had my double-press the button on the side of the watch. This started a preprogrammed demo of the watch. The demo was not interactive, but did show off the watch’s interface and taptic capabilities.

Next he put the leather loop band on. It was fastened to a stainless steel watch. I had read some reports that the leather loop wasn’t as soft was advertised, and while I agree it isn’t the most supple leather in the world, I liked how it felt on my wrist.

Holding the two watches, one in each hand, I could discern that the stainless steel one is slightly heavier, however in the brief period of time that I had them on, I really couldn't tell that it was heavier. After trying the Sport model on with the fluoroelastomer band I was convinced I had made the right purchase choice. I am very tempted by the leather loop band and will likely order one of those. The sport band has a small metal post that holds the band in place and I'm worred that it will mar the wrist rest on my MacBook Pro. The leather loop band has no metal that would mar the laptop. However I may wait until I have the watch to purchase a second band for it.

I asked about the strength of the taps on the wrist, could they be adjusted. The clerk didn’t know. Later, when I was exploring the demonstration watches embedded in a little stand with a screen to explain various features, I discovered a setting that would make some taptic taps stronger.

I also asked if the bands could go on the watch either way. I.e., could the two halves of the band be attached to either the top or the bottom of the watch. That answer is yes. Also, in the settings you can specify which wrist the watch is on, left or right, and which side the crown is on, left or right. You could set up the watch on either wrist with the crown on the elbow side or the hand side. On the elbow side you’d use your thumb on the crown, whereas on the wrist side you’d use your forefinger on the crown.

The crown is amazing. It has a wonderfully smooth action, that has just the right amount of drag. Pressing it once takes you to the home screen. Pressing it twice in succession lets you bounce back and forth between the last two apps you visited.

After my trail fitting was over I spent a good 30 minutes exploring all the apps on the demo watch. Not everything was turned on. Those things that required being mated with a phone (remote camera features) were not enabled. I was most intrigued by the fitness apps. I wear a Fitbit Flex and I am very interested to see how the activity tracking the Apple Watch provides compares to the Flex.

I have wanted an Apple Watch since they were announced last autumn, and after trying a couple on today and after exploring the demo watch, I am even more anxious to have one of my own.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


19 Years

Permalink - Posted on 2015-02-20 18:39

Zanshin.net is 19 years old today.

$ whois zanshin.net | grep Creation
Creation Date: 1996-02-20T05:00:00.00Z

I've lost track of the number of major revisions my site has had in that time, but I do know that it has gone from hand-coded to Blogger to MoveableType to Wordpress to Octopress and finally to Jekyll.

In addition to the main domain, there are three subdomains. Geek a semi-frequently updated link-list of technology sites. You can drag-and-drop the sections. Books is a listing of all that I've read this year. Includes audiobooks too. And Health is a record of my daily exercise, calories, and weight.

In terms of numbers there are (approximately) 653,754 words in the postings (not counting this one), and this post will be number 2,158. The site's readership has steadily increased each year now for several years. Currently I average about 550 visits per day or 14,000 per month, give or take.

Here's to another 19 years.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Arch Linux on a MacBook Pro Part 4: System Configuration

Permalink - Posted on 2015-02-06 04:51

Introduction and Motivation

This is the fourth part in a series on dual booting Arch Linux and Mac OS X on a MacBook Pro. This part covers setting up Xorg, getting the Nvidia graphics sub-system working, and installing Gnome and Awesome. At the end the is a bibliography of some of the many sites I used as references. Part One covered creating a bootable USB drive with the Arch Linux installer. Part Two discussed how to prepare the MacBook Pro. Installing the base Arch Linux operating system and getting the dual boot between Arch and OS X working was covered in Part Three.

My day job has transitioned to system administration and infrastructure automation (Chef!). All of our virtual infrastructure (with rare exceptions) is based on Linux so I am keenly interested in learning more about its underpinnings. Setting up Arch Linux and sorting through its configuration challenges seems like a good way to jump into the deep end of the Linux pool.

Arch Linux on a MacBook Pro Part 1 - Creating a USB Installer
Arch Linux on a MacBook Pro Part 2 - Preparing for Dual Boot
Arch Linux on a MacBook Pro Part 3 - Base Installation
Arch Linux on a MacBook Pro Part 4 - System Configuration

Setup Wireless

You need to download the proprietary Broadcom driver, and then make a package, and finally install the package. (I did this under the chroot used to setup Arch, but didn't test it until the base install was completed and I was logging in via my account. Consequently you may need to use sudo for some of these commands.)

$ mkdir src
$ cd src
$ wget https://aur.archlinux.org/packages/br/broadcom-wl/broadcom-wl.tar.gz
$ tar xf broadcom-wl.tar.gz
$ cd broadcom-wl/
$ makepkg -s

Note: If you are doing this under the chroot you'll have to su to the user account you created earlier to run the makepkg command.

Next use the packman command below to install the newly made package.

$ pacman -U /tmp/usb/broadcom-wl-6.30.223.248-4-x86_64.pkg.tar.xz

After the package installation, load the kenel modules necessary for WPA2 connections

$ modprobe wl lib80211_crypt_tkip

Finally use the wifi-menu command to connect to a wireless network. Note: you may have to install some dependencies via pacman -S <dependency>.

64-bit Pacman

In order to make the library of 64-bit wrapped 32-bit applications available edit /etc/pacman.conf and uncomment the multilib lines. Then update the system using:

$ pacman -Syu

More packages

Next install all the basic utilities needed to build 32-bit or 64-bit packages.

$ sudo pacman -S multilib-devel fakeroot git jshon wget make pkg-config autoconf automake patch

Press enter to install all members in group multilib-devel. And say yes to removing those packages in conflict.

AUR

The "Arch User Repository" is a user-managed package repository with a huge number of packages. To access it install packer, which uses the same command syntax as pacman. I create a src directory in my home to hold such things as this.

$ mkdir src
$ cd src
$ wget http://aur.archlinux.org/packages/pa/packer/packer.tar.gz
$ tar xf packer.tar.gz
$ cd packer
$ makepkg -s
$ pacman -U packer-20140817-1-any.pkg.tar.xz

Sound

ALSA works out of the box with Macs so install it via:

$ pacman -S alsa-utils

Then use

$ alsamixer

to control the speakers. Make sure to disable channels for speakers you don't have. Test your speakers with

$ speaker-test -c 2

where 2 is the number of speakers.

Xorg

Setting up Xorg will enable your video card, trackpad, backlight, et etera.

Install the base packages for Xorg, using:

$ sudo pacman -S xorg-server xorg-xinit xorg-server-utils xorg-server-devel mesa. 

Note that the mesa package is included for 3D support, if you do not have a 3D capable graphics card you can skip this package.

NVIDIA

Getting the NVIDIA card working was the hardest part of the install for me. In the end I used the Nouveau driver as the Nvidia ones didn't work. Follow the instructions on the Nouveau page and you should be okay.

At this point you will need to reboot your machine to load the proper kernel modules and module blacklists.

Desktop

There are lots of choices in each of the three major desktop manager categories (stacking, tiling, and dynamic). To try something completely different I decided to install Awesome as well as Gnome.

Gnome

Awesome didn't so much work out of the box, so I installed Gnome.

$ pacman -S gnome gnome-extra

It will install lots of packages which, depending on your download speed, may take a while.

This command:

$ sudo systemctl enable gdm.service

will set Gnome to start when you boot your computer.

Awesome

One of the many postings I used to figure all of this out talked about Awesome, and since I'd never seen it before I thought I'd give it a try.

Start off by getting some fonts:

$ pacman -S ttf-dejavu ttf-ubuntu-font-family

Then install awesome from the official respoitory.

$ pacman -S awesome

Now you can select which desktop environment you want when you sign in, either Gnome or Awesome. You'll want to read the Awesome wiki and documentation, as out of the box it provides no configuration.

Conclusion

I've only scratched the surface of configuring and using Arch Linux. But I now have a capable machine running both OS X and Arch with which to learn.

I relied heavily on a large number of websites to figure all of this out. These are the most heavily used.

Dual Boot Arch Linux on MacBook Pro Installation

Arch Linux on MacBook Pro Retina 2014 with DM-Crypt, LVM and suspend to disk

Arch Linux: System Installation

Arch Linux: From Post-Install to Xorg

Awesome

Xorg

Swap

Disable clearing of boot messages

root partition read only after update systemd

Failed to start Remount Root and Kernel File System (systemd)

Blkid returns nothing, but has no error

I highly recommend reading the Arch Beginners's Guide. The #archlinux IRC channel is vibrant and can also be a source of help.

Feedback

If you've gotten this far in the series and or if you've successfully (or not) tried to dual boot a MacBook Pro with Arch, I'd love to hear from you. You can reach me via email link in my sidebar.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Arch Linux on a MacBook Pro Part 3: Base Installation

Permalink - Posted on 2015-02-06 04:07

Introduction and Motivation

This is the third part in a series on dual booting Arch Linux and Mac OS X on a MacBook Pro. This part covers partitioning the drive, the base Arch installation, and getting the dual boot setup. Part One covered creating a bootable USB drive with the Arch Linux installer. Part Two discussed how to prepare the MacBook Pro. Setting up the system, configuring Xorg, installing Gnome and Awesome are all covered in Part Four.

My day job has transitioned to system administration and infrastructure automation (Chef!). All of our virtual infrastructure (with rare exceptions) is based on Linux so I am keenly interested in learning more about its underpinnings. Setting up Arch Linux and sorting through its configuration challenges seems like a good way to jump into the deep end of the Linux pool.

Arch Linux on a MacBook Pro Part 1 - Creating a USB Installer
Arch Linux on a MacBook Pro Part 2 - Preparing for Dual Boot
Arch Linux on a MacBook Pro Part 3 - Base Installation
Arch Linux on a MacBook Pro Part 4 - System Configuration

Determine the MacBook Pro version

Determine the version of MacBook Pro you have. These instructions are for a Mid 2010 model or 6,2 in Apple parlance. Minor hardware differences may make these instructions not work if you have a significantly different MacBook Pro, e.g., one with a SSD.

Boot from the Arch USB Drive

Insert the USB drive containing the bootable Arch ISO (from Arch Linux on a MacBook Pro Part 1 - Creating a USB Installer) and boot or restart the MBP. Hold the left Option key down until the drive selection window appears.

Select the EFI Boot disk using the arrow keys, and press enter to start.

Select the Arch Linux option from the boot menu, or let the time out do it for you. Once the initial boot completes (should be fairly quick) you see a prompt like this:

Arch Linux 3.17.6-1-ARCH (tty1)

archiso login: root (automatic login)
root@archiso ~ #

Congratulations, you've got root.

Get connected

You'll need to be connected to the Internet to complete the setup. The easiest way is via Ethernet. If you don't have Ethernet available, skip ahead to the Setup Wireless section at the start of Arch Linux on a MacBook Pro Part 4 - System Configuration, and setup wireless now. These instructions assume you have working Ethernet.

Type:

$ dhcpcd

This will start the DHCP client and get an IP address lease from your LAN. You can verify that you have working connectivity by pinging something, Google for example.

$ ping -c 3 google.com

Determine drive mapping

In order to proceed you'll need to know the drive mapping scheme. The easiest way to get that information is via

$ fdisk -l

which lists the existing partitions. If you created two partitions when preparing the MBP, you should see a partition with a Type of Apple HFS/HFS+ with a size that matches the size you set aside for Arch. In my case this was /dev/sda4. All the partitioning commands below will use /dev/sda4, you should substitute the designation for your drive.

Partitioning

Now that we know the drive designation we can use cgdisk tp setup the partitions for our install. Run

$ cgdisk /dev/sda

to see the current state of the disk and to access the partitioning utility. The output will be similar to what is shown below.

Part #  Size      Partition type      Partition name
        3.0 Kib   free space
1       200 Mib   EFI System          EFI system partition
2       78.8 Gib  Apple Core Storage  Macintosh HD
3       619.9 MiB Apple boot          Recovery HD
4       223.4 Gib Apple HFS/HFS+      Untitled 1
        128.0 Mib free space

We are going to add 6 partitons:

Linux boot loader 128 Mib
swap 8 Gib
boot 256 Mib
root 40 Gib
var 12 Gib
home ~160 Gib

The Linux boot loader will later be blessed as bootable using OS X. The final result should look like this:

Part #  Size        Partition type      Partition name
        3.0 Kib     free space
1       200 Mib     EFI System          EFI system partition
2       78.8 Gib    Apple Core Storage  Macintosh HD
3       619.9 MiB   Apple boot          Recovery HD
4       128.0 Mib   Apple HFS+          Linux boot loader from Apple
5       8.0 Gib     Linux swap          swap
6       256.0 Mib   Linux filesystem    boot
7       40.0 Gib    Linux filesystem    root
8       12.0 Gib    Linux filesystem    var
9       163.1 Gib   Linux filesystem    home

To navigate around cfdisk, use the left and right arrow keys to select a command and use the up and down arrow keys to select the partition and/or the free space. Once you have the partitions set the way you desire, select the Write option to create the new partitions.

Begin by deleting the Untitled 1 HFS partition created when you setup the MBP. Next subdivide it into the 6 new partitions. You can use K, M, and G to specify sizes. Accept the starting location offered by the tool when creating a new partition, then enter the size desired. You can use the L option to look up filesystem type codes. Apple HFS+ is af00, Linux filesystem is 8300 (the default), and Linux swap is 8200. Finally give the new partition a name. Repeat for each partition. On the last partition accept the default size offered to use up all remaining space. This means you should do home last to give it as much space as possible.

Select Write and then confirm that you want to overwrite the disk. Once the display returns you can Quit from cgdisk.

Running fdisk -l again should show your new partition scheme. If it doesn't look like you want or expected, repeat the cgdisk process to fix things.

Format the partitions

Now it's time to format the partitions.

$ mkfs.ext2 /dev/sda6
$ mkfs.ext4 /dev/sda7
$ mkfs.ext4 /dev/sda8
$ mkfs.ext4 /dev/sda9

And create the swap and use it.

$ mkswap /dev/sda5
$ swapon /dev/sda5

Note that we skipped /dev/sda4 as that will be setup using OS X later.

Mount the filesystem

In order to acces the new partitions they must be mounted. First mount your root partition.

$ mount /dev/sda7 /mnt

And within the root mount just created, create mount points and mount boot, var, and home.

$ mkdir /mnt/boot && mount /dev/sda6 /mnt/boot
$ mkdir /mnt/var && mount /dev/sda8 /mnt/var
$ mkdir /mnt/home && mount /dev/sdc9 /mnt/home

Install Arch

With the partitions created and formated, and with the filesystem mounted, the operating system can now be installed using pacstrap.

$ pacstrap /mnt base base-devel

This will install ~140 packages and could take a while based on your download speeds. Sit back and watch the progress.

Set fstab

Once the packages are installed it's time to record your file system settings in fstab. Use the genfstab command to generate your fstab

$ genfstab -p /mnt >> /mnt/etc/fstab

You can view the fstab using less

$ less /mnt/etc/fstab

Initial Configuration

Now you can set up your desired hostname, proper time zone, the hardware clock, create a user account for yourself, and enable sudo.

First you need to chroot into the new system.

$ arch-chroot /mnt /bin/bash

Set your hostname.

$ echo arch > /etc/hostname

Set your time zone. I'm in the US Central time zone so I used Chicago. Adjust this to your location.

$ ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime

And set the hardware clock.

$ hwclock --systohc --utc

Create your user account and generate a password for it.

$ useradd -m -g users -G wheel -s /bin/bash you && passwd you

While you're at it, create a root password too.

$ passwd

You'll want sudo installed so that when you are signed in to your account you can run commands requiring root privilege. pacman is the command line package manager for Arch, so we'll use that.

$ sudo pacman -S sudo

Edit /etc/sudoers and uncomment the wheel line. The -G wheel portion of the useradd command above added you to the wheel group. By uncommenting this group in the sudoers file you'll allow all wheel members to run commands as sudo. You need to use visudo to edit this file.

$ visudo

Set your locale.

sudo vi /etc/locale.gen

and uncomment the locales you want. For me this was en_US.UTF-8 UTF-8 and en_US ISO-8859-1.

Generate the locale.

$ locale-gen

And set the /etc/locale.conf and export your settings.

$ echo LANG=en_US.UTF8 > /etc/locale.conf
$ export LANG=en_US.UTF-8

Double check /etc/mkinitcpio.conf to make sure keyboard is after autodetect in the HOOK section.

$ less /etc/mkinitcpio.conf

Then run:

$ mkinitcpio -p linux

Bootloader configuration and setup

This is somewhat confusing. The best way to do this is to boot directly from your MBP's EFI boot loader, which means creating a boot.efi.

Grab the package:

$ pacman -S grub-efi-x86_64

And then, edit /etc/default/grub and alter GRUB\_CMDLINE\_LINUX_DEFAULT to look like this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet"

which I believe is the default setting.

Then you can generate the boot.efi with GRUB which you just installed. You’ll want to put this on a USB device because you’re going to be switching into OS X in a minute.

$ grub-mkconfig -o boot/grub/grub.cfg
$ grub-mkstandalone -o boot.efi -d usr/lib/grub/x86_64-efi -O x86_64-efi --compress=xz boot/grub/grub.cfg

This is going to create a file in the current directory called boot.efi. Copy it to a USB device. Check your devices then make a directory to mount your USB. Copy the boot.efi file onto your USB drive. You may have to determine the path to the USB drive.

$ mkdir /mnt/usbdisk && mount /dev/sdb /mnt/usbdisk
$ cp boot.efi /mnt/usbdisk/

Exit and reboot to OS X

Now you can exit chroot and unmount everything, and reboot back to OS X.

Exit chroot.

$ exit

Unmount all filesystems. And reboot.

$ reboot

Restart the computer and boot into OS X. Run Disk Utility and select /dev/sda4 which is the "Linux boot loader from Apple" partition created earlier. Using Disk Utility erase this partition by selecting "Mac OS X Journaled" and clicking on Erase. This is where the Grub2 image will go.

Open up Terminal and issue the following sequence of commands to create directories and files necessary for this partition.

$ cd /Volumes/disk0s4
$ mkdir System mach_kernel
$ cd System
$ mkdir -p Library/CoreServices
$ cd Library/CoreServices
$ touch SystemVersion.plist

Copy the boot.efi image from the USB drive as a peer to SystemVersion.plist.

$ cp /Volumes/usbdrive/boot.efi .

Edit SystemVersion.plist to look like this:

<xml version="1.0" encoding="utf-8"?>
<plist version="1.0">
<dict>
    <key>ProductBuildVersion</key>
    <string></string>
    <key>ProductName</key>
    <string>Linux</string>
    <key>ProductVersion</key>
    <string>Arch Linux</string>
</dict>
</plist>

Next "bless" the partition so that it is bootable.

$ sudo bless --device /dev/disk0s4 --setBoot

Now when you boot or restart the MBP, a Grub menu with Arch Linux should appear. To boot into OS X you'll need to hold down the left Option key. Test this and make sure it works before proceeding to Arch Linux on a MacBook Pro Part 4 - System Configuration.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Arch Linux on a MacBook Pro Part 2: Preparing for Dual-Boot

Permalink - Posted on 2015-02-06 03:04

Introduction and Motivation

This is the second part in a series on dual booting Arch Linux and Mac OS X on a MacBook Pro. This installment covers the preparation of the MacBook Pro for dual booting. Part One covered creating a bootable USB drive with the Arch Linux installer. Installing the base Arch Linux operating system and getting the dual boot between Arch and OS X working is covered in Part Three. Setting up the system, configuring Xorg, installing Gnome and Awesome are all covered in Part Four.

My day job has transitioned to system administration and infrastructure automation (Chef!). All of our virtual infrastructure (with rare exceptions) is based on Linux so I am keenly interested in learning more about its underpinnings. Setting up Arch Linux and sorting through its configuration challenges seems like a good way to jump into the deep end of the Linux pool.

Arch Linux on a MacBook Pro Part 1 - Creating a USB Installer
Arch Linux on a MacBook Pro Part 2 - Preparing for Dual Boot
Arch Linux on a MacBook Pro Part 3 - Base Installation
Arch Linux on a MacBook Pro Part 4 - System Configuration

Prepare the MacBook Pro

In my case I am maintaining a small OS X installation on the MacBook Pro (MBP) to allow for firmware updates. I used a Yosemite USB boot drive to format the drive and re-partition it. Initially it had one 320 GB partiton, I split that into two: an OS X drive ~80 GB and a second partition for Arch that is about 240 GB.

If you want to keep what is already on the OS X partition you can use Disk Utility to shrink that partition, creating free space for the Arch Linux installation. Just be careful to leave enough free space in the OS X partition for future growth and about 25% unused disk for swapping.

You can also use About This Mac and its System Report option to note the make and model of your video chipset. This will be essential when setting up Xorg at the end of the Arch install.

Once you have the MBP partitioned the way you like you are ready to start the Arch install process. Insert the USB drive you set up in Arch Linux on a MacBook Pro Part 1 - Creating a USB Installer and reboot the laptop. Once the screen goes black, hold down the left Option key under the list of available drives appears. Select the USB drive with the arrow keys and press Enter. Arch Linux on a MacBook Pro Part 3 - Base Installation will take you through the basic Arch install.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.


Arch Linux on a MacBook Pro Part 1: Creating a USB Installer

Permalink - Posted on 2015-02-06 02:51

Introduction and Motivation

This is part one in series on dual booting Arch Linux and Mac OS X on a MacBook Pro. This part covers creating a bootalbe USB installer. Part Two discusses how to prepare the MacBook Pro. Installing the base Arch Linux operating system and getting the dual boot between Arch and OS X working is covered in Part Three. Setting up the system, configuring Xorg, installing Gnome and Awesome are all covered in Part Four.

My day job has transitioned to system administration and infrastructure automation (Chef!). All of our virtual infrastructure (with rare exceptions) is based on Linux so I am keenly interested in learning more about its underpinnings. Setting up Arch Linux and sorting through its configuration challenges seems like a good way to jump into the deep end of the Linux pool.

Arch Linux on a MacBook Pro Part 1 - Creating a USB Installer
Arch Linux on a MacBook Pro Part 2 - Preparing for Dual Boot
Arch Linux on a MacBook Pro Part 3 - Base Installation
Arch Linux on a MacBook Pro Part 4 - System Configuration

Download an Arch Linux ISO

Visit the Arch download site and grab an ISO.

Convert the ISO to UDRW Format

The image needs to be in Read/Write Universal Disk Image Format (UDRW) format. Use the command line tool hdiutil to convert the file.

$ hdiutil convert -format UDRW -o destination_file.img source_file.iso

The resulting image will actually be called destination_file.img.dmg as hdiutil will append that suffix. The file format extension won't matter, so you can ignore it.

Prepare the USB Drive

While some of this can be done using GUI tools, not all of it can, so I'll describe all the steps using the command line.

Find the name of the USB drive

Insert the drive and then run this command:

$ diskutil list

The output will look something like this:

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:          Apple_CoreStorage                         399.5 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   5:                 Apple_Boot Boot OS X               134.2 MB   disk0s5
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS MacOSX                 *399.2 GB   disk1
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 GB     disk2
   1:       Microsoft Basic Data UNTITLED 1              2.0 GB     disk2s1

In this case the USB is /dev/disk2.

Prepare the drive

Prepare the USB by making it all free space. This will delete all data on the USB drive.

$ diskutil partitionDisk /dev/disk2 1 "Free Space" "unused" "100%"

Substitute the proper designation for your USB drive.

Copy the ISO

Now we can copy the converted image to the USB drive.

$ dd if=destination_file.img.dmg of=/dev/disk2 bs=1m

The dd command does not show any output before it has finished the copy process, so be patient and wait for it to complete. When the command does complete OS X will try to mount the drive and fail as it won't recognize the formatting. Click ignore or eject.

Eject the drive

If you clicked ignore above you can eject the drive from the command line.

$ diskutil eject /dev/disk2

Now the bootable image is ready to be used. Proceed to Arch Linux on a MacBook Pro Part 2 - Preparing for Dual Boot.


You should follow me on Twitter. You should also subscribe to @ZanshinNet on Twitter for site updates.