Saturday, 25 February 2017

RPi Raspbian install with Mac


Updated 2017-05-15 !

When starting up a new project with Raspberry Pi I like to start up fresh and with a minimal OS. Therefore i always use Raspbian Lite. Doing it right You don't have to use an external display, keybord and mouse, just the ssh client from Your Mac

Connect the card reader, with the SD card inserted, to Your Mac and format the card with SD Formatter and use the "Owerwrite Formate" option. This will also check that the SD card is OK.

Download the latest OS, as image, from Raspberrypi.org unzip it and put it in Your root directory. The same directory as the one You start in when using the program Terminal

Start the program Terminal, on Your Mac, and check Your SD cards name type

$ diskutil list



and You will have something like

/dev/disk0 (internal, physical):                                              
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *121.3 GB   disk0     
   1:                        EFI EFI                     209.7 MB   disk0s1  
   2:          Apple_CoreStorage Macintosh HD            120.5 GB   disk0s2  
/dev/disk1 (internal, virtual):                                              
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            Macintosh HD           +120.1 GB   disk1    
                                 Logical Volume on disk0s2                  
                                 9519AF9B-4C53-41CE-BB98-1139A7C82D9D        
                                 Unencrypted                                
/dev/disk2 (external, physical):                                            
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *8.1 GB     disk2    

In this case "/dev/disk2" is the name

You now have to unmount the SD card.

$ diskutil unmountDisk /dev/disk2             
Unmount of all volumes on disk2 was successful

and then copy the OS to the SD card using the password to the Mac

$ sudo dd bs=1m if=2017-04-10-raspbian-jessie-lite.img of=/dev/disk2
Password:                                                          
1326+0 records in                                                  
1326+0 records out                                                
1390411776 bytes transferred in 1102.416630 secs (1261240 bytes/sec)

Check with Finder and You will see a nice structure of files and folders.

Create an empty file with the name "ssh", no extension, in the root of the SD card. This will enable ssh before it is actually configured.(See picture above)

Plug the SD card into Your RPi, connect the lan cable and then power it up. It will boot, green led blinks, and after about 2 minutes it schould be visible in Your routers list over connected devices with the name "raspberrypi".

Start Terminal and logon with "ssh"

$ ssh pi@raspberrypi                                                        
The authenticity of host 'raspberrypi (192.168.1.79)' can't be established.
ECDSA key fingerprint is SHA256:lNY6d3pAK5TDO5XLma3k2w0IgOkGBcs1wa1T7QGaXjk.
Are you sure you want to continue connecting (yes/no)? yes                  
Warning: Permanently added 'raspberrypi' (ECDSA) to the list of known hosts.
Warning: the ECDSA host key for 'raspberrypi' differs from the key for the IP address '192.168.1.79'                                                      
Offending key for IP in /Users/xxxxx/.ssh/known_hosts:5                    
Are you sure you want to continue connecting (yes/no)? yes                  
pi@raspberrypi'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.
pi@raspberrypi:~ $

If the name doesn't work with the ssh command use the IP from the routers devicelist instead.

As You see in the log I have used this RPi before and the router is assigning it the same IP but with a new fingerprint(New OS). The easiest way to solve the problem is just to empty the file  "known_hosts" on Your Mac.

And now over to the basic setup and pic the items below. Use up and down arrow to move, left right arrow to select and Enter to confirm

$ sudo raspi-config











And go through the following items

1/ Change User Password
2/ Change hostname
4/ Localisations options
   I1/ Change locale (Swedish sv_SE ISO-8859-1)
   I2/ Change timezone
   I4/ Change Wi-fi Country
5/ Interfacing options
   P2/ SSH Enable/Disable remote command line access to your Pi using SSH
7/ Advanced Options
   A1/ Expand file system
   A2/ Change hostname

then reboot and update the installation with


$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get clean

You schould also check Samba, RPi as a fileserver and RPi as a Apache webserver with PHP.

No comments:

Post a Comment