Wifi on MacBook Running Void Linux
Thu, 07 Apr 2022 05:00:00 -0600
Recently, I got my hands on an older MacBook Air. Normally I avoid Apple products, but since this one was free, I figured I would see if I could remove MacOS and replace it with something more privacy friendly. I chose to install Void Linux on it, since it's really light weight and an overall solid distribution (the boot time is lighting fast). If you haven't given Void a try, I would highly recommend it.
Prelims
The installation was relatively straight forward (Void has a friendly pseudo graphical installer), but to my great annoyance, this MacBook only had wireless (as do all newer MacBooks). This would have been fine; however, their proprietary Broadcom WiFi cards need additional set up to work. This caused me so much headache that I figured I would write an article on how to do it if you find yourself in a similar situation. Hopefully I can save you hours of scouring the Man Pages and Stack exchange like I did! Note that you will need a Ethernet to USB-A so that you can install the firmware and other packages!
Before beginning this process, make sure to install the non-free repositories so that contain the proprietary Broadcom drivers and re-sync your repositories.
# xbps-install void-repo-nonfree
# xbps-install --sync
Next you will need to install the free and proprietary firmware/drivers from the Void repositories. I am generally a staunch advocate for free software, but with Wi-Fi cards, you do not have much choice.
# xbps-install linux-firmware linux-firmware-network
# xbps-install broadcom-wl-dkms
Setting up wireless
Once you have the firmware installed, you will need to load the drivers. To do this, run the modprobe command as follows:
# modprobe wl
In this example, we will be using a network management software. You can use wpa_supplicant if that is what you are comfortable with, but to make your life easier, I would recommend using something like NetworkManager or Connman. In this tutorial I will be using NetworkManager. You will need to install and deamonize it along with the dbus package. Next, you will need to create some symbolic links.
# xbps-install NetworkManager dbus
Before we set up NetworkManager, it is important to stop any services that are managing the network. By default Void uses dhcpcd and wpa_supplicant (note that NetworkManager is a wrapper for wpa_supplicant, so if you don't stop the current deamon, your system will run two versions which may cause some nasty side effects). To permanently disable them, delete their symbolic link as follows:
# rm /var/service/dhcpcd && /var/service/wpa_supplicant
Then, you will need to start the NetworkManager so that it starts on boot as follows.
# ln -s /etc/sv/NetworkManager /var/service/
# ln -s /etc/sv/dbus /var/service/
Then add the following line to your NetworkManager.conf file. If it does not exist, you can make one. Add the following line to it and save. Make sure that you edit as root.
# vim /etc/NetworkManager/NetworkManager.conf
[device]wifi.scan-rand-mac-address=no
Save and restart the NetworkManager for setting to take effect.
# sv restart NetworkManager
Then, you can use the nmcli tool to scan the local network for WiFi and connect. I generally recommend doing this on an at home network. Trying to connect to eduroam or an enterprise network may require additional settings. This is the last thing you want when trying to establish a first time connection.
# nmcli dev wifi list
# nmcli dev wifi connect "your ssid" password "your password"
If that runs without a hitch, then you should be all set!
Edit: I've been using this computer for about six months. The operating system still runs fine, but I still run into issues with the network from time-to-time. The most common problem is switching from a wired to wireless connection. If I've been using a wired connection and unplug the Ethernet cable, the computer has trouble connecting to my home WiFi network. My work around has been to restart NetworkManager. This is less than ideal, but it's not the worst thing in the world. If I ever find a solution, I will post it here.
Edit: I have now switched to iwd to manage my wireless networks. Checkout my post for more details. I think that wpa supplicant was the real culprit here.