Raspberry Pi OS Setup using Mac

So, when using a Mac first you want to put the Micro SD card into a SD card adapter and put it in the SD card slot.

Next, when you insert the card into the computer the computer will mount it and begin reading from it. When this happens you will not be able to write the Raspian image to the disk so we need to do some preparation first.

On a Mac go to Launchpad (Icon with a rocketship), click on Other icon, you will get a window with multiple programs (looks kind of like control panel on PC’s) and click on Terminal.

This will give you a command line terminal (like a dos window) that we can type commands on.

When that window comes up type in:

diskutil list

This will give you a list of disks you have attached to your Mac. The SD card should show up at the bottom, but it will be the one that matches the size of your memory card and it should be FAT_32. What we need is the disk number, mine was disk2.

Next we need to go to Launchpad again, then other, then disk utility.

You should see your SD Card in the list on the left and it will have a couple images that look like SD cards indented and underneath it. One will probably say boot, click on that one and up above the unmount button should become active. Click on unmount and the boot label should turn light grey to show that it is unmounted. Now we are ready to write our image to the SD card.

I move the image from downloads to my desktop, but you can put it anywhere you know how to get to from the terminal command window.

By default when you run the terminal program it puts you in your home directory. If you do a list command ( ls ) it will show you all the files and directories where your are at in the directory structure. If you are in you home directory you should see a Desktop directory. I go there ( cd desktop ) and do another ls command.

I should see the 2016-05-27-raspbian-jessie.img file there.

Next we need the command that we will run to move the .img to the SD card. That is on Raspberry Pi’s webpage also.

On the same page you downloaded the .img from there is a link towards the top that says:

installation guide

Click on it and it takes you to another page.

Scroll down and there is a list of different OS types to click on, I click on Mac OS.

That will take you to another page and you can scroll down and you will find.

sudo dd bs=1m if=path_of_your_image.img of=/dev/rdiskn

Copy that line, go to your terminal window, hopefully you are in the directory where the image is, if not make sure you go there first. Then paste the line in the terminal window.

Now we need to edit the line before you press enter. we need to replace rdiskn with the label for our SD card, mine was disk2. Then you need to arrow over to just after path_of_your_image.img and start backspacing to remove it. Then you can type in 2016-05-27-raspbian-jessie.img, or highlight it in your file list and drag and drop it and it will populate the command for you.

So when the command is ready to be executed it will look something like:

sudo dd bs=1m if=2016-05-27-raspbian-jessie.img of=/dev/disk2

I have not researched yet what all the options mean, but sudo is the admin account used for this Linux system that allows you to break….. do things that can really mess things up. You will use this account many times in this tutorial.

After you hit enter, it will ask you for your password (Mac admin password you set up when you first got it) and then it should begin to transfer the .img to the SD Card, it doesn’t give you any info to tell you it’s doing anything, your computer just usually get’s really slow, and it will take awhile.(if you have a PC using it is WAY faster)

If you get a message that says the disk is in use, that means you unmounted the wrong one or didn’t do what I said, so you will need to go back and do that first.

When it’s done the command line will come back and it should give you some info about all the data that was transferred.

After that you need to tell the computer to eject the SD card, this can be done from the Disk Utility program or from Finder.

Now you can take the SD card out of the computer, take the Micro SD card out of the adapter and put it in the Raspberry Pi in the disk slot underneath on the bottom of the motherboard.

when write is complete, eject micro sd card from PC and put in Raspberry Pi

Now we are ready to work on the Raspberry Pi itself.

DO NOT PLUG THE POWER IN FIRST!!!

You can use the Raspberry Pi with just a power cord and a network connection, but you must know the IP Address to do anything and that requires a HDMI capable monitor. You also need a USB Keyboard and Mouse. So after you have the Network cable, HDMI cable, Keyboard and Mouse plugged in, plug in the power.

Things should begin to fly across the screen.

Then towards the end it will show your IP Address you need, but then it will instantly start the windows like interface and you won’t have time to read the Address, that’s fine, we will get it in a minute.

When it is done booting you can click on the Terminal app in the top left (looks like a monitor with a black screen). Once in there you can type ifconfig and it will give you your IP address(inet addr: in the eth0 section if you are using a network cable).

With this information you will be able to log into the Raspberry Pi remotely so you will only need a power cord and a network connection to the Raspberry Pi to administer it via SSH.

To log in to the Raspberry Pi via SSH on a Mac you go to the terminal program and type:

ssh 192.168.1.132 -l pi

replace my ip address with the ip address for your Raspberry Pi, -l means log in I suppose and pi is the user account you want to log in with. It will ask you for the pi accounts password, then you are in! It will put you in the pi accounts home directory.

Or you can use the terminal on the Raspberry Pi.

Open terminal app

Update Raspbian

Upgrade Raspbian

Upgrade can take a while, so watch some TV or do something else for a half hour.

Install Apache Server

Install PHP

Open file to set permissions

Scroll to end of file and add permission line

ctrl-o to save
ctrl-x to exit

Install GIT:

Install GIT

Make a GIT directory in /home/pi (you should already be there)

Go into GIT directory:

GIT directory

Get my files from GIT:

Get my files from GIT

Go into new directory with my files:

Home-Automation-Production

Enter into dangerous admin mode:

sudo su

Copy PHP files:

cp *.php /var/www/html

Copy Python files:

cp *.py /home/pi

EXIT OUT OF ADMIN MODE!

exit

DONE! You can make sure the files are where they need to be if you want:

file check

PHP files

Now you are ready for my apps.

Here is a good video that shows you what I told you:
Getting Started with Raspberry Pi

Old images if you ever need one – http://downloads.raspberrypi.org/raspbian/images/