8

I'm trying to run my Raspberry Pi 4 on Ubuntu Server 20.04 (64bit) following this tutorial. When I reached 4. Boot Ubuntu Server, my RPi had no IP address (I switched to using a monitor when doing a headless setup failed, and calling hostname -I returns a blank line), which I believe is the result of having no internet connection, further demonstrated by sudo apt update failing with every line saying temporary failure resolving 'ports.ubuntu.com'. I also get a blank line when calling arp -a | findstr b8-27-eb from the Windows command prompt.

The tutorial had me modify the network-config file before inserting the card into the RPi which I did, and through some exploring, this had the following effect on /etc/netplan/50-cloud-init.yaml (with WIFI-NAME and WIFI-PASSWORD being what they should be):

# this file 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/99-disable-network-config-cfg with the following:
# network:{config: disabled}
network:
    ethernets:
        etho:
            dhcp4: true
            optional: true
    version: 2
    wifis:
        wlan0:
            access-points:
                WIFI-NAME:
                    password: WIFI-PASSWORD
            dhcp4: true
            optional: true

In spite of this, my RPi 4 is still unable to connect to WiFi. If it's relevant, the first time I booted the RPi I didn't actually get the IP address since I disliked the angle of the cord so I unplugged it after a minute or two, plugged it back in, and on the second boot was when I attempted to get the IP.

What am I doing wrong? Or is the issue perhaps with Ubuntu 20.04 and I should use Ubuntu 18.04.4 until 20.04 stabilizes?

  • You listed a tutorial, but have NOT followed it! NOTE the arp instructions are WRONG for a Pi4, but there are better methods of determining IP. How do you know "my RPi 4 is still unable to connect to WiFi"? – Milliways Apr 25 at 6:53
  • @Milliways I've updated my post to better reflect the steps I did. – Drake P Apr 25 at 9:17
  • I am having this exact same issue. sudo iwlist wlan0 scan is even picking up the network I want to connect to, but the system dialog for Wifi says that I don't have a wifi adapter installed. – Brian Tracy Apr 25 at 22:49
9

I've had similar adventures over the last few days :) My system is now:

  • burn image of ubuntu server 20.04 onto sd card
  • boot rpi
  • write network: {config: disabled} to /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
  • write the following to /etc/netplan/01-netcfg.yaml:
network:
  version: 2
  renderer: networkd
  wifis:
    wlan0:
      dhcp4: true
      dhcp6: true
      optional: true
      access-points: 
        "******":
          password: "**********"
  • then do:
sudo netplan generate
sudo netplan apply
reboot

wifi now works for me, and then you can do stuff like apt update and install a desktop and stuff

For more info on netplan, check out https://netplan.io/examples

| improve this answer | |
  • 2
    I am going to try this tomorrow, because I am in the exact same situation. Could you explain what the network: {config: disabled} line does? In addition, when I run sudo netplan apply, I get Warning: The unit file, source configuration file or drop-ins of netplan-wpa-wlan0.service changed on disk. Run 'systemctl daemon-reload' to reload units. – Brian Tracy Apr 27 at 6:19
  • the config: disabled part turns off the "cloud config" networking stuff that's configurable in the 50-something file in cloud.cfg.d. I've had a couple of occasions where I encountered warnings when running apply too, but after reboot, it always works :) – Andbdrew Apr 30 at 21:59
  • Thank you for this great answer. I owe you a beer :) – ndreisg May 27 at 17:25
  • Is there any way to do this without connecting a keyboard and monitor to the Pi? I'm trying to manually tamper with them as little as possible so that they are easily re-imagable... thanks! – Mark Stickley May 29 at 20:38
  • As of Jun3 15,2020, slight update. I also got the Run 'systemctl daemon-reload'. Tried it. It exited with non-zero error, I think it was 5. I tried the reboot. No good. No wifi. Repeated the process. Same. No good. Then I did a full shutdown and poweroff instead of reboot. Powered back up and after giving the login prompt, it also then gave some status and versions info for several lines, where I was supposed type in the login user. I went ahead with user and password, as if those messages had not stomped on the login area and had not repositioned the cursor. Successfully loggen in. – always_learning Jun 15 at 19:18
4

Using Andbdrew's tips above I was able to make this work headless (and with a head) consistently without disabling Cloud-Init. Thanks to @enconn, for brainstorming and a link to https://cloudinit.readthedocs.io/en/latest/topics/examples.html#reboot-poweroff-when-finished.

  1. Image the SD Card using Raspberry Pi Imager v 1.3 selecting the 'UNBUNTU 20.04 LTS (RASBERRY PI 3/4)(64-bit) image.
  2. When imaging is completed, remove the SD Card and then reinsert it so that it is mounted.
  3. Modify 'network-config' found on the SD Card so that it contains only the items in the example below. Comment out with #, or remove, all other settings including the LAN ones. Enter any missing items. Be certain to maintain only the indentations shown. Use two spaces for each indentation. Remove all tab characters. Be especially careful if using Notepad++ as it will enter tabs wherever enter is used to start a new line. Replace the SSID with your wireless SSID and the PassPhrase with your wireless passphrase. When done, those two values should be wrapped in quotes. Save the modified file to the SD Card.
  4. Edit 'user-data' appending the additional lines shown below. Again, use spaces, not tabs and mind the indentation.
  5. Eject the SD Card, remove it from the computer used to image it, and then insert into the powered off Raspberry Pi. Then, power up the RPi.
  6. Allow Ubuntu to boot; DO NOT try to log into Ubuntu as soon as possible. Wait until Cloud-Init runs (although it appears to be doing nothing - in about two minutes it will show SSH info when done). If you don't wait you may not be able to logon with the default user and passwd. At the end of the cloud-init,Ubuntu will be rebooted. What a couple of minutes for the server to boot.
  7. Logon either at the console or remotely using ssh ubuntu@x.x.x.x (get the address from your router, etc.)

That's it: Headless, Wi-Fi'd Ubuntu 20.04 on Raspbery Pi 4b

network-config example:

# This file contains a netplan-compatible configuration which cloud-init
# will apply on first-boot. Please refer to the cloud-init documentation and
# the netplan reference for full details:
#
# https://cloudinit.readthedocs.io/
# https://netplan.io/reference
#

version: 2
renderer: networkd
wifis:
  wlan0:
    dhcp4: true
    dhcp6: true
    optional: true
    access-points:
      "SSID":
         password: "PassPhrase"

Append this to the end of 'user-data':

##Reboot after cloud-init completes
power_state:
  mode: reboot
| improve this answer | |
  • This works perfectly as a one-step solution, without needing to log in and perform other actions – Crollster Jul 1 at 0:39
  • The reboot is the critical part here. Though, why doesn't it pick up WiFi settings on initial run? That prevents package_update & package_upgrade runs from finishing successfully. – jolt Jul 6 at 18:28
0

I used your method but on a different file. sudoedit /etc/netplan/50-cloud-init.yaml

you don't have to do the sudo netplan generate or reboot. It will work straight away after the sudo netplan apply

| improve this answer | |
  • I believe this would only be a temporary solution, since 50-cloud-init.yaml says Changes to it will not persist across an instance reboot. – Drake P May 11 at 14:49
  • @DrakeP I wonder why raspberrypi.stackexchange.com/questions/98598/… is suggesting to update that very same file. This is confusing. – piepi Jul 28 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.