2020-09-05
md
Ubuntu 20.04 Server: Wi-Fi, Snap, etc.
RTFM!

There was a small form factor computer, an HP Pavilion, sitting forlornly in a corner in need of a new purpose in life. As proof of the fact that the computer is rather old, let's just say that it has an AMD Athlon 64 X2 dual core processor and it came with Windows Vista Media Centre (32 bit) preinstalled. I decided it could be used as a headless remote backup system. To that end the hard drive was replaced with a (nominal) 2 TB Seagate liberated from a USB 2.0 enclosure. The TV tuner expansion card was removed and the CD-ROM drive was ripped out to be replaced with a second hard drive. All that needed to be done was to install a Linux server distribution and that's when a problem manifested itself. I could not get the Wi-Fi network interface running. As the subtitle says, it was my own fault, the solution was in the manual.

Table of Contents

  1. Which Server Distribution?
  2. Initial Installation and Configuration
  3. Installing the Wi-Fi Interface
  4. Removing Snap
  5. Disabling Automatic Upgrades
  6. Disabling CloutInit
  7. Conclusion

Which Server Distribution? toc

While I have installed various "light" Linux distributions on a number of ARM-based single-board computers in the last few years, my experience with similar installations on AMD64 systems is much more limited. The installation of Debian on an old Dell computer a few months ago was relatively simple (see Domoticz Backup Scripts), although I was surprised at how sparse the system was and remains. In any case, I installed the same "non-free" distribution and was quite pleased that the installer found both the Ethernet and Wi-Fi network interfaces and could proceed with the installation of "standard" Debian. However, I could not get the Wi-Fi card up on the installed image.

My next attempt was to install Mint 20 Mate. That went smoothly and the Wi-Fi worked in that distribution. However, installing a complete graphic user interface which would not be used just to enable the Wi-Fi card was not very satisfying. Of course it would be possible to remove the GUI and end up with a lighter distribution.

My third try was to install Ubuntu Server. Its installer did not find the Wi-Fi interface and again I was unable to install the Wi-Fi card once the OS was running. I also noticed that Snap was installed and I happen to have a probably unjustified bias against that package manager.

At that point, which was a couple of weeks ago, I ran out of time and had to abandon the project. Yesterday, I was able to come back to it and managed to get the Wi-Fi up in Ubuntu Server and to modify the latter to my liking.

Initial Installation and Configuration toc

The first thing I did after the initial boot was to edit the sudoers file to reduce the number of times it is necessary to enter the user password when using the sudo command.

michel@hpav:~$ sudo visudo [sudo] password for michel: ****** not echoed to screen

... # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # Default user privileges %michel ALL=(ALL:ALL) NOPASSWD: ALL # See sudoers(5) for more information on "#include" directives: ...

The only member of the group michel is user michel, so the percent (%) prefix is not really necessary. Of course, others will have to adjust and use the correct user or group if doing the same thing. Then, as usual, the system should be updated and upgraded. Of course, it is necessary to have a network connection for this but fortunately, Linux usually has no problem setting up wire Ethernet interfaces.

michel@hpav:~$ sudo apt update && sudo apt upgrade -y Hit:1 http://ca.archive.ubuntu.com/ubuntu focal InRelease ... The following package was automatically installed and is no longer required: squashfs-tools Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. michel@hpav:~$ sudo apt autoremove Reading package lists... Done ... Removing squashfs-tools (1:4.4-1) ... Processing triggers for man-db (2.9.1-1) ...

The next step involved repairing a mistake because I did not include the SSH server during the installation of Ubuntu when I think there was an opportunity to do so. First I verified that the prerequisite was installed, and then it was a simple matter to add the server and verify that it was installed.

michel@hpav:~$ ssh -V OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f 31 Mar 2020 michel@hpav:~$ sudo apt-get install openssh-server ... michel@hpav:~$ sudo systemctl status sshd ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2020-09-04 20:21:15 UTC; 6min ago Docs: man:sshd(8) man:sshd_config(5) Process: 728 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) Main PID: 729 (sshd) Tasks: 1 (limit: 4391) Memory: 4.4M CGroup: /system.slice/ssh.service └─729 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups Sep 04 20:21:15 hpav systemd[1]: Starting OpenBSD Secure Shell server... Sep 04 20:21:15 hpav sshd[729]: Server listening on 0.0.0.0 port 22. Sep 04 20:21:15 hpav sshd[729]: Server listening on :: port 22. Sep 04 20:21:15 hpav systemd[1]: Started OpenBSD Secure Shell server. Sep 04 20:22:38 hpav sshd[889]: Accepted password for michel from 192.168.1.126 port 54664 ssh2 Sep 04 20:22:38 hpav sshd[889]: pam_unix(sshd:session): session opened for user michel by (uid=0)

As can be seen, I opened an SSH session about a minute after starting the server. Everything was done in SSH sessions from then on.

Because this server will be moved to another network which I know uses a different subnet, I deliberately continued with dynamic IP address which is not the best solution for a server. To make it easy to find the address, especially when the system will be used without a keyboard and without a monitor, I installed the ZeroConfiguration daemon, avahi-daemon and modified its configuration file so that it will advertise the server as a desktop.

michel@hpav:~$ apt-cache policy avahi-daemon avahi-daemon: Installed: (none) Candidate: 0.7-4ubuntu7 Version table: 0.7-4ubuntu7 500 500 http://ca.archive.ubuntu.com/ubuntu focal/main amd64 Packages michel@hpav:~$ sudo apt install avahi-daemon -y Reading package lists... Done ... Need to get 223 kB of archives. After this operation, 991 kB of additional disk space will be used. ...

michel@hpav:~$ sudo nano /etc/avahi/avahi-daemon.conf
... [publish] ... publish-workstation=yes

michel@hpav:~$ sudo systemctl restart avahi-daemon

Checking on my desktop, I found the server with the Zeronconf browser.

michel@hpav:~$ avahi-browse --all + wlp3s0 IPv6 hpav [00:2b:83:28:eb:17] Workstation local + wlp3s0 IPv4 hpav [00:2b:83:28:eb:17] Workstation local + enp4s0 IPv6 hpav [00:2b:83:28:eb:17] Workstation local + enp4s0 IPv4 hpav [00:2b:83:28:eb:17] Workstation local ...

The time zone is not set as shown by the timedatectl utility.

michel@hpav:~$ timedatectl Local time: Sat 2020-09-05 23:08:31 UTC Universal time: Sat 2020-09-05 23:08:31 UTC RTC time: Sat 2020-09-05 23:08:31 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no

Since I know that nearby Halifax (N.S.) is in the time zone database, it was easy to confirm the correct name of the time zone in preparation for setting it with the same timedatectl utility.

michel@hpav:~$ timedatectl list-timezones | grep Halifax America/Halifax michel@hpav:~$ sudo timedatectl set-timezone America/Halifax

A further call of the utility showed that the last step was successful.

michel@hpav:~$ timedatectl Local time: Sat 2020-09-05 20:09:01 ADT Universal time: Sat 2020-09-05 23:09:01 UTC RTC time: Sat 2020-09-05 23:09:01 Time zone: America/Halifax (ADT, -0300) System clock synchronized: yes NTP service: active RTC in local TZ: no

The next step was to get the Wi-Fi network card running. Again, I would prefer that a server be connected to the local area network with an Ethernet cable, but this machine is destined to live in a dark corner of the basement of a relative where there is no hope of running a cable from the router on the first floor.

Installing the Wi-Fi Interface toc

As it happens, Ubuntu not only recognized the Wi-Fi interface, but it installed the drivers.

michel@hpav:~$ lsusb ... Bus 001 Device 003: ID 15a9:0004 Gemtek WUBR-177G [Ralink RT2571W] ... michel@hpav:~$ sudo lshw -C Network *-usb:1 DISABLED description: Wireless interface product: 802.11 bg WLAN vendor: Ralink physical id: 9 bus info: usb@1:9 logical name: wlx00e533bf124a version: 0.01 serial: 00:E5:33:BF:12:4A capabilities: usb-2.00 ethernet physical wireless configuration: broadcast=yes driver=rt73usb driverversion=5.4.0-45-generic firmware=N/A link=no maxpower=300mA multicast=yes speed=480Mbit/s wireless=IEEE 802.11 michel@hpav:~$ lsmod | grep rt rt73usb 36864 0 rt2x00usb 24576 1 rt73usb rt2x00lib 61440 2 rt73usb,rt2x00usb mac80211 843776 2 rt2x00lib,rt2x00usb cfg80211 704512 2 rt2x00lib,mac80211 crc_itu_t 16384 2 rt73usb,firewire_core

The NetManager package is not installed so I assumed that editing the /etc/network/interfaces or the /etc/dhcp/dhcpcd.conf and adding a WPA Supplicant configuration file with the Wi-Fi credentials should do the trick, much as it had in many installations of Debian based distributions on single board computers. To make a long story short, I could not manage it, but I eventually landed on an article, Ubuntu 20.04: Connect to WiFi from command line by Lubos Rendek (May 13, 2020), that set me on the correct path. It seems that for some time Ubuntu has been using a different network configuration tool: Netplan. After reading a bit of the documentation on that site and How to Use the Netplan Network Configuration Tool on Linux by Jack Wallen (September 7, 2018), I came up with the following netplan configuration file.

michel@hpav:~$ cat /etc/netplan/00-installer-config.yaml # This is the network config written by 'subiquity' network: version: 2 renderer: networkd ethernets: enp0s7: dhcp4: true optional: true wifis: wlx00e533bf124a: dhcp4: true optional: true access-points: "my_wifi_ssid_in_quotes": password: "my_wifi_psk_in_quotes"

Note that subiquity is the Ubuntu installer, so this .yaml will not be overridden. The ethernets section was already created by the installer, I added the optional: true line because it would not do to suspend the boot process waiting for an ethernet connection which in the end will not be used. The interface name of the Wi-Fi card, wlx00e533bf124a, I found with the lshw command shown above, but it can be found with the ip a command.

After rebooting, I was disappointed to see that the Wi-Fi card was not up.

michel@hpav:~$ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:2b:83:28:eb:17 brd ff:ff:ff:ff:ff:ff inet 192.168.1.133/24 brd 192.168.1.255 scope global dynamic enp0s7 ... 3: wlx00e533bf124a: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000 link/ether 00:E5:33:BF:12:4A brd ff:ff:ff:ff:ff:ff

Luckily, the system journal had some pertinent information:

michel@hpav:~$ journalctl --no-pager | grep netplan ... Sep 04 21:02:42 hpav systemd[1]: Started WPA supplicant for netplan wlx00e533bf124a. Sep 04 21:02:42 hpav systemd[559]: netplan-wpa-wlx00e533bf124a.service: Failed to execute command: No such file or directory Sep 04 21:02:42 hpav systemd[559]: netplan-wpa-wlx00e533bf124a.service: Failed at step EXEC spawning /sbin/wpa_supplicant: No such file or directory ...

Actually, I found the information another way, first by listing failed system services; there was one, and then checking its status.

michel@hpav:~$ sudo systemctl --no-pager | grep fail ● netplan-wpa-wlx00e533bf124a.service loaded failed failed WPA supplicant for netplan wlx00e533bf124a michel@hpav:~$ sudo systemctl status netplan-wpa-wlx00e533bf124a.service ● netplan-wpa-wlx00e533bf124a.service - WPA supplicant for netplan wlx00e533bf124a Loaded: loaded (/run/systemd/system/netplan-wpa-wlx00e533bf124a.service; enabled-runtime; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2020-09-04 22:27:11 UTC; 5min ago Main PID: 568 (code=exited, status=203/EXEC) Sep 04 22:27:11 hpav systemd[1]: Started WPA supplicant for netplan wlx00e533bf124a. Sep 04 22:27:11 hpav systemd[568]: netplan-wpa-wlx00e533bf124a.service: Failed to execute command: No such file or directory Sep 04 22:27:11 hpav systemd[568]: netplan-wpa-wlx00e533bf124a.service: Failed at step EXEC spawning /sbin/wpa_supplicant: No such file or directory Sep 04 22:27:11 hpav systemd[1]: netplan-wpa-wlx00e533bf124a.service: Main process exited, code=exited, status=203/EXEC Sep 04 22:27:11 hpav systemd[1]: netplan-wpa-wlx00e533bf124a.service: Failed with result 'exit-code'.

I verified that the package, called wpasupplicant, that contains wpa_supplicant was not installed and then installed it in the usual manner.

michel@hpav:~$ apt-cache policy wpasupplicant wpasupplicant: Installed: (none) Candidate: 2:2.9-1ubuntu4.1 Version table: 2:2.9-1ubuntu4.1 500 500 http://ca.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages 2:2.9-1ubuntu4 500 500 http://ca.archive.ubuntu.com/ubuntu focal/main amd64 Packages michel@hpav:~$ sudo apt install wpasupplicant Reading package lists... Done ... Setting up wpasupplicant (2:2.9-1ubuntu4.1) ...

The welcome screen after rebooting and logging back on the machine showed that everything worked.

Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-45-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Fri 04 Sep 2020 10:39:19 PM UTC System load: 1.09 Usage of /: 0.3% of 1.79TB Memory usage: 4% Swap usage: 0% Temperature: 40.0 C Processes: 124 Users logged in: 0 IPv4 address for enp0s7: 192.168.1.133 IPv6 address for enp0s7: fd00:fc:8d4f:71b2:13d:82aa:18ecb:de95 IPv6 address for enp0s7: 2607:fea8:f1a0:d1d8:13d:82aa:18ecb:de95 IPv4 address for wlx00e533bf124a: 192.168.1.134 IPv6 address for wlx00e533bf124a: 2607:fea8:f1a0:d1d8::d IPv6 address for wlx00e533bf124a: fd00:fc:8d4f:71b2:a79:33bf:1e9a:124a IPv6 address for wlx00e533bf124a: 2607:fea8:f1a0:d1d8:a79:33bf:1e9a:124a

Had I read the manual page for netplan, I would have realized immediately that WPA Supplicant had to be installed.

michel@hpav:~$ man netplan ... Properties for device type wifis: Note that systemd-networkd does not natively support wifi, so you need wpasupplicant installed if you let the networkd renderer handle wifi.

In conclusion, installation of a Wi-Fi network interface in Ubuntu Server 20.04 is not complicated at all:

  1. Make sure that the hardware driver is loaded.
  2. Install the wpasupplicant package.
  3. Add the needed Wi-Fi credentials to the the /etc/netplan/xxx.yaml file.

Out of curiosity, I checked how the Wi-Fi interface is handled on my desktop running Mint 19 which is derived from Ubuntu.

michel@hp:~$ uname -a Linux hp 5.4.0-42-generic #46~18.04.1-Ubuntu SMP Fri Jul 10 07:21:24 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux michel@hp:~$ cat /etc/netplan/1-network-manager-all.yaml # Let NetworkManager manage all devices on this system network: version: 2 renderer: NetworkManager

I actually like that Ubuntu Server uses the built-in systemd-networkd configuration controller instead of installing yet another package. However, there are some aspects of Ubuntu Server that I wanted to change.

Removing Snap toc

Snap is the Canonical package manager that competes with Flatpak and AppImage. I think the way it is so closely tied into the system (try the df -h command to see what I mean) sort of defeats the purpose. Furthermore, I was disappointed with early snap packages in Ubuntu 18.04 which was one of the reasons, but only a minor one, that pushed me to return to the Mint (the major reason is that I prefer the Mate desktop).

Removing the Snap package and daemon was not complicated following the instructions found in Disabling Snaps in Ubuntu 20.04 by Kevin Custer (April 20, 2020). I noticed that the installed Snap packages were not the same as in the article, but then the author may have been running the full desktop version of Ubuntu. On my system snap list showed that core18 and lxd were the only packages running plus the spand service. The following commands were all that were needed on my system.

michel@hpav:~$ snap remove lxd michel@hpav:~$ snap remove core18 michel@hpav:~$ snap umount /snap/core/xxxx michel@hpav:~$ sudo apt purge snapd

Unfortunately, forgetting to keep a keep a record, I cannot recall the actual name of the Snap core service that had to be unmounted. It can be found by running the df command. I did not find any of the Snap related directories mentioned in the article, but there was an additional directory, mostly empty, that I removed.

michel@hpav:~$ sudo rm -rf /root/snap

Disabling Automatic Upgrades toc

By default, automatic upgrades are enabled. I prefer to control the updates of the system so I disabled them.

michel@hpav:~$ sudo dpkg-reconfigure unattended-upgrades Replacing config file /etc/apt/apt.conf.d/20auto-upgrades with new version

The service that handles the upgrades, a Python script, still gets loaded by systemd. If this is to be avoided, see How To Disable Unattended Upgrades On Ubuntu by sk (March 16, 2020) for the details on how to remove the package altogether. I'll wait until I am sure that is what I want, although it should be simple enough to install the deleted package if wanted.

Disabling CloudInit toc

Following Hitoriki, (How to remove cloud-init from Ubuntu Server 20.04 (June 20, 2020) I removed CloudInit.

michel@hpav:~$ sudo touch /etc/cloud/cloud-init.disabled

This will take effect on the next boot. After reading what CloudInit did, I preferred disabling the service just in case. Disabling the service did not change the locale, time zone or hostname so perhaps I will simply remove the package a little later on.

Conclusion toc

With all these changes, I found that the operating system occupies 118 Mbytes of the 3,72 Gbytes of available memory which is a relatively small footprint. According to htop the system was running 29 tasks after settling down once the initial boot sequence was completed. This is not too bad, my Debian server has 78 tasks loaded which use up 141.7Mbytes but it is running two important servers, syncthing and nginx not yet added in the Ubuntu system.

Today, I have been looking at just how I should use this remote server and it struck me that I may be installing some lightweight NAS system which would mean replacing Ubuntu. No matter, this exercise was a lesson which I am glad to have completed.