Justin Merrill, MBA, BS .:|:. Platform Engineer

Platform | DevOps | SRE | K8s | GitOps | IaC | CICD | Security | IAM | Cloud | Software | Data | APIs

Uncategorized

Alpine Linux 3.20.3 with xfce4 Desktop – Installation and Repair Script – Troubleshooting Steps

It’s been awhile!

I recently started very much appreciating how much amazing info is shared online from blogs posts, just like this one.

So maybe this will help you out by reading on (and if my SEO game is still strong after all these decades).

You might have arrived here because you need help with one or more of the following issues (or something similar):

  • You need to resolve xfce4 Desktop Issues After ‘apk update’ from before Alpine v3.20.3 (:latest at the time of writing)
  • You are stuck with only a flashing cursor and black screen instead of xfce login prompt
  • You have no mouse or keyboard function when xfce4 desktop starts on Alpine Linux v3+
  • You want to install xfce4 on Alpine Linux 3.20+ for your first time, but the other guides out there all seem to be missing something…

TL;DR for xfce4-install-or-fix-for-AlpineLinux3.20.x.sh

For those of you that just want to blindly run the “fixer script” some random person on the internet wrote and put on a website, skip the context, personality and backstory and click here or scroll down to the code block for: xfce4-install-or-fix-for-AlpineLinux3.20.x.sh


Problem Statement

I recently updated a few Alpine Linux VMs for version 3.20.2 to 3.20.3 and for some reason or another, this caused a black and blank screen with a flashing cursor in the top left corner, after booting. This appears to be a fairly common issue that has happened throughout the last 7+ years with Alpine Linux users that attempt to install the xfce Desktop Environment. But most of the posts I found were extremely dated, something going all the way back to Alpine v3.8, sometimes even earlier.

As I began picking apart the possible reasons and potential fixes, I also lost my keyboard and mouse function once xfce4 desktop wallpaper would display

While in both situations I was still able to ssh into the Alpine Linux VM, which was fine at first, I still wanted my desktop with mouse capabilities back.

By doing a key combination of Ctrl + Alt + F2 (or whatever F-key you like for tty#) I was able to bring up with terminal again from the browser-based Hypervisor Console management tool.

Awesome! Now could I could log in “natively” again, even though it was just from a terminal (no GUI, yet).

But, after reviewing 3 different articles about xfce4 with alpine and lots of other side quests, here is the progression that led to the solution, below.


The ‘xfce with Alpine Linux’ Articles Used for the Context of the Solution

https://wiki.alpinelinux.org/wiki/Xfce – The official Alpine Linux Wiki for xfce

If you are installing Alpine Linux for the first time, I highly recommend that you follow this guide and install xfce as your first Alpine Linux desktop environment. It’s *almost* as powerful and polished as Gnome DE, but takes a “minimalist” approach to how to add various tools and options, rather than assume you want games and a full blown LibreOffice Suite with every new install. Gnome Disk Utility and gparted are available for xfce on alpine, as are tons of other apk packages for gnome-* and xorg-* in Alpine, too. But even still, I did not manage to bring up my xfce4 Desktop again by following the guide (I figured it out later on, bear with me


https://breder.org/alpine-setup

This great article added the part about configuring alpine with sudo (instead of doas), and granting WAY too many permissions to a user, but the mentioned rc-update-add dbus might be the magic to a fix for your issue (or test first, with rc-service dbus restart).


https://www.linkedin.com/pulse/adding-gui-graphical-user-interface-our-alpine-linux-virtual-ionica

This article is a bit dated now, as it was written for Alpine Linux v3.17.x, but here Razvan tells us about setup-xorg-base, which was what solved my issue after tinkering and trying a number of different things. This was the “magic” that led to the working xfce4 DE again!


Full Disclosure: There is actually a reference to both dbus and setup-xorg-base on the LinuxAlpine.org xfce Wiki under the headings “Manual installation”, and below that, “Prerequisites”. But since I’d already had a working desktop before, I assumed that I met both of these already. Yes, that’s right. Someone on the internet just admitted they were wrong.



Alpine Linux 3.20+ /etc/apk/repositories Configuration Options

After some trial and error, and re-visiting the multiple guides I used to figure out how to get xfce to work in Alpine Linux 3.20+, I found a quick fix that should work for every similar system, so I can easily apply it through some form of automation.

For my guest VMs, I enabled the following apk repos:

  • main: https://dl-cdn.alpinelinux.org/alpine/v3.20/main
  • community: https://dl-cdn.alpinelinux.org/alpine/v3.20/community

The “main” repo is enabled by default, but the “community” repo may not be (unless you enabled during initial install with the ‘setup-alpine’ script).

Living on the Alpine Linux edge (Not For Production)

If you prefer, you can “live on the edge”, and instead (Note the emphasis on INSTEAD) use the “edge” repos, which are *NOT* considered “production ready”. You can do so by inverting the selected repositories by adding/remove comment #’s in front of the URLs in the file so you are using “edge” instead. If you do, just be aware this is considered “unsafe for anything but testing”.

In hindsight, I discerned that I had the issue of losing the xfce4 DE due to my leaving both the v3.20 community AND the edge community repos enabled during an apk update, but YMMV. This was most likely a setting I was experimenting with a few months ago and just forgot to clean up. But having admitted that, I did not see any issues in my dozens of copied Guest VMs with this above described flawed apk repo configuration until the upgrade between v3.20.2 to v3.20.3. But the lesson has been learned (Hopefully this saved you for the same future fate).

Here is a very important read from the AlpineLinux.org Wiki for how Alpine Linux apk repositories work, and how to prevent future problems: https://wiki.alpinelinux.org/wiki/Repositories

If you need an edge package, either spin up a new Alpine instance for that atomic purpose, are toggle repos as needed and “pin” your working apk package version.

DISCLAIMER: The below advice is NOT meant for a production system and has a chance of breaking things that only work with edge packages.

If you really MUST downgrade from the edge repo packages and go back to main or community, then make the changes to /etc/apk/repositories you want and then execute the following to get you back on track with the repository of your new configuration:

doas apk upgrade -Ua --interactive


The Fix and Install Script for xfce4 with Alpine Linux v3.20.x: xfce4-install-or-fix-for-AlpineLinux3.20.x.sh

Here is the quick fix I recently created in a Bash shell (.sh) script to get xfce back up and running as the Desktop Environment (DE) for an Alpine Linux 3.20.x VM guest machine on a XenServer Hypervisor.

This may also work as an installation script for xfce, too. You will have to add a few accessories of your own, though, like a lightweight GUI text edit (mousepad) and a web browser of your choice (chromium or firefox/firefox-esr work fine).

Using flatpak with flathub opens up a very wide world of possibilities for even using alpine on extremely dated hardware, like an old laptop or mini-pc.

There are still a few limitations that I’ve seen with Alpine as a “daily driver”, such as I still have not found a good way to natively install pgadmin (its not in flathub) or a number of other more “cumbersome” tools and services like , GitLab CE, Jenkins, Mulesoft, jFrog, ThingsBoard, Wuzah, Docker-desktop (Docker engine DOES work on Alpine, though), etc.

But!

Docker (Engine) and both Podman engine and podman-desktop seem to work pretty well on the more recent versions of Alpine, so there may be some opportunities to find work arounds for getting it all to work on Alpine. There are even a few people that have managed to use Alpine Linux as the host VM of their Hypervisors (I can’t recommend it, but maybe I’ll give a try and post about it, someday, since Alpine has a libvirt apk available).

I have been extremely impressed with the performance of Alpine Linux on very meager resource allocations. Even running with 2 slow and dated vCPU cores and 4GB of DDR3 RAM, there is a considerable amount of power and performance over literally every other minimal OS configuration I have ever tried to install a GUI with. I have seen a noticeable increase in performance with non-GUI Alpine VMs with only 2 vCPU and 256MB (yes, MEGAbytes of RAM… In 2024). Perhaps I will have to compare Alpine performance to FreeBSD or OpenBSD with something basic, like a JMeter test against identical spec-ed VM’s with nginx or lighttpd running. Feel free to reach other to me here if this is something you would like to see.

Have fun exploring Alpine Linux!

j-merrill

Justin Merrill, MBA, BS .:|:. Platform Engineer Engineer | Software | DevOps | CICD | Cloud | Security | IAM | SRE | K8s | GitOps | IaC | Data | APIs | Platform

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.