Raspberry Pi image access from OS X

I've managed to lock myself out of the RaPi - for example, by changing the network address (in /etc/network/interfaces) to one which I can't access.

If you have a HDMI device, keyboard and mouse to hand the problem is easily solved but if you don't you would be looking for a way to correct your mistake and "undo" that last [fatal] configuration change.

There are many other reasons you may want to access the information on the RaPi image, so here is a way you can do it (without spending money):

If you haven't already got it download and install Virtualbox (free).

Download CentOS, create a centOS virtual machine and configure the virtual machine (VM) with a shared folder as below (make sure Auto-mount is set to Yes)

Transfer your RaPi image into the shared folder on your host machine and start your VM.

In the VM (CentOS), start terminal (Menu Applications -> System Tools -> Terminal) and execute the following commands:

sudo su -
mkdir /media/rapi
kpartx -a -v /media/sf_linuxShare/your_rapi_image_name
mount -o rw -t ext4 /dev/mapper/loop0p2 /media/rapi

In executing the above commands you will be asked for the root password and you should see a couple of lines like "add map loop0p1 ……." when you execute the "kpartx" command, these lines should contain the words "loop0p1" and "loop0p2". Find the word "loop…" in the second of the two lines, that's what you need to use in last line.

You should now see an icon on the desktop

This icon represents the RaPi file system, you can double click on it to browse or use the File Browser where you also have an eject button. 

Note 1: Although this article is written for OS X it is also applicable for Windows computers. 

Note 2: There is a paid solution called ExtFS for MacOS which allows mounting of the RaPi image in OS X - you can find it here.