Image

raspberry

Introduction

3 min read
Last update: November 28, 2021

Get Started

tip Basics To Begin
  • raspberrypi.org download Raspberry PI OS (here, we will install Raspberry Pi OS (32-bit) Lite without desktop)
  • A Raspberry PI (I have Raspberry PI 3 B+) with power supply
  • SD Card (I have 32 Go but 8 Go is enough)
  • Ethernet cable (this guide setup Raspberry with ethernet, it's possible with WiFi too, check links at the end)
  • A computer with Linux (it's also possible with Windows or MacOS, check links at the end)
  • Terminal knowledge: basic to medium level (manage relative and absolute paths, know how to locate the name of a disk)

Installation

Download Raspberry Pi OS (32-bit) Lite to have OS without desktop, just for server and SSH access. Unzip it like this (need to have pzip package)

7z x 2020-05-27-raspios-buster-lite-armhf.zip

You will get an img file: 2020-05-27-raspios-buster-lite-armhf.img

Note I have a file with `2020-05-27` in it name, you will have certainly a different file name.

Connect your SD Card to your computer and list disks with

lsblk -p
Erase SD Card and create new partition with any package like with `gnome-disks`

For example I have this output.

alt

Explanation

My SD Card has 32 Go disk space, lsblk list three disks: sda, sdb, nvme0n1 with partitions. sdb have 29,7 Go in SIZE column, so it's my SD Card.

Write OS image on SD Card with dd, don't copy paste this command, you have certainly to modify raspios-buster-lite-armhf.img path, like ~/2020-05-27-raspios-buster-lite-armhf.img and modify /dev/sdX, like /dev/sdb for me.

sudo dd bs=1M if=raspios-buster-lite-armhf.img of=/dev/sdX status=progress conv=fsync

Enable SSH and connection

It's will take some time. When it's finish mount the SD Card to access to it (you can do this with any file manager on Linux, like Nautilus).

In terminal, you will have access like this

cd /media/$USER/

You will have two partitions boot & rootfs, you have to enable SSH.

cd /media/$USER/boot/ ; touch ssh
cd /media/$USER/rootfs/boot/ ; touch ssh

Now, SSH is enabled and you can unmount SD Card (with Nautilus for example). And insert SD Card to Raspberry PI, insert ethernet cable and power on. Wait some seconds and try to connect with terminal.

ssh pi@raspberrypi.local

The default password is raspberry. If everything works, you will connect to your Raspberry and you can setup it.

sudo raspi-config


More infos

https://raspberrypihq.com/how-to-connect-your-raspberry-pi-to-wifi/

sudo apt install -y exfat-utils exfat-fuse curl git nethogs vim net-tools

Locales

sudo dpkg-reconfigure locales

Choose en_US.UTF-8 in the list and validate

locale

Any error ?
Add this to .zshrc

export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LANGUAGE="en_US.UTF-8"

Setup

Define password for root

passwd

Edit sshd daemon config

sudo vim /etc/ssh/sshd_config

Add PermitRootLogin yes

sudo /etc/init.d/ssh restart

Logout SSH and SSH with root

ssh root@raspberrypi.local

Delete pi and create new user

userdel pi ; useradd -m newuser ; passwd newuser ; usermod -aG sudo newuser

Logout SSH and SSH with newuser

ssh newuser@raspberrypi.local

Remove PermitRootLogin yes from /etc/ssh/sshd_config