DEV Community

Cover image for Ubuntu Server 20.04.1 set up on Raspberry Pi 4 Model B/2GB
Jasmeet Singh
Jasmeet Singh

Posted on • Updated on

Ubuntu Server 20.04.1 set up on Raspberry Pi 4 Model B/2GB

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

  1. Download Raspberry Pi Imager from their website, which will allow us to write the OS on SD Card.
  2. Open Raspberry Pi Imager and select OS as Ubuntu Server 20.04.1 LTS and memory card where you want to write OS Alt Text Alt Text
  3. Click WRITE. It will take some time depending on your internet speed.
  4. Once it finishes writing into SD/USB card, plug the card into Raspberry Pi and turn it ON.
  5. 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.
  6. 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):
    1. libnl-route-3-200_3.4.0-1_arm64.deb
    2. libpcsclite1_1.8.26-3_arm64.deb
    3. wpasupplicant_2.9-1ubuntu4_arm64.deb
  7. 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
    following for me SANDISK -> ../../sda1)
    The USB location in my case was /dev/sda1. Might be different in your case so check ls -lt output above
  8. 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
    
  9. 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.

  10. 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"
    
  11. 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
Enter fullscreen mode Exit fullscreen mode
  • 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)