Brainstorm's snippets (1/228)

  Raspberry PI setup guide

1   Initial setup

2   Enable SSH connections

Connect with a keyboard, then issue these commands from terminal:

systemctl enable ssh.service
systemctl start ssh.service

3   Set locale

sudo -s
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

5   Expand swap partition ...

100 Mb (the default) is too small, and if you are doing memory intensive stuff (e.g., web surfing), you can easily max it out.

The recommended swap size is 2*physical RAM - in the case of the Pi (modern/current versions of), this is 2G.

You can increase the swap size by changing the CONF_SWAPSIZE or the CONF_SWAPFACTOR parameter in /etc/dphys-swapfile followed by a reboot:

cat /etc/dphys-swapfile

[...]
CONF_SWAPFACTOR=2
[...]

Test after reboot:

# free -h
              total        used        free      shared  buff/cache   available
Mem:           927M        259M        425M         30M        242M        585M
Swap:          1.8G          0B        1.8G

6   ... or remove it !

On the other hand, you might want to turn off swap entirely in order to reduce the amount of write operations on the SD card – because SD cards have their life limited to the amount of write operations:

sudo systemctl disable dphys-swapfile

Test after reboot:

# free -h
              total        used        free      shared  buff/cache   available
Mem:           927M        257M        437M         24M        232M        593M
Swap:            0B          0B          0B

Another option is to move swap to an external device (for example a USB key).

References:

7   Setup SMTP

TODO; vedere:

Installazione e Configurazione di Postfix su Raspberry usando come Smarthost GMAIL:

https://www.raffaelechiatto.com/installazione-configurazione-postfix-raspberry-usando-smarthost-gmail/

NULLMAILER – IL POSTINO MINIMALISTA:

https://hamradio.fe.linux.it/nullmailer-il-postino-minimalista/

8   Start chromium in Kiosk mode on raspbian jessie

file ~/Desktop/runChromium.desktop:

[Desktop Entry]
Type=Application
Exec=/usr/bin/chromium-browser --noerrdialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://127.0.0.1
Hidden=false
X-GNOME-Autostart-enabled=true
Name[en_US]=RunChromium
Name=RunChromium
Comment=Start Chromium in kiosk mode; copy int ~/.config/autostart to have it run automatically

References:

10   Display rotation

file "/boot/config.txt":

# LCD Rotation
lcd_rotate=2

# Display Rotate (HDMI)
#display_rotate=2

11   Disable screen sleep

file "/etc/lightdm/lightdm.conf":

[Seat:*]
...
# don't sleep the screen
xserver-command=X -s 0 dpms

or:

sudo apt-get install xscreensaver

then configure the screensaver application under the Preferences option on the main desktop menu.

12   How to up a Static IP on Your Ethernet or Wireless Network Connection

file /etc/dhcpcd.conf:

# setup ethernet static ip
interface eth0
inform 192.168.1.18
static routers=255.255.255.0

# setup wireless static ip
interface wlan0
inform 192.168.1.19
static routers=255.255.255.0

or:

# setup ethernet static ip
interface eth0
static ip_address=172.26.11.85/24
static routers=172.26.11.100
static domain_name_servers=8.8.8.8 8.8.4.4

then:

#sudo /etc/init.d/networking restart
sudo reboot

https://projects.raspberrypi.org/en/projects/getting-started-with-picamera