Installing and configuring a Raspberry Pi

Setup / Installation of a Raspberry Pi

First of all, you have to download the image from https://www.raspberrypi.org/downloads/ :

 

In parallel you can delete and format your SD-card. On am Mac it is quiet easy. Select in the finde the “Programs” and go to “System Utilities”. Click on the “Harddisk Utility”. Be careful! You could delete your HDD of the Mac! This is the recommended workflow:

  1. Put the SD-card in a SD-card reader or in the SD-card slot of the Mac.
  2. Select the Card (NOT you HDD of the Mac)!
  3. Choose these values:
    1. Name: free
    2. Format: MS DOS File System (FAT)
    3. Schema: Master Boot Record

That’s it! In the meantime the download should be finished. You can find the image in the “Downloads” Folder. Now start a Terminal window. You can find it in the utilities folder. Fist of all, switch to the admin mode with root access. In my case it is the “Admin” user.

su Admin
Password:xxxxxxx
bash-3.2$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         499.9 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +499.9 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume SSD_Macintosh           361.9 GB   disk1s1
   2:                APFS Volume Preboot                 20.6 MB    disk1s2
   3:                APFS Volume Recovery                514.7 MB   disk1s3
   4:                APFS Volume VM                      4.3 GB     disk1s4

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *16.0 GB    disk2
   1:                 DOS_FAT_32 EVALUIERUNG             16.0 GB    disk2s1

bash-3.2$ diskutil umountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
bash-3.2$ sudo dd if=/Users/##USER-NAME##/Downloads/2018-11-13-raspbian-stretch-full.img of=/dev/disk2 bs=4m
Password:
load: 1.42  cmd: dd 1171 uninterruptible 0.00u 1.54s
37+0 records in
36+0 records out
150994944 bytes transferred in 20.125403 secs (7502704 bytes/sec)
load: 1.48  cmd: dd 1171 uninterruptible 0.00u 4.72s
118+0 records in
117+0 records out
490733568 bytes transferred in 63.439629 secs (7735442 bytes/sec)
1263+0 records in
1263+0 records out
5297405952 bytes transferred in 675.900108 secs (7837557 bytes/sec)
bash-3.2$ 

If you want to see the status of the installation: Press >CTRL< + t . The installation lasts between 10 and 60 min. Depending on the SD card and the Mac.

If the image is on the SD-card, you have to activate the ssh mode and WiFi. Therefor a file is needed in the root partition -that you can find on the desktop of you Mac. The easiest way is to generate this file is:

 touch /Volumes/boot/ssh

That’s all! Now you can boot the Raspi the first time! But connect it to the LAN, because WiFi is not activated and configured. In the DHCP Service you can find the IP address of the Raspi. Type in the terminal: ssh pi@###ip-address###. The password of the user pi is  > raspberry < .

Some topics that are not mandatory but userful.

Passwort pi reset

sudo passwd pi

Samba configuration

If you want to have the raspberry files in the Finder, you have to configure Samba. Fist of all, install it with this commands:

sudo apt-get update
sudo apt-get install samba samba-common-bin
sudo vi /etc/samba/smb.conf

The last line is needed for the configuration. Please insert at the end of the file “read only = no”.

sudo su
root@raspberrypi:/home/pi# smbpasswd -a root
New SMB password:
Retype new SMB password:
Added user root.
smbpasswd -a pi
New SMB password:
Retype new SMB password:
Added user pi.

Restart of the Samba service:

/etc/init.d/samba stop
/etc/init.d/samba start

The go to the Finder of you Mac and select in the Finder-Menu “Go to Server” and type the server address:

Please insert the correct address, select “connect” and the user “pi”.

Trouble shooting

If the connect is not possible the the Raspi due to the fact that it has to be reinstalled and the SHA key was already in use before. Therefore try this:

ssh-keygen -R "myIP“

 myIP is the IP Adresse of the Raspi.

Connect the Raspi to a Synology NAS (Mounting a Shared Drive)

First you have to give the permissions to the user / the ip address. Therefore you have to login an the NAS as an administrator. Go to the “Control Panel”. Choose “Shared Folders”  from “File Sharing” and select the folder, that has to be shared. I this case > pi < und > web <:

Then select “Create” and go in the “NFS-Permissions” tab and add a new “NFS rule”

Then “ok” and back to the Raspi!

Create a mount point

sudo mkdir /web
sudo mkdir /nas
sudo vi /etc/fstab

With the last command, the file is open that has the information about the point points. In this case is is the folder > pi < and >web< on the NAS that hast to bee mounted to the folders >pi< and >nas< on the Raspi. You can do that with that lines:

192.168.2.107:/volume1/pi /nas nfs atime,auto,rw,dev,exec,suid 0 0
192.168.2.107:/volume1/web /web nfs atime,auto,rw,dev,exec,suid 0 0

Please do not modify the other lines! They are needed for the SD-card. Afterwards you can execute this commands:

sudo mount -a
sudo /etc/init.d/rpcbind start

That’s all! The Raspberry has mounted the shared folders.

Configuring WiFi

Edit the following file:

sudo vi /etc/network/interfaces

and insert:

auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ap-scan 1
wpa-scan-ssid 1
wpa-ssid "My - SSID"
wpa-psk "My - Password"

Please insert YOUR password for the WiFi and the SSID of the WiFi. The you can do a reboot and unplug the LAN. But your Raspi has a new address! Use this for login. Now it is time for the first Backup! If you crash it or you misconfigure it you can set it up without trouble shooting!

Backup while the Raspi is switched on

A Backup while the Raspi is switched on is problematical. It works, but not stable! In this example I use the mounted /nas folder for the backup. The whole Raspi is in the folder /dev/mmcblk0! This folder has to be saved with “dd” command.

sudo fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 14.9 GiB, 15962472448 bytes, 31176704 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc7513dd7

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       8192    98045    89854 43.9M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      98304 31176703 31078400 14.8G 83 Linux

Command (m for help): q


sudo dd if=/dev/mmcblk0 of=/nas/Backup/2018-12-09-Eval.img bs=1M
15223+0 records in
15223+0 records out
15962472448 bytes (16 GB, 15 GiB) copied, 1455.43 s, 11.0 MB/s

Be careful with this! Some data can be locked or are saved while you do the backup! The 100-% way is to do the backup with the SSD-card and without the Raspi!

Leave a Reply

Your email address will not be published. Required fields are marked *