I recently purchased a BeagleBone Black.  The OS and configuration it ships with is nice and friendly, but I wanted something that I can have real control over.  I went with Ubuntu 13.04 at first, but then I thought about BackTrack, which I quickly realized is now Kali.  And there’s a BBB distribution available.  So after a few days of sleepless nights and lost hair, I present you with my guide to getting Kali Linux working on a headless BeagleBone Black via OS X.

sdxcOne of the first questions I asked myself (and Google) was:  Does the BeagleBone Black support 32 GB microSD cards / SDXC?  I know the SDHC spec says it supports up to 32 GB, but it appears that the 32 GB card I bought is actually SDXC.  At any rate, even though not explicitly stated ANYWHERE (and trust me, I searched), it turns out that the BBB does indeed support 32 GB SDXC cards.  If your 32 GB microSD card isn’t working, it’s likely that there’s a different problem, so read on…

Flashing Your microSD Card

First things first.  Download the Kali BeagleBone Black Image file.

Word to the wise: Before doing anything else, run an SHA1 sum against the download file.  I can’t tell you how long I spent trying to troubleshoot the boot process, only to finally realize that the image I downloaded was corrupt.  To do this in OS X, open Terminal, navigate to the directory containing your image file, and run:

openssl sha1 kali-linux-1.0.5-armhf-bbb.img.xz

For the sake of brevity, I’m only going to refer to the Kali BBB image filename; replace this with whatever image file you’re using.  The SHA1 sum should be 308c944217bc43ff3fc255a26d8aa3a7347851d6.  The download page says it’s something else, but the download page is wrong.  This forum page has the correct ones.  Also, I was never able to download this file directly in Chrome – it kept dying near the end, so I resorted to using a download manager – specifically aria2 installed via Homebrew.

Since I already had Ubuntu on there I no longer had to hold down the User Boot button (which was good, cuz I rebooted A LOT in order to finally get it up and running).  If you’re running Angstrom, you’ll need to hold this button down every time you want to boot from the microSD.  I highly recommend that you flash Ubuntu onto the eMMC before doing anything else so that you can avoid this tedious step every time you boot up.

So your download image is good and you’re ready to go.  In order to flash the SD card, first check in Finder and make sure that no partitions are mounted.  If they are, eject them.  Then run:

diskutil list

This will give you an output that looks something like:

   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            399.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:       Microsoft Basic Data BOOTCAMP                100.0 GB   disk0s4
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *31.5 GB    disk1
   1:             Windows_FAT_32 NO NAME                 128.0 MB   disk1s1
   2:                      Linux                         7.2 GB     disk1s2

In this example, all of the disk0 references are my Mac’s HDD, and the disk1 references are my SD card.  Please make absolutely sure that whatever you reference below is really your SD card, or you might cause some serious problems on your Mac. Like destroying partitions/data.  In other words, don’t just blindly copy what I’ve written.  Caveat emptor.

First unmount your SD card:

sudo diskutil unmountDisk /dev/disk1

Then flash the image onto your SD card by running the following:

xz -cdvv kali-linux-1.0.5-armhf-bbb.img.xz | sudo dd of=/dev/rdisk1 bs=512k

Where /dev/rdisk1 is the raw version (hence the “r”) of /dev/disk1. The raw disk is much faster to write to.

This takes awhile, so now it’s time to move on to the next step.

Setting Up Your Kali Virtual Machine

So while this is happening, why don’t you download VirtualBox and a Kali ISO.  I chose the 32-bit version as I thought I’d run into less compatibility issues running it in a VM.  The reason I went with Kali instead of another Linux distro was so that I could test things out in VirtualBox, see what changes occurred, and apply them to my SD card.  Note that I tried to do this in Parallels, but with current Macbook Pro models this is impossible with the internal SD reader since it’s connected via SATA instead of USB.  Just trust me on this and download VirtualBox.

Follow these fantastic instructions on how to get Kali installed on VirtualBox.  It seems like it should be straightforward, but I had the graphical install crap out on me every time I tried, and wouldn’t have known about the PAE/NX option otherwise.

Once Kali is installed, shut it down.  Hopefully your SD card is done flashing by now.  You can try popping it into your BeagleBone, connecting an ethernet cable and powering it up (mine worked fine with just USB power).  After a minute or two you’ll see that another device is now on your network (check your router/DHCP logs, or use nmap [installed via Homebrew] to scan before and after).  That’s great, but the SSH daemon is not enabled.  And if you’re like me and it’s headless, you’re stuck.  This is where your VirtualBox image comes in.  The filesystem that Kali uses is ext4, and I know of no way to write to that filesystem under Mountain Lion, which is why we need the VM.

Before restarting your Kali VM, you need to set up your SD card so that the Kali VM sees it has a hard drive.  Thanks to this excellent SuperUser answer I was able to make this work without blowing up my hard drive.

Assuming you’re working with /dev/disk1 as above, first unmount /dev/disk1s1 (OS X likes to mount it automatically since it can read the filesystem).

diskutil unmount /dev/disk1s1

Next you’ll need to take ownership of the SD card and all of its partitions.  In the example above, and with “gecko” as my Mac username, I would type:

sudo chown gecko /dev/disk1
sudo chown gecko /dev/disk1s1
sudo chown gecko /dev/disk1s2

Note that every time you eject and re-insert the SD card, you’ll need to go through the unmounting and chown instructions above in order to mount it in VirtualBox, and your guest OS will need to be powered off when you do.

Now you need to create a VirtualBox vmdk for your SD card.  Run the following (substituting gecko with your username, Kali with the name of your Kali VM, and /dev/disk1 as above):

VBoxManage internalcommands createrawvmdk -filename "/Users/gecko/VirtualBox VMs/Kali/sdcard.vmdk" -rawdisk /dev/disk1

Just to be safe, run the unmount command again:

diskutil unmount /dev/disk1s1

Go back to VirtualBox and select Settings for your Kali VM.  Click Storage > Controller: SATA > Add Hard Disk.  Select Choose existing disk and select your newly created sdcard.vmdk.  Now you can restart your VM.  If you get an error on startup about sdcard.vmdk, run the above diskutil unmount command again, then restart your VM.

If you’ve gotten this far, you deserve a beer.  Go get yourself one, then come back.

Editing Your BeagleBone Black Kali microSD

So now you have your Kali VM booted up in VirtualBox.  Open Computer, right-click the 7.2 GB partition that references the ext4 partition on your SD card, then click Mount.  It will be mounted at /media/<some-really-long-guid>.  For brevity I’ll just refer to this as /media/microsd.


Open Terminal on the Kali VM and run the following commands, substituting your path for /media/microsd (just hit Enter when prompted for a passphrase on the ssh-keygen commands):

cd /media/microsd
rm etc/rc?.d/*ssh
ln -s ../init.d/ssh etc/rc2.d/S17ssh
ln -s ../init.d/ssh etc/rc3.d/S17ssh
ln -s ../init.d/ssh etc/rc4.d/S17ssh
ln -s ../init.d/ssh etc/rc5.d/S17ssh
ssh-keygen -t rsa -f etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa -f etc/ssh/ssh_host_dsa_key
ssh-keygen -t ecdsa -f etc/ssh/ssh_host_ecdsa_key

Finally, you need to edit your rc.local file to tell it to start the ssh service. Type:

nano etc/rc.local

Add the following line above exit 0

service ssh start

At the very least this file should have the following lines:

#!/bin/sh -e
service ssh start
exit 0

Hit ^X to save and exit.

You should now be able to shut down your Kali VM, eject your SD card from Finder, pop it into your BBB and boot up that bad boy! If you have an ethernet cable connected and you know the IP address of your BBB you can now ssh into it.

Networking Examples

My network discovery / ssh connection is as follows.  You can ssh from either your Kali VM or your native OS X machine.  The nmap command can be run from your OS X machine if you’ve installed it via Homebrew, otherwise you’ll have to use your VM.  Note that on OS X if you run nmap as root (sudo) with the -sn switch, it will tell you the manufacturer. In the case of the BBB you’re looking for Texas Instruments:

sudo nmap -sn
Starting Nmap 6.40 ( http://nmap.org ) at 2013-09-13 23:26 EDT
Nmap scan report for
Host is up (0.0028s latency).
MAC Address: C8:A0:30:B8:9D:83 (Texas Instruments)
ssh root@
root@'s password: 
Linux kali 3.8.13-bone26.1 #1 SMP Wed Aug 28 17:48:51 CDT 2013 armv7l

The programs included with the Kali GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Kali GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Jan  1 01:19:08 2000 from

Useful Resources

Expanding your Ubuntu microSD partition

How to install new OSes on your BeagleBone Black

Pre-built, auto-flashing Ubuntu image