Raspberry PI Setup

Setup SD Card

Step 1: Format SD Card to FAT32

In order to setup your Raspberry PI you will need to setup your SD Card. Plug the SD card into your Mac or connect the SD card reader with the SD card inside.

Method 1 Easy Way

Use piBakery  to create a minimum setup for Debian linux.

Method 2 Mac OS Only

Use Disk Utility to simply format the SD Card to MS DOS Fat.

Method 3 Old School Way

We need to format the card to FAT32 : Yes DOS never dies!

Step 2: Copy OS To SD Card

Now we need to find the SD Card by tying the following command:

diskutil list

Find the sd card in the list of drives.

diskutil unmountDisk disk<# of drive>

Download the Raspbian Stretch Lite, unzip it and use the following command to copy the image to the SD Card:

sudo dd bs=1m if=<XXXX-XX-XX-raspbian-stretch-lite>.img of=/dev/rdisk<# of drive> conv=sync

You can use a Control-T to watch the progress.  Mount the image and create an empty file at the root called ssh  to you can ssh into the newly create image.

Eject the SD Card and plug it into a raspberry pi!

Step 3 Update OS

Find the Raspberry PI on the network and ssh into it. The default user name is pi  and the password is raspberry.

sudo apt-get update

sudo apt-get upgrade

Install some handy programs:

sudo apt-get install vim tmux

Step 4 Install Docker

Install packages to allow apt to use a repository over HTTPS:

sudo apt-get install \apt-transport-https \ca-certificates \curl \gnupg2 \software-properties-common

Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

$ sudo apt-key fingerprint 0EBFCD88pub   4096R/0EBFCD88 2017-02-22Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88uid                  Docker Release (CE deb) <docker@docker.com>sub   4096R/F273FCD8 2017-02-22

To also add the edge repository, add edge after stable on the last line of the command.

echo "deb [arch=armhf] https://download.docker.com/linux/debian \$(lsb_release -cs) stable" | \sudo tee /etc/apt/sources.list.d/docker.list

Update OS:

sudo apt-get update

Install a version of Docker that works on RPI:

sudo apt-get install docker-ce=18.06.0~ce~3-0~debian


Part Two

Create Image

Buster Image

Copy image from here.  You can double check to see what version of Debian you are using the following:

lsb_release -a

Determine SD device

diskutil list

or

Copy the image

From Terminal, enter:

sudo dd bs=1m if=path_of_your_image.img of=/dev/rdiskN conv=sync

Replace N with the number that you noted before.

This can take more than 15 minutes, depending on the image file size. Check the progress by pressing Ctrl+T.

If the command reports dd: bs: illegal numeric value, change the block size bs=1m to bs=1M.

If the command reports dd: /dev/rdisk2: Operation not permitted you need to disable SIP before continuing.

If the command reports the error dd: /dev/rdisk3: Permission denied, the partition table of the SD card is being protected against being overwritten by Mac OS. Erase the SD card's partition table using this command:

sudo diskutil partitionDisk /dev/diskN 1 MBR "Free Space" "%noformat%" 100%

That command will also set the permissions on the device to allow writing. Now issue the dd command again.

Enable SSH for Headless Raspberry Pi

Enable SSH on a headless Raspberry Pi (add file to SD card on another machine)For headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card from another computer. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter; it could contain text, or nothing at all.If you have loaded Raspbian onto a blank SD card, you will have two partitions. The first one, which is the smaller one, is the boot partition. Place the file into this one.

Install Docker

Then:

curl -sSL https://get.docker.com | sh

or

Add permission to Pi User to run Docker Commands

Create the docker group.

Add your user to the docker group.

Reboot at this time....

sudo reboot

Test Docker installation

docker run hello-world

Install dependencies

sudo apt install -y libffi-dev libssl-dev

sudo apt-get install -y python3 python3-pip

sudo apt-get remove python-configparser

Install Docker Compose

sudo pip3 install docker-compose

Install ZSH

Yes, we have moved form bash to zsh

apt install zsh

chsh -s /usr/bin/zsh root

If you need to reset the settings

autoload -Uz zsh-newuser-install

zsh-newuser-install -f

.ZSHRC Setup

Install Google Cloud SDK

We use Google Cloud along with AWS to drive our farm.   Google Cloud is used to for development for ARM and Intel platforms along with our core web services.  AWS lambda and Alexa are used to drive automation.

Install Google Cloud SDK

Create Image File

Now we create an image file to be replicated across all of the ARM devices.

Find where the SD Card resides after you insert it into a Mac.

diskutil list

Make disk image, note use diskutil list to figure out what "disk#" to use.

sudo dd bs=1m of=./raspbian-buster.img if=/dev/rdisk2 conv=sync

Then use this command to make our images to be deployed across devices.

sudo dd bs=1m if=./raspbian-buster.img of=/dev/rdisk2 conv=sync