Installing Alpine Linux and KDE Plasma
Published: 2022-03-25
Last updated
Published: 2022-03-25
Last updated
2024 update: The Alpine Linux installer changed a bit since this article was published. Although the instructions should still remain largely unchanged, exercise caution if you stumble upon something not mentioned in this article.
When it comes to choosing a Linux distro, you may want to use Arch Linux because it's lightweight and you choose what runs on your system. There's a distro that is even lighter than Arch Linux: Alpine.
In this guide, I will explain how to get a fully working KDE Plasma desktop on Alpine Linux.
This guide admits you have already installed a Linux system before (especially Arch Linux, or other systems that require using command line). If you have never installed a Linux system, you should look at Fedora. This guide also admits you are familial with the vi
text editor.
The obvious first step is to download the system ISO. Head to https://alpinelinux.org/downloads/. Now pick the extended version since it contains everything we need to get a working install (this guide doesn't cover installing with other versions).
Once the download is done, put the ISO on a USB stick as you'd do for any Linux distro, and boot on it (these two are out of the scope of this guide).
Now that Alpine is downloaded and you've booted into the live system, login as root
.
If you have ever installed Arch Linux, this prompt might seem familial, although Alpine Linux comes with a step by step installer that helps you get everything ready.
Skip this part if you don't especially want a Btrfs partition
Now comes the hard part: formatting your disk to Btrfs. Btrfs is the recommended file system for Linux systems nowadays, but Alpine Linux doesn't use Btrfs by default. If you want to use Btrfs for your system partition, you need additional setup.
First, load the Btrfs drivers with modprobe btrfs
.
Now, partition your disk using your favorite utilities. If you don't know which tool to use, you can use cfdisk
(install it with apk add cfdisk
), but be careful with this tool! Make sure to reboot after changing the partition table.
Finally, run apk add btrfs-progs
and mkfs.btrfs -f /dev/sda1
(replacing sda1
with the name of your partition). You now have configured Btrfs for your system partition. If you want to create additional Btrfs partitions, you can do so following these same steps.
Installing the system is simple: run the setup-alpine
command and follow the steps.
You get a list of all the available keyboard layouts. First, enter the name of the keyboard language you have, and then select the variant you want (for example in French I can use AZERTY, BEPO or DVORAK). If you are installing Alpine Linux on a Mac, you might want to use the Mac variant.
This part may seem like nothing but it is actually very important. If you want to access your computer remotely from another device in your network, you need to give it a name. Make sure you use a name that isn't already existing on your network.
The name can only contain lowercase letters, numbers, dots, hyphens and underscores.
To make sure you get the most up-to-date system once you install, you need to configure the network. While this is not a required step, it is highly recommended that you setup the network.
Generally, just pressing Enter at every prompt should get you connected, unless your network requires special configuration.
Although I say "pressing Enter at every prompt", don't blindly press Enter as you may go to the next step accidentally. Be careful what the prompt says. If it says "New password", don't press Enter and read the next step of the guide.
root
passwordroot
is the system administrator account on POSIX systems. Alpine, by default, does not create additional users.
At the end of this guide, we will disable the root
account for security purposes, but it is required that we give it a password to access the system once it is install.
Selecting a timezone will... obviously, help set the time. If you don't know what you need to put here, you can view the list of TZ database timezones on Wikipedia.
If you are on an enterprise network that requires the use of a proxy server, it is now time to enter the address of that proxy server. If you don't use a proxy server, simply press Enter and continue the installation.
The Network Time Protocol (NTP) is a protocol that helps keep your computer's time in sync with Internet time.
Alpine asks you what NTP service you would like to use. Unless you know what you are doing and want to use another service, simply press Enter. If you want to not use NTP, enter none
.
A mirror is the server that is used to download packages that will be installed on the system. By default, Alpine comes with no mirror installed, which greatly limits the amount of packages you can install; so the installer helps us get a mirror installed.
The way I recommend to setup a mirror is to enter f
, which will pick the fastest mirror near you. It takes a while because it have to test the speed of all known mirrors, but you will end up with a perfect config file with the fastest mirror near you.
Once it is done, it will automatically add the fastest mirror to your config and lets you continue the setup:
You can also use any of these 3 other options:
If you want to use a random mirror, enter r
If you wish to not setup mirrors (not recommended, we assume you will setup mirrors later), simply enter done
.
If you have a specific mirror you want to use, enter its number if it's in the list, or its URL if it's not in the list
If you wish to access your computer's command line remotely, you might want to install an SSH server.
When Alpine asks you which SSH server you want to use:
Enter openssh
if you want to enable remote login;
Enter none
if you don't want
This choice is not permanent, you can always install or uninstall the SSH server after installing the system.
Make sure you follow these steps carefully. Any wrong choice can lead to data loss (make sure you have a recent backup before continuing). Always double check what you are doing.
If you want to use the Btrfs partition we created earlier in this guide, refer to the Advanced installation (Btrfs) section below.
Selecting the target disk
Alpine will now show you the list of all disks that are attached to the system. Enter the name of the disk you want to use as a system disk (you can setup additional partitions after installing).
Selecting the contents type
Now, you are asked what is this disk supposed to contain. By default, I recommend setting sys
, but:
if you want to setup encryption, enter crypt
, configure encryption, then enter sys
;
if you want to setup the logical volume manager, enter lvm
, configure logical volumes, then enter sys
Confirm that you want to erase the disks, and continue the installation.
These steps are required only if you installed Alpine on a Btrfs partition. If you used the default installation procedure, the bootloader is already installed and working.
UEFI systems
The bootloader is already installed and working. You can now remove the installation media from the computer, and enter reboot
to boot into the newly installed system.
Legacy BIOS
By default, Alpine Linux wants to use the extlinux bootloader, but I recommend GRUB as it is simpler to use, configure and maintain.
First, remove all the other bootloaders using apk del syslinux
; and install GRUB on the live system using apk add grub grub-bios
.
You also need to install GRUB on the installed system, using these commands:
chroot /mnt
apk add grub grub-bios
And exit
to go out of the chroot environment
Then, finish installing GRUB using grub-install --root-directory=/mnt /dev/sda
(replace /dev/sda with the name of your disk), and these commands to generate a configuration:
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
chroot /mnt
grub-mkconfig -o /boot/grub/grub.cfg
And exit
to go out of the chroot environment
You're done installing the bootloader. You can now remove the installation media from the computer, and enter reboot
to boot into the newly installed system.
Now that you have installed Alpine and that you booted from the disk, there are a number of things you need to do.
(Optional) Make it a rolling release distro
If you want to get software updates as they release, you can use Alpine Linux Edge to transform this install into a rolling release install.
To do this, edit /etc/apk/repositories (vi /etc/apk/repositories
), comment all the lines, and uncomment the lines that contains edge
Save the file (:wq
), run apk update
to fetch the repositories, and apk upgrade
to update your system. Finally, run reboot
to make sure you run the latest kernel.
The Community repository contains additional packages that are not included in the base distro. If you followed the Make it a rolling release distro section, you don't need to enable the Community repository as it should already be enabled.
To enable the Community repository, edit /etc/apk/repositories (vi /etc/apk/repositories
) and uncomment the first line that ends in community
. Save the file (:wq
) and run apk update
.
With doas, a user can gain administrator privileges without using the root password. Installing doas is recommended but not necessarily required.
First, run apk add doas
, then edit /etc/doas.d/doas.conf (vi /etc/doas.d/doas.conf
), add permit persist :wheel
as the last line of the file.
Most desktop apps (including the desktop itself) won't start if you try to run them as root. This means you need to create a user account on this system.
First, run adduser <user>
(replace <user> with the name you want), and run adduser <user> wheel
to make this user administrator.
Type exit
, and log in as the user you just created. Run doas whoami
to make sure doas is configured properly. Now, disable the root account by running doas passwd -l root
(you can enable it again with doas passwd -u root
).
Now that we have a working system, we need to install a desktop environment. Run doas apk add plasma elogind polkit-elogind dbus
which will install all the required packages, and complete installing Xorg with doas setup-xorg-base
Now enable the required services by running these commands:
doas rc-update add dbus
doas rc-update add elogind
doas rc-update add polkit
(may not exist)
doas rc-update add udev
doas rc-update add sddm
Then, reboot the system (doas reboot
), and you should be greeted with SDDM. If that's not the case, make sure you have the proper video drivers installed.
Now, it's great, we have a working KDE Plasma desktop, but it's missing a lot of apps (we don't even have a terminal). We can easily solve that:
log out from KDE Plasma
press Ctrl+Alt+F2 to access the console
login from here
run doas apk add oxygen-sounds kde-applications-base
You'll obviously also want a browser. KDE recommends using Falkon, but you can also install any browser you want.
Once you're done installing apps from the console, press Ctrl+D to log out, and then Ctrl+Alt+F7 to go back to the GUI.
Earlier during the installation process, the keyboard was configured. Now that Xorg (or Wayland, depending on the session type you select) is running, your keyboard may be set back to QWERTY.
To fix that, head into Plasma's System Settings, Input Devices, then Keyboard, Layouts, and check Configure layouts. Add your prefered keyboard layout, and hit Apply.
To make sure it applies also to the login screen, edit /usr/share/sddm/scripts/Xsetup (kate /usr/share/sddm/scripts/Xsetup
) to add setxkbmap "fr"
(replace fr with your prefered X11 keyboard map)
Earlier when we created our user, we didn't specify a name for it. The default name is "Linux User", so we want to change that.
Click on Plasma's Application Launcher, and click on the profile picture. This opens the System Settings, where you can set a proper username (and profile picture if you want).
Once you are done with this, you need one final reboot. You can now enjoy KDE Plasma on a lightweight system (less than 3 GiB of disk space used on a full install, less than 300 MiB of RAM used at boot) that is Alpine Linux.
Next time, I will try running GNOME on Alpine Linux, so stay tuned.