Setup your Raspberry Pi 4 - without an external monitor
The blog post defines the steps to setup a brand new Raspberry Pi 4 Model B without an external monitor attached to the Pi.
I received my first Raspberry Pi yesterday.
I have got a Raspberry Pi 4 Model B with 8 GB
RAM.
As I was doing the setup, I found it difficult to get all the information in one place, so I decided to write this blog post.
This post documents the steps to setup a brand new Raspberry Pi without an external monitor.
Here is what we are going to do:
- install the Raspberry Pi OS (64-bit)
- setup internet connection over WiFi
- SSH and run updates
- setup VNC Viewer
- install Docker
We have quite a lot to cover, so let’s get started.
Prerequisites
Following are some prerequisites for the setup:
- Raspberry Pi board (obviously)
- connector for power supply
- microSD card (depends on your Pi model though) and a card reader
- another system to do the work (on the same network)
- SSID (network name)
- PSK (network password)
Installing Raspberry Pi OS
The very first thing you need for the setup is the Raspberry Pi Imager. Raspberry Pi Imager is the quick and easy way to install Raspberry Pi OS and other operating systems to a microSD card, ready to use with your Raspberry Pi. The imager provides a wide range of stable operating systems. However, they are all 32-bit (I think). You can very well choose either one and move forward.
Since the Raspberry Pi 4 supports 64-bit OS, I will be installing the 64-bit Raspberry Pi OS. You can download the same from here. Please note that it’s still in beta testing and a list of known issues can be found on the same forum.
Follow the steps below to install the OS:
- Connect your microSD card to the system where you have downloaded the OS and imager.
- In the imager select the
Choose OS
option. - Scroll down the pop-up list and select
Use custom
at the end. - Select the downloaded OS (
.zip
file) - Now select
Choose Storage
and select the connected SD card. - Click
Write
and wait for the process to complete.
Setup Wifi
Now that we have installed the OS, it’s time to setup the network.
Open the SD card in a file manager of your choosing.
If you are using a Windows
based system, the SD card will directly land you in the boot
directory.
You can double check it by looking for these files:
|
|
Create a file named wpa_supplicant.conf
next to the above files, i.e., in the boot
directory.
However, if you are on a Linux
based system you need to create the file as /etc/wpa_supplicant/wpa_supplicant.conf
.
Now, add the following content to your file:
|
|
Save the file and ensure that the file extension is .conf
.
Insert the SD in the slot of the Pi board, connect the power and turn it on.
As the Pi boots you should see the blinking green
and red
lights.
Once the boot is complete the green
light will turn off.
SSH and Run Updates
Now, it’s time to find the IP address of your Raspberry Pi. There are multiple ways to scan a network and get connected devices. In order to make it easy you can use an IP Scanner. This article provides a good list of scanners that you can choose from. Select and install one.
Scan your network and you should see a Raspberry Pi device connected. Here is an example:
Note the IP address. Let’s SSH into the Pi with default credentials.
|
|
Here are a few things you should do as you login:
|
|
The Raspberry Pi OS also provides a configuration manager that you can start using the sudo raspi-config
command.
It will prompt you with the following or similar term-UI:
|
|
Setup VNC Viewer
Honestly, you don’t really need a GUI to work with a Raspberry Pi. But it can be useful at times, especially if you are a beginner. Let’s setup VNC viewer just for that.
On your Pi, install the realvnc server:
|
|
Start the VNC server using the vncserver
command:
|
|
Notice the last line that provides details about how you can connect to the desktop started by the server.
Now install the VNC Viewer (also know as VNC client) on the system you want to have the display on.
Once installed, start the client and use the desktop address you got from the VNC server (192.168.0.232:1
in my case).
When prompted, provide the Raspberry Pi user credentials you used to SSH into the Pi.
Congratulations! You have successfully setup your Raspberry Pi. 🎉 🥳
Install Docker
Installing Docker on Raspberry Pi 4 is super simple. All you need is to run the following command that gets a script and pipes it to the shell:
|
|
By default, Docker daemon runs a privileged service and a non-privileged user can’t connect with it without using sudo
.
Meaning, if you try executing docker ps
command you would get the following error message:
|
|
In order fix this we need to add the pi
user to the docker
group.
Once done, reboot the Pi.
|
|
SSH again and try executing the docker ps
command w/o sudo
and you should not get any errors.
|
|
Conclusion
In this blog post, we have setup a Raspberry Pi 4 Model B from scratch without an external monitor connected to the Pi. We have also installed Docker and so, the Pi is all set to get you rocking on a new journey. In the next post, we will setup Rust and write our first application. Later we will containerize the application and run it on the Raspberry Pi. So, stay tuned.
I hope you found the steps useful and I look forward to your valuable feedback. If you run into issue, please do let me know and I will be happy to help.