Installing Raspberry Pi OS

Last Updated 9 November 2024


Download and install Raspberry Pi Imager

Go to https://www.raspberrypi.com/software/, download Raspberry Pi Imager for your operating system and install it on your computer.

Install Raspberry Pi OS on your SD-card

  • Connect a micro SD-card of 8GB or greater capacity to your computer.
  • Open Raspberry Pi Imager.
  • Choose operating system, Raspberry Pi OS (32-bit).
  • Choose storage location. (Make sure you have chosen the right storage device and don’t overwrite something important).
  • Press the gear to open the advanced options window.
  • Fill in the advanced options:
    • Set a hostname to be able to remotely connect to the pi without a static IP-address.
    • Enable SSH to remotely connect to the pi with SSH.
    • You should always create a new user, other than the pi user. The user you create here replaces the pi user.
    • You must always create a new password for your user.
    • Set your WiFi and locale settings.
    • If you enable telemetry Raspberry Pi can collect data to see what is the most popular operating systems installed and other statistics (https://rpi-imager-stats.raspberrypi.com/).
  • Press the SAVE button. This takes you back to the main window.
  • In the main window, press the WRITE button.
  • Make sure you have chosen the right storage device and then press the YES button in the popup window.

Raspberry Pi Imager will now install Raspberry Pi OS on your SD-card. When finished remove the SD-card from your computer.

Configure Raspberry Pi OS – Connect to a headless Raspberry Pi

This is the necessary configuration needed to remotely connect to your Raspberry Pi desktop without a monitor, mouse and keyboard. The pi must be on the same network as the connecting computer. VNC Server from RealVNC comes pre-installed on Raspberry Pi OS, but must be enabled for you to be able to connect to the pi with VNC.

  • Insert the SD-card in your Raspberry Pi and power it up. It will take some time to boot up and connect to your WiFi network the first time, so be patient. To see when it is connected you can use your routers client list or ping the Raspberry Pi from a terminal window with:
ping YourHost.local
  • When the pi is connected to your network, open a terminal window on your computer and SSH into the Raspberry Pi.
ssh YourUser@YourHost.local

The first time you connect with SSH you must confirm that you want to continue connecting, this will add “YourHost.local” to the list of known hosts on your connecting computer. You will then be prompted for your password.

  • When you are logged in to the pi for the first time, you want to update Raspberry Pi OS.
sudo apt update
sudo apt upgrade

The first time you run upgrade it will take some time, so again be patient.

  • Next we want to enable the VNC server to be able to remotely connect to the pi desktop. Open the Raspberry Pi software configuration tool.
sudo raspi-config
  • Enable the VNC server.

The server is now enabled and the easiest way to connect is using VNC Viewer from RealVNC. VNC Viewer is open source and free to use. You do not need to register an account for using it on a local network, but if you register you can use it to remotely connect over internet. It can be used on Linux, Mac and Windows and are found at: https://www.realvnc.com/en/connect/download/viewer/

Alternative remote desktop client – Remmina Remote Desktop Client

The default remote desktop client for Ubuntu is Remmina Remote Desktop Client. To connect with Remmina you need to change the authentication method for the VNC server. The VNC server on Raspberry Pi is set to use the UNIX-password while Remmina uses the VNC-password.

  • SSH into the Raspberry Pi.
  • Generate a VNC-password with:
sudo vncpasswd -service
  • Edit the file vncserver-x11.
sudo nano /root/.vnc/config.d/vncserver-x11
  • Add the following line at the end off the file.
Authentication=VncAuth
  • Save and exit vncserver-x11.
  • Finally, restart the VNC server with:
sudo systemctl restart vncserver-x11-serviced

You should now be able to connect to the Raspberry Pi using the Remmina VNC Plugin in Remmina Remote Desktop Client.

Configure Raspberry Pi OS – Static IP-address

I prefer to have a static IP-address on the Raspberry Pi, it is easier to find on the network and you can connect to it without using the hostname.

  • SSH into the Raspberry Pi.
  • Edit the file dhcpcd.conf.
sudo nano /etc/dhcpcd.conf

I like to configure static IP-addresses for both WiFi and cabled connections, if you find yourself not able to connect to the pi on a WiFi connection you can always connect an ethernet cable to get access to the pi.

  • Add your configuration to the file (Replace the IP-addresses to suit your network).
# Static IP configuration WiFi:
interface wlan0
static ip_address=192.168.0.42     
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

# Static IP configuration cable:
interface eth0
static ip_address=192.168.0.24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
  • Save and exit dhcpcd.conf
  • Reboot the Raspberry Pi.
sudo reboot

When the pi boots back up you should be able to connect to it with the static IP-address.

  • SSH into the Raspberry Pi with your static IP-address:
ssh YourUser@192.168.0.42

Windows:
The first time you connect with SSH after setting the static IP-address you must again confirm that you want to continue connecting, this will add “192.168.0.42” to the list of known hosts on your connecting computer and you will then be prompted for your password. Static IP-address configuration is completed and you can now connect to the pi using your static IP-address or your hostname.

Linux:
If you are connecting from a Linux computer you will get a warning that remote host identification has changed. You have to remove the old host key from the list off known hosts on the connecting computer.

  • Replace “USER” with your actual user on the computer you are connecting from and remove the key.
ssh-keygen -f "/home/USER/.ssh/known_hosts" -R "192.168.0.42"
  • SSH into the Raspberry Pi with your static IP-address again.

You must again confirm that you want to continue connecting, this will add “192.168.0.42” to the list of known hosts on your connecting computer and you will then be prompted for your password. Static IP-address configuration is completed and you can now connect to the pi using your static IP-address or your hostname.

Configure Raspberry Pi OS – Security

I am working on a chapter about security configurations you should consider to apply to The Raspberry Pi after installing Raspberry Pi OS. Meanwhile you can watch this excellent video on the subject:

Share this: