Introduction
In this tutorial, we will learn to install Ubuntu on a Raspberry Pi. There are two methods we can use to setup:
- Using external HDMI screen and USB keyboard for your Pi,
- Using a wifi network (Headless).
Hardware Requirements:
- Raspberry Pi (I used, model 4 B)
- Power cable
- micro SD card (I used,16GB)
- Computer with a microSD card drive.
- Monitor(optional)
- HDMI connector(optional)
- keyboard (optional).
Prepare the SD Card
Warning
This will erase all existing content on the microSD card.
Now you need to download the right Ubuntu Pi Image (Download link).
- Next, download and install BalenaEtcher to flash the downloaded image to the SD card. (click here to download)
- Next, insert your sd card to your computer
- Open BalenaEtcher.
- Click on “Select image” and locate the downloaded image file on your computer.
- Next, make sure the right drive is selected (In my case Its G:\ )
- Finally , Click on “Flash!”
- It will take few minutes to complete the process.
- So, Now your SD card is ready. (Flash Complete!)
Now , you can remove your SD card from your computer.
Boot Ubuntu
If you are using an HDMI screen and a keyboard:
- Plug these into Pi.
- Insert the SD card into the Pi and power it up (plug in your power supply).
You will be able to see the boot process on the screen and log in using “ubuntu” as both the password and login ID. After a minute or so, Ubuntu on your Raspberry Pi will have fully booted.
If you are running your device headless:
- You need to connect to it remotely from your laptop.
- We are going to do so using the SSH protocol.
For this first we need to insert our SD card back into the computer.
- open the partition named “system-boot”
- Next find and open the file named “network-config” using notepad. (Any other text editor will do)
- Find the below lines inside the “network-config” file.
#wifis: # wlan0: # dhcp4: true # optional: true # access-points: # homessid: # password: "S3kr1t"
- Uncomment these lines by removing the ‘#‘
- Replace homessid with the name of your wifi network(say “HomeNet”).
- SSID should be written within “”.
- Also, Enter the password for your network.(say “12345678” )
Example is shown below:
wifis: wlan0: dhcp4: true optional: true access-points: "HomeNet": password: "12345678"
Once the required changes are made ,Save it and close this file.
Now, insert SD card to Raspberry Pi and power it on. (wait for few minutes as first boot usually takes some time)
Connect remotely to your Raspberry Pi
To connect to your Raspberry Pi remotely, you need two things (we’ll help you find them):
- Its IP address on the local network
- An SSH client (SSH is a communication protocol between machines)
Next, we need to find the IP address of pi on your network. For this we can use any method
I use an app called Network Scanner to find the ip address.(playstore link)
Now open Cmd in windows or Terminal in linux and type:
ssh ubuntu@192.168.31.9
Here my IP address was “192.168.31.9”.Replace with your IP address.
- Type yes and press Enter.
- Now enter the password as “ubuntu“
The first thing Ubuntu will do is ask you to change the password. Once done, reconnect with the ssh command and the new password.
Success! You are now connected to Ubuntu Server running on your Raspberry Pi.
5. Install a desktop(OPTIONAL STEP)
Depending on requirement we can setup a desktop environment to run graphical applications.
Update packages to latest versions : Type-
sudo apt update sudo apt upgrade
Then, use any one of the below command to install a desktop environment.
Here are some popular and lightweight options:
sudo apt install xubuntu-desktop
sudo apt install lubuntu-desktop
sudo apt install kubuntu-desktop
Finally Reboot:
sudo reboot
If you are connected to a HDMI screen .The new Desktop automatically comes up on Display