I needed to turn my Raspberry Pi 4 Model B/2GB into Ubuntu Server to serve my flask application(Nginx, flask integration in a separate blog). I followed the following steps to achieve the same
- Download Raspberry Pi Imager from their website, which will allow us to write the OS on SD Card.
- Open Raspberry Pi Imager and select OS as Ubuntu Server 20.04.1 LTS and memory card where you want to write OS
- Click WRITE. It will take some time depending on your internet speed.
- Once it finishes writing into SD/USB card, plug the card into Raspberry Pi and turn it ON.
- If your Raspberry PI is connected to ethernet, than it's great and go to Setting up the wifi(Step 9), otherwise go through the painful steps(6, 7 and 8) below to install packages that will help you set up wifi.
- Download the following files from a computer with an internet connection and save them into a USB drive(not the one on which you wrote OS and download packages from Ubuntu Package site):
- libnl-route-3-200_3.4.0-1_arm64.deb
- libpcsclite1_1.8.26-3_arm64.deb
- wpasupplicant_2.9-1ubuntu4_arm64.deb
- Plug in the USB drive to the Raspberry Pi and let's copy them and install the packages
$ cd /dev/disk/by-label
$ ls -lt (it will show your USB name and location, it gave
The USB location in my case was
following for me SANDISK -> ../../sda1)/dev/sda1
. Might be different in your case so checkls -lt
output above -
Now mount the usb and installed packages
$ sudo mkdir /media/usb $ sudo mount -t vfat /dev/sda1 /media/usb $ cd /media/usb $ sudo dpkg -i libnl-route-3-200_3.4.0-1_arm64.deb\ libpcsclite1_1.8.26-3_arm64.deb \ wpasupplicant_2.9-1ubuntu4_arm64.deb
-
Check the name of the network interfaces and the associated IP address
$ ip a
will list all networks. In my case they were eth0 for ethernet, Wlan0 for wifi which we will use below. -
Now to add set wifi username and password info
$ ls /etc/netplan/
which will output the the name of YAML file, something like XX-cloud-init.yaml. Create back up of it and open it in nano editor and add wifi settings as shown below:
$ sudo cp XX-cloud-init.yaml XX-cloud-init.yaml.bak $ sudo nano XX-cloud-init.yaml # This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/XX-disable-network-config.cfg with the following: # network: {config: disabled} network: version: 2 ethernets: eth0: dhcp4: true optional: true wifis: wlan0: dhcp4: true optional: true access-points: "WIFI-USER-NAME-KEEP-QUOTES": password: "WIFI-PASSWORD-KEEP-QUOTES"
Save the changes. And try the following to make sure there is no error in YAML file
$ sudo netplan --debug try (continue even if fails/pass)
$ sudo netplan --debug generate (fix all the issues raised; mostly regarding tabs/indentation, you can also look https://netplan.io/examples/ for examples if you are facing any troubles regarding tabs/indentation/spacing)
$ sudo netplan --debug apply
$ sudo reboot
- Now
$ ip a
and you will see local IP address against the wlan0 - check wifi is working
ping google.com
and see the packages received and transmitted
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.