Got your first RASPBERRY PI? Missing a mini-HDMI adapter, or micro-usb
keyboard?Raspberry Pi’s are capable of running just like any
computer, full displays and window management, keyboards and mice, but
you probably don’t intend to set one up on your desk and leave it
there.
More than likely your intent is to use it for a motion-sensitive
webcam, IoT device or intelligent adapter or controller.
Once you have your Raspberry Pi setup and deployed, remote management
will be required, SSH will be ideal, and you probably didn’t want to
install an extra 2.7GB worth of window management anyway.
_HERE’S WHAT WE’LL COVER:_
* _Download Raspbian latest_
* _Format your MicroSD card_
* _Write the image to your MicroSD card_
* _Mount the image_
* _Enable SSH_
* _Configure Wi-Fi_
* _Gracefully eject your MicroSD card_
* _Boot your Raspberry Pi_
Before we begin, it’s worth noting that the steps I’ll cover are
primarily for OS X, however, most of the steps only require small
adaptations for other operating systems.
STEP 1. DOWNLOAD RASPBIAN LATEST
The latest image of Raspbian is available from raspberrypi.org
[https://www.raspberrypi.org/downloads/raspbian/]. We’re going t o
skip the 4+GB Raspbian Jessie with Pixel and go for the svelt 307MB
Raspbian Jessie Lite. Take your pick of the .torrent or .zip flavours.
STEP 2. FORMAT YOUR MICROSD CARD
You’ll want to use a MicroSD card that you can erase for the rest of
these instructions. Disk Utility won’t cut it here, however there is
SD CARD FORMATTER available from SDCardFormatter.com
[https://www.sdcardformatter.com]. Download, install and follow the
straight forward instructions for formatting your card.
Choose “Overwrite Format” and specify a new name for the card, for
this example I called it “RaspberryPi”.
STEP 3. WRITE THE IMAGE TO YOUR MICROSD CARD
These steps are relatively well documented in the Raspbian
installation guide, follow the instructions here for your preferred
host OS.
My take on the OSX instructions (10.12 Sierra in this case) were
straightforward, diskutil list will list connected media, you’re
looking for something like /dev/disk#.
$ diskutil list
$ diskutil unmount /dev/disk#
$ sudo dd bs=1m if=/path/to/raspbian-jessie.img of=/dev/disk#
This is all that was necessary for me, however the instructions were
extensive and provide workaround for issues that I didn’t encounter.
Once the image is written, the boot partition should immediately
become available, however, the root partition will not if you’re
running OS X.
STEP 4. MOUNT THE IMAGE
Now that you have the image written to the MicroSD card, you’ll need
to mount it before you can customize it. This is where things get a
little awkward. OS X doesn’t support Ext filesystems, and needs a
little extra help.
FUSE for macOS (or osxfuse) can help us mount the filesystem, I
previously had osxfuse installed to mount AWS S3 buckets, but the
installation should be straight forward.
With osxfuse installed, we now need to install fuse-ext2 which will
help us mount EXT2/EXT3/EXT4 filesystems. The setup instructions are
relatively straight forward, you may not already have an /opt/gnu/bin
folder, so you may need to create that first.
Additionally, during the e2fsprogs steps, I may suggest symlinking the
files from /opt/gnu/lib/pkgconfig to /usr/local/lib/pkgconfig rather
than copying them to make future cleanup easier.
STEP 5. ENABLE SSH
Assuming you named your boot partition RaspberryPi (as I did above):
$ touch /Volumes/RaspberryPi/ssh
Enabling SSH is as simple as that, Raspbian will look for a file named
ssh on the boot partition at startup and will enable sshd, which by
default is disabled.
STEP 6. CONFIGURE WI-FI
With Step 4 complete, and your root partition mounted under
/Volumes/Raspbian, we’ll need to update the wpa_supplicant.conf with
a network preconfigured.
Edit /Volumes/Raspbian/etc/wpa_supplicant/wpa_supplicant.conf and add
your network to the end of the file:
network={
ssid="Your SSID"
psk="YourWPAPassword"
key_mgmt=WPA-PSK
}
After editing, the file should look something like:
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Your SSID"
psk="YourWPAPassword"
key_mgmt=WPA-PSK
}
STEP 7. GRACEFULLY EJECT YOUR MICROSD CARD
osxfuse will want to hold onto that mounted filesystem, you’ll need
to find the process (Activity Monitor, or ps aux) and kill the
process, you should then be able to eject from Finder.
STEP 8. BOOT YOUR RASPBERRY PI
Insert the MicroSD card into your Raspberry Pi and connect it to
power. If all of the above steps went well, it should start up, enable
sshd, automatically connect to your wifi.
The Raspberry Pi should pick up an IP address from your local DHCP
server, so you’ll either need to guess the IP, or use your router
admin interface to list the connected clients.
Pro-tip: If you’re using an Apple Airport, option-double-click on
your Airport in Airport Utility to view the list of connected clients.
Once you’ve got the IP address of your fresh Raspberry Pi, you’ll
be able to access it via ssh, the default password is raspberry:
$ ssh pi@10.0.1.27
pi@10.0.1.27's password:
The programs included with the Debian GNU/Linux system are free
software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes
with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable
law.
SSH is enabled and the default password for the 'pi' user has not been
changed.
This is a security risk - please login as the 'pi' user and type
'passwd' to set a new password.
Congratulations on setting up your Raspberry Pi! Don’t forget to
change your password!
Edit: Ok, one last step. Adding the ssh file to the boot partition is
only temporary, the file is removed on startup and sshd won’t start
on subsequent startups.
workshop
technology
Start Up
Virtual event
303
Views
27/09/2020 Last update