LinkedIn Sourceforge

Vincent's Blog

Pleasure in the job puts perfection in the work (Aristote)

Install Alpine Linux on a Lenovo T14s

Posted on 2024-01-02 22:42:00 from Vincent in Alpine Linux

For an OpenBSD user like me since +10 years, coming back to linux is quite strange and fun. The goal is to have multi-boot systems. This blog will document how I did it.


I have the opportunity to use a brand new Lenovo T14s with AMD Ryzen 7 CPU and huge amount of ram and huge NVMe disk.
So, clearly too much for only OpenBSD. So, my idea was to install different OSes and see the differences.

The machine will be perfect to run virtual systems. So I'll do it maybe later. But at this stage I would like to see how OpenBSD compares to other systems on such brand new machine.

First thing first, I've installed OpenBSD on the whole disk (simplicity), to see how it works. And in fact everything was successful except the Wifi (as expected). Details are available on nycbug.
After having adapted the login.conf file, I never had crashed anymore.
But that's not the scope of this specific blog ;)

Having an OS working, I've use it to grab Alpine Linux ISO and burn it on an USB key:

# dd if=alpine-standard-3.19.0-x86_64.iso of=/dev/rsd1c bc=1M conv=sync

Making partitions

Because the BIOS is GPT compliant we do not have the limit of 4 partitions on the disk. Thus I did 6 partitions of 50G each to install different BSD systems and few Linux distro and 1 partition for EFI.

I was not comfortable enough to do it with Linux install ISO, so I inserted an OpenBSD boot USB key and did it with fdisk.

First partition for EFI with a size of 512M (a posteriori, I think that 100M will be largely enough).
I did a Linux swap partition of 16G
Then I did 6 partitions of 50G. I dedicated one for OpenBSD, one for FreeBSD/DragonFlyBSD and 4 for linux distros.

Alpine Linux Install

Once the partition made, I reboot the machine with the Alpine Linux USB key.

Since I do not want a "full disk install", I do not follow the whole process.
Once booted:

login as root (no passwd required)
type: setup-alpine
follow the instructions (keyboard, network, ...) until disk part

At the disk part I cancel the process and continue from the shell.

Mounting disk

I format the targeted disk with ext4. For that purpose I must request the required package:

apk add e2fsprogs
mkfs.ext4 /dev/nvme0n1p9
mount /dev/nvme0n1p9 /mnt

apk is the package manage for Alpine linux. During the installation process few packages will be installed.
Please note that, in my case, my targeted partition is the 9th one.

The I must attach the EFI partition to it.

mkdir -p /mnt/boot/efi
mkfs.vfat /dev/nvme0n1p1
mount /dev/nvme0n1p1/mnt/boot/efi

In this case, no need to use apk to have the command mkfs.vfat.

Installing Alpine linux

We must inform that we are in an EFI context and we can trigger the installation:

export USE_EFI=1
setup-disk -m sys /mnt

Please check Alpine linux web pages for more details. But "-m sys" will trigger a "normal" install on disk.
During this process an entry will be created in /mnt/boot/efi which is like this:

-rwxr-xr-x    1 root     root        135168 Jan  2 17:47 /boot/efi/EFI/alpine/grubx64.efi

This EFI process inform where the boot elements are present (in partion 9 in my case).

The whole process takes less than 30 seconds !!.
Like often with Alpine Linux, it's fast ;).

Moreover it takes the parameters you have entered for the wifi connection. At reboot, you machine will immediately use the same parameters.

Then we have to inform the BIOS/EFI that there is a new entry available. For that we must use the program called efibootmgr.

apk add efibootmgr
efibootmgr -c -d /dev/nvme0n1 -p 1 -l '\EFIlpine\grubx64.efi' -L Apline

In short this command add an entry called Alpine with the reference to grubx64.efi which reside on disk nvme0n1 on partition 1.
It's important to place simple quote and use backslashes in path name for grubx64.efi. I see on different web pages other notifications, but they are not working on my case. Only this one was working.

If everything was ok, it's time for the first boot.


Evaluation of desktop environments

Normally your machine will trigger this last install of Alpine Linux. If it's not the case, hit F12 to see which entries are defined in the EFI program.

I've tested different desktop environments by following the Apline Linux processes. Which are mainly based on a simple command:

apk update
apk upgrade
setup-desktop gnome

But I've tried plasma, mate and xfce too.
With this simple command all required packages are coming in order to have a complete system. TIn some cases firefox comes with, in other cases you have to install it your self with the command "apk add firefox".

But none of those systems were matching my tastes. On OpenBSD I'm using Openbox with tint2, so, I've selected lxqt.

Most of the required actions to performed a document on Apline Linux page

Preparation of my LXQt desktop

In any cases, before installing a desktop environment, It's safe to perform the following actions:

apk update
apk upgrade
adduser -u 1001 vi
addgroup vi lp
addgroup vi wheel
addgroup vi audio
addgroup vi video

Because I'm using a Belgium keyboard, I must add in /usr/share/X11/xorg.conf.d/99-my.conf

Section "InputClass"
    Identifier "keyboard"
    MatchIsKeyboard "yes"
    Option "XkbLayout" "be"
    #Option "XkbVariant" "nodeadkeys"

Then trigger installation of all required packages:

apk add lxqt-desktop obconf-qt lximage-qt pavucontrol-qt screengrab arandr sddm elogind polkit-elogind gvfs udisks2
tt=$(apk search -q gvfs*) # to install all gvfs modules
apk add $tt
apk add ntfs-3g fuse-openrc adwaita-icon-theme picom adwaita-qt breeze oxygen libreoffice firefox 
apk add neovim efibootmgr 
apk add font-dejavu
apk add font-hack #(for Qterminal)
apk add alsa-utils alsaconf pulseaudio 
apk add xscreensaver-gl-extras
apk add mandoc man-pages mandoc-apropos less less-doc
apk add docs # install man pages
rc-update add dbus
rc-update add sddm
rc-update add fuse
rc-update add elogind

The last commands register automatic start of few daemon.
If everything went smoothly, it's good moment to perform the last reboot.

At the reboot, the machine should show you a login screen where you must enter your user's password.

And voila ;)

Adding wifi manager

To have a nice and simple to use small icons on the task bar to manage wifi and network connections, we can install NetworkManager:

apk add networkmanager networkmanager-wifi

I must add my user "vi" to the group "plugdev" in order to be able to modify wifi parameters:

addgroup vi plugdev                                  
rc-update add networkmanager                         
rc-update del networking boot                        
rc-update del wpa_supplicant boot

And finally, we give all hands to networkmanager and deactivate wpa_supplicant.

There is one extra action to perform:

cat << _EOL > /etc/NetworkManager/NetworkManager.conf



I let you check the documentation, but via this command we define how this wifi manager must run. In such case, I do not activate the rando mac-address use during the scanning process.

To be complete, I've put the parameter "cloned-mac-address" to "Permanent" via the "Edit connections" menu when righ-clicking on the NetworkManager icon.

One last element concerning shells

By default Alpine Linux is using /bin/ash, the ash shell provided by busybox.
Unfortunately, the Xsession process does not take into account the fact possible lines you place in ~/.profile.
To solve this, you must add the following line in ~/.xsession

export ENV=~/.profile

At next login in LXQt, your .profile will be fully taken into account.
In my case this solve the fact that "alias" command present in .profile were not taken into account.

Scrolling via touch screen

To be able to vertically scroll web pages in firefox, we must add the following variable in our ~/.profile file

export MOZ_USE_XINPUT2=1

Without this modification, vertical dragging your fingers will simply select several lines on the webpage.


Thanks to his minimalist philosophy, Alpine Linux is amazing good: Light and fast. Moreover they are concerned about security aspects: musl libc, PaX, OpenRC, ASLR, ....

The whole system takes 3.5G on disk.

Touch screen, audio volume, brightness buttons, wifi are all recognized without any issue.

All in all it takes less than 10 minutes to install such system. And it does what it proposes, not more, not less.

9, 9
displayed: 7930

What is the last letter of the word Moon?