Tuesday, 3 December 2019

Raspbian install with Mac/Windows/Linux

Updated 2019-12-03 !

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 a ssh client.

Here You find a post with headless WiFi install.

Download the latest OS(with or without Desktop/GUI), as image, from Raspberrypi.org.

Flash SD card with Etcher and a Windows/Mac/Linux client

Download Etcher, install it, open it, and follow the on screen instructions

After the flash, about 3 + minutes, continue with RPi settings below.

There have been a bug with MacOS Catalina and Balena Etcher so use 1.5.67 or later !

Flash SD card with Mac command line

Unzip the image 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                  
/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. There will be no feedback until the copy is ready.

$ sudo dd bs=1m if=2019-09-26-raspbian-buster-lite.img of=/dev/disk2
2096+0 records in
2096+0 records out
2197815296 bytes transferred in 1069.719007 secs (2054573 bytes/sec)

RPi settings

Check the SD card 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)

Adding WiFi connection now ? 

You now have to unmount the SD card.

In a Mac

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

Plug the SD card into Your RPi, connect the LAN cable.

Connect the mouse, keyboard, screen and power. Log on and continue with the configuration below.


Use headless just connecting the power

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".

Or just check with a ping in the Mac Terminal or similar for other OS

$ ping raspberrypi
PING raspberrypi.lan ( 56 data bytes
64 bytes from icmp_seq=0 ttl=64 time=247.129 ms
64 bytes from icmp_seq=1 ttl=64 time=8.676 ms
64 bytes from icmp_seq=2 ttl=64 time=3.914 ms
64 bytes from icmp_seq=3 ttl=64 time=1.865 ms

Start Mac Terminal, or Windows putty, and logon with "ssh" and default password "raspberry"

$ ssh pi@raspberrypi                                                        
The authenticity of host 'raspberrypi (' 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 ''                                                      
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/ Network Options
   N1/ Hostname
   N2/ WiFi
4/ Localisations options
   I1/ Change locale (Swedish sv_SE ISO-8859-1)
   I2/ Change timezone
   I3/ Change Keyboard Layout
   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

update the installation with
$ sudo apt update && sudo apt full-upgrade -y && sudo apt clean

then reboot 

$ sudo reboot

There could be a notice 
xxxxx InRelease' changed its 'Suite' value from 'testing' to 'stable'
which is solved with using 
sudo apt-get update --allow-releaseinfo-change

You schould also check Samba, RPi as a Windows fileserver, RPi as a Apache webserver with PHP and Rasbian lite with GUI, VNC, RDP.

Checking SD-card

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

1 comment:

  1. Pretty! This has been a really wonderful article.
    Thank you for supplying these details.