Our step-by-step guide to prepare a lean yet versatile SD card image based on Raspberry Pi OS Lite.
Learn how we at reelyActive prepare a SD card image for a headless Pi.
Download the latest version of Raspberry Pi OS Lite and flash it to an SD card with Etcher.
We'll flash the SD card with Etcher, a friendly open source tool that you can download here.
From the computer with which you intend to flash the SD card :
You should now have a file entitled 20xx-xx-xx-raspios-bullseye-armhf-lite.img on your computer . Let's flash!
We recommend using micro SD cards from reputable vendors of at least 4GB size.
From the computer with which you intend to flash the SD card :
Proceed to the next step once the SD card is flashed and verified.
Configure Raspberry Pi OS before the first boot on the Pi, ensuring a painless initial connection.
Following the flashing of the SD card in the previous step, the computer should automatically mount two partitions: boot and rootfs. We'll make minor changes to each partition as follows.
If the partitions aren't automatically mounted, eject the SD card and then re-insert into the computer .
Open a terminal and browse to the root of the bootfs partition (ex:
cd /media/user/bootfs/), then:
sudo touch ./ssh
This will allow us to SSH into the Pi on the first boot, and will use predictable network interface names (ex: eth0, wlan0) which we'll need for Part 3.
As of April 2022, Raspberry Pi OS no longer ships with a default username & password!
From the same terminal in the root of the bootfs partition (ex:
sudo nano userconf)
This will set the default username to pi with password berryinsecure (encrypted above), which will be required when SSHing into the Pi in Step 3—and you can change it to a less-insecure password in that step too!
Open a terminal and browse to the root of the rootfs partition (ex:
cd /media/user/rootfs/). Edit the /etc/dhcpcd.conf file to include the following (simply append or uncomment and edit):
# It is possible to fall back to a static IP if DHCP fails: # define static profile profile static_eth0 static ip_address=10.0.50.100/24 static routers=10.0.50.1 static domain_name_servers=10.0.50.1 # fallback to static profile on eth0 interface eth0 fallback static_eth0
This will ensure that the Pi boots with the static Ethernet address of 10.0.50.100 in the absence of DHCP, as will be the case, and will prove helpful on any occasion where it is necessary to directly connect to the Pi over Ethernet, as in the following step.
Unmount both partitions and eject the SD card which is now ready to find its way into the Pi.
Boot the Pi for the first time and SSH in via Ethernet to run raspi-config.
The SD card should only be inserted into (or removed from) the Pi when it is disconnected from power.
With the SD card inserted into the Pi, complete the following:
ssh firstname.lastname@example.org, when prompted, enter the password berryinsecure (before April 2022, the default password was raspberry)
Now that you're logged in to the Pi, it is possible to execute commands such as raspi-config.
From the command prompt on the Pi , enter the command
sudo raspi-config which will open a text-based menu.
Update the configuration as per the following table where the settings are indicated in [ ].
S1 Wireless LAN
*adjust as per your region and local WiFi network
S3 Password* [berryinsecure]
*this is a good time to choose something less insecure
I6 Serial Port
L2 Change Timezone* [America | Montreal]
*adjust as per your region (reelyActive is "Made in Montréal")
|6||Advanced Options||A1 Expand Filesystem [Select]|
Upon completing the above, select <Finish> and select <Yes> when prompted to reboot. If you entered valid WiFi settings, the Pi should connect to this network automatically, which will be required for the next step.
SSH into the Pi over WiFi and configure its Ethernet DHCP server to facilitate future direct connections.
The Pi should have rebooted from the previous step and connected to both the local WiFi network and again to the computer connected directly via Ethernet .
With the Pi still connected to the computer via Ethernet , and from the same terminal window as before:
ssh email@example.com, using the new password (or berryinsecure if you didn't change it)
ifconfig. It will be the inet value under wlan0 (ex: 192.168.0.123)
ssh firstname.lastname@example.org, replacing the x values with the Pi's WiFi IP address.
The computer is now connected to the Pi over WiFi .
Be sure to disconnect the network cable between the two, else they may ignore their Internet connection over WiFi, instead selecting Ethernet as their default gateway.
From the same terminal connected to the Pi via SSH over WiFi :
sudo apt-get install dnsmasq
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.default
sudo nano /etc/dnsmasq.confthen paste in the following two lines and save:
sudo service dnsmasq restart
The Pi will now behave as follows on Ethernet connection:
|External DHCP?||Behaviour of the Raspberry Pi|
|Yes||The Pi will accept the DHCP-assigned IP address|
|No||The Pi will fallback to static IP address 10.0.50.100 and it will assign IP addresses in the range 10.0.50.2-99 to any connected devices|
The core configuration of the Pi is now complete. On to the software!
Install all the prerequisites to run Node.js programs such as our Pareto Anywhere middleware.
To simplify installing and updating Node.js, the NodeSource binary distributions will be used. From the same terminal connected to the Pi via SSH over WiFi :
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update && sudo apt-get install -y nodejs1 min
Confirm that node and npm are successfully installed with the commands
node --version and
npm --version respectively.
*it is recommended to specify the current LTS version as indicated on nodejs.org
Since the latest release of Raspberry Pi OS Lite, there are inevitably newer versions of some of the packages available. From the same terminal connected to the Pi via SSH over WiFi :
sudo apt-get update1 min
sudo apt-get upgrade5 mins+
sudo apt-get install git
All software packages are now installed and at the latest version. The Pi is prepared for the (optional) installation of Pareto Anywhere, which is the subject of the next tutorial:
Continue exploring our open architecture and all its applications.