A farewell to Sabayon Linux

After a hiatus of thirty-four months in the blog posts on the Sabayon Linux Website, a couple of posts on 20 November 2020 announced that the distribution was switching its base distribution from Gentoo Linux to Funtoo Linux (‘Sabayon and Funtoo Linux Merge Projects’), and that the distribution was rebranding (‘Sabayon project is rebranding to MocaccinoOS’) and moving to a completely different package manager named ‘Luet’. A new Website and forums for MocaccinoOS were started, and the Sabayon Linux forums and Wiki are no more.

Although my first experience of Linux was Ubuntu in 2006, it was Sabayon Linux in early 2007 that turned me into a full-time Linux enthusiast and got me interested in the Portage package manager and Gentoo Linux, which I have been using as my main OS for many years now. My interest in Sabayon Linux waned when it moved to a binary package manager (‘Entropy’), and later when it switched from OpenRC to systemd.

Unlike binary distributions, Gentoo Linux enables users to use whichever init system they choose. My Gentoo Linux installations use OpenRC rather than systemd but, occasionally, if a problem interested me, I tried to help Gentoo Linux users who had opted to use systemd. As Sabayon Linux was based on Gentoo Linux with systemd, I would occasionally install Sabayon Linux in virtual machines as a convenient way to investigate issues in Gentoo installations using systemd. Likewise I occasionally tried to help Sabayon Linux users if a problem interested me.

Despite no longer being a full-time user of the distribution, I remained one of the moderators of the Sabayon Linux forums until its demise, albeit not having much time to devote to the role in the last few years. Activity on the Sabayon Linux forums had been quite low for quite some time and I was not surprised to learn that the distribution’s developers had finally called it a day late last year and started a new project. I wish them success with the new distribution.

Moving from Lubuntu 18.04 to 20.10

The Lubuntu developers will no longer be supporting Lubuntu 18.04, the final release of Lubuntu to use LXDE, after April this year. I therefore decided to replace it with Lubuntu 20.10 on the family desktop machine (a single-seat, multi-user installation). Lubuntu 20.10 uses LXQt so it was not feasible to upgrade the existing installation, as explained on the official Lubuntu Website:

Note, due to the extensive changes required for the shift in desktop environments, the Lubuntu team does not support upgrading from 18.04 or below to any greater release. Doing so will result in a broken system. If you are on 18.04 or below and would like to upgrade, please do a fresh install.

Thus I had to install Lubuntu 20.10 from scratch. I downloaded the ISO file (1.8 GB) from the official Lubuntu Website and used the dd command to create a LivePendrive:

user $ sudo blkid # Ascertain which device is the pendrive.
user $ sudo dd bs=4M if=/home/fitzcarraldo/lubuntu-20.10-desktop-amd64.iso of=/dev/sdb conv=fdatasync status=progress

Some of my blog posts during the last three years covered various additions and fixes I made to the Lubuntu 18.04 installation on the family desktop machine. Below I explain how I implemented those, if necessary, in the fresh 20.10 installation.

Due to the automated backup routine I implemented in 2018, a permanently-connected external USB HDD (filesystem label ‘FREECOM HDD’) contained a backup of each users’ home directory from the Lubuntu 18.04 installation:


I installed Lubuntu 20.10, overwriting the Lubuntu 18.04 installation. The resulting 20.10 installation had me as the sole user:

user $ whoami
user $ groups
fitzcarraldo adm cdrom sudo dip plugdev lpadmin sambashare

All the files in my home directory are owned by fitzcarraldo.fitzcarraldo (user.group). I want all users to be members of the group ‘users‘ in addition to a group with their own username, so first I added myself to that group:

user $ sudo usermod -a -G users fitzcarraldo
user $ groups
fitzcarraldo adm cdrom sudo dip plugdev users lpadmin sambashare

Before using the groupadd and useradd commands I double-checked their options, as these can differ between distributions:

user $ groupadd --help
user $ useradd --help

Then I added the other users (N.B. GID and UID are not the same value per username):

user $ sudo groupadd -g 1002 molly 
user $ sudo useradd -m -c "Molly" -g molly -G adm,cdrom,dip,lpadmin,plugdev,sambashare,users -p strawberryfields -s /bin/bash -u 1001 molly
user $ sudo groupadd -g 1003 aquilino
user $ sudo useradd -m -c "Aquilino" -g aquilino -G adm,cdrom,dip,lpadmin,plugdev,sambashare,users -p paperbackwriter -s /bin/bash -u 1002 aquilino
user $ sudo groupadd -g 1004 cholo
user $ sudo useradd -m -c "Cholo" -g cholo -G adm,cdrom,dip,lpadmin,plugdev,sambashare,users -p mysweetlord -s /bin/bash -u 1003 cholo
user $ sudo groupadd -g 1005 paul
user $ sudo useradd -m -c "Paul" -g paul -G adm,cdrom,dip,lpadmin,plugdev,sambashare,users -p sweet16 -s /bin/bash -u 1004 paul

WARNING: Do not add other users to the sudo group, otherwise Muon Package Manager in Lubuntu 20.10 will not allow you to install any more packages (see [Bug 1875346] Re: Muon does not recognize user password).

Lubuntu 18.04 used the LightDM display manager, whereas Lubuntu 20.10 uses the less-sophisticated SDDM display manager. To display the avatar of each user on the SDDM login page I copied a portrait photograph of each user to the relevant SDDM directory:

user $ sudo cp /home/fitzcarraldo/Pictures/Portraits/fitzcarraldo.png /usr/share/sddm/faces/fitzcarraldo.face.icon
user $ sudo cp /home/fitzcarraldo/Pictures/Portraits/molly.png /usr/share/sddm/faces/molly.face.icon
user $ sudo cp /home/fitzcarraldo/Pictures/Portraits/aquilino.png /usr/share/sddm/faces/aquilino.face.icon
user $ sudo cp /home/fitzcarraldo/Pictures/Portraits/cholo.png /usr/share/sddm/faces/cholo.face.icon
user $ sudo cp /home/fitzcarraldo/Pictures/Portraits/paul.png /usr/share/sddm/faces/paul.face.icon

I also configured a different wallpaper for each user’s Desktop:

user $ sudo mkdir /home/molly/Pictures/Wallpaper
user $ sudo chown molly.molly /home/molly/Pictures/Wallpaper/
user $ sudo mkdir /home/aquilino/Pictures/Wallpaper
user $ sudo chown aquilino.aquilino /home/aquilino/Pictures/Wallpaper/
user $ sudo mkdir /home/cholo/Pictures/Wallpaper
user $ sudo chown cholo.cholo /home/cholo/Pictures/Wallpaper/
user $ sudo mkdir /home/paul/Pictures/Wallpaper
user $ sudo chown paul.paul /home/paul/Pictures/Wallpaper/
user $ cd Pictures/Wallpaper/
user $ sudo cp wallpaper2.jpg /home/molly/Pictures/Wallpaper/
user $ sudo chown molly.molly /home/molly/Pictures/Wallpaper/wallpaper2.jpg 
user $ sudo cp wallpaper3.jpg /home/aquilino/Pictures/Wallpaper/
user $ sudo chown aquilino.aquilino /home/aquilino/Pictures/Wallpaper/wallpaper3.jpg 
user $ sudo cp wallpaper4.jpg /home/cholo/Pictures/Wallpaper/
user $ sudo chown cholo.cholo /home/cholo/Pictures/Wallpaper/wallpaper4.jpg
user $ sudo cp wallpaper5.jpg /home/paul/Pictures/Wallpaper/
user $ sudo chown paul.paul /home/paul/Pictures/Wallpaper/wallpaper5.jpg

Note that, unlike Lubuntu 18.04, Lubuntu 20.10 does not have a ‘Switch User’ option, so it is not possible for users to switch between sessions without logging out. I actually prefer it this way, as other family members would usually switch user rather than logging out in Lubuntu 18.04, leaving open sessions.

Lubuntu 20.10 still does not automatically unmount the external HDD when a user logs out, thus making it impossible for the next user who logs in to access the external HDD (see Prevent Lubuntu 17.10 from leaving an external HDD mounted incorrectly for other users). The fix in this version of Lubuntu differs from the fix in 18.04; I added the following two lines to the end of /usr/share/sddm/scripts/Xsetup:

# Fix to make sure each user can access the external HDD
udisksctl unmount --block-device '/dev/disk/by-label/FREECOM\x20HDD'

Virus scan

I set up my automated system to scan files downloaded to the ~/Downloads directory as explained below.

user $ sudo apt install clamtk
user $ sudo apt install clamav
user $ sudo apt install clamav-daemon
user $ sudo apt install clamdscan
user $ sudo apt install inotify-tools
user $ sudo apt install kdialog # In Ubuntu this would be zenity instead.

I copied the script ~/.monitorDownloadsGUI listed below into each user’s home directory, and made the ownership <username>.<username> and the script executable:



# Get rid of old log file, if any
rm $HOME/virus-scan.log 2> /dev/null

IFS=$(echo -en "\n\b")

# Optionally, you can use shopt to avoid creating two processes due to the pipe
shopt -s lastpipe
inotifywait --quiet --monitor --event close_write,moved_to --recursive --format '%w%f' $DIR | while read FILE
# Added '--recursive' so that a directory copied into $DIR also triggers clamscan/clamdscan, although downloads
# from the Web would just be files, not directories.
     sleep 1s
     # Have to check file length is nonzero otherwise commands may be repeated
     if [ -s $FILE ]; then
          # Replace 'date >' with 'date >>' if you want to keep log file entries for previous scans.
          date > $HOME/virus-scan.log
          clamdscan --move=$HOME/virus-quarantine $FILE >> $HOME/virus-scan.log
#         Use zenity in GNOME; kdialog in KDE and LXQt:
#          zenity --info --title="Virus scan of $FILE" --text="$(cat $HOME/virus-scan.log)"
          kdialog --title "Virus scan of $FILE" --msgbox "$(cat $HOME/virus-scan.log)"

I configured each user’s account to execute ~/.monitorDownloadsGUI at login. To do this in LXQt, in each user’s account I selected ‘Preferences’ > ‘LXQt settings’ > ‘Session Settings’ > ‘Autostart’.

Other useful packages

I installed the Elementary Icon Theme, as I saw some error messages about it not being installed:

user $ sudo apt install elementary-icon-theme

I installed a utility I find useful for searching for the location of a file, and ran the command to update its database of file names (you can run it at any time, or add it to e.g. crontab):

user $ sudo apt install mlocate
user $ sudo updatedb

I use Buku bookmark manager and Thunderbird e-mail client, so I installed those too:

user $ sudo apt install buku
user $ sudo apt install thunderbird
user $ sudo apt install thunderbird-locale-en

I added Buku to my crontab (the location of the binary has changed to /usr/bin/buku since I wrote my above-mentioned blog post on Buku in 2018):

1,21,41 * * * * rm /home/fitzcarraldo/ownCloud/Bookmarks/*.txt; sleep 30s && /usr/bin/buku -p --nc > /home/fitzcarraldo/ownCloud/Bookmarks/Buku_bookmarks_backup.txt

I prefer Signal to WhatsApp so I installed Signal Desktop by following the instructions at https://signal.org/download/#

Some of my family prefer the Google Chrome browser to Firefox, so I installed that:

user $ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
user $ sudo apt install ./google-chrome-stable_current_amd64.deb

I right-clicked on the Desktop and selected ‘Create Launcher’ to create the file ~/Desktop/Google_Chrome_Web_browser.desktop for each user (I edited it to change the icon, and ticked ‘Trust this executable’ if not ticked):

[Desktop Entry]
Name=Google Chrome Web browser
GenericName=Web browser
Comment=Google Chrome Web browser

I right-clicked on the Desktop and selected ‘Create Launcher’ to create the file ~/Desktop/Firefox_Web_browser.desktop for each user (I edited it to change the icon, and ticked ‘Trust this executable’ if not ticked):

[Desktop Entry]
Name=Firefox Web browser
GenericName=Web browser
Comment=Firefox Web browser

I right-clicked on the Desktop and selected ‘Create Launcher’ to create the file ~/Desktop/Signal.desktop (I edited it to change the icon, and ticked ‘Trust this executable’ if not ticked):

[Desktop Entry]
GenericName=Signal messenger
Comment=Signal messenger

All the family use Skype, so I downloaded the .deb file from https://www.skype.com/en/get-skype/download-skype-for-desktop/ and double-clicked on it to install it.

I right-clicked on the Desktop and selected ‘Create Launcher’ to create the file ~/Desktop/Skype_for_Linux.desktop (I edited it to change the icon, and ticked ‘Trust this executable’ if not ticked):

[Desktop Entry]
Name=Skype for Linux
GenericName=Skype messaging
Comment=Skype for Linux

I also dragged some of the icons from the Desktop to the Panel in order to create quick-launch items on the Panel, useful when frequently used items on the Desktop are obscured by open windows.

I installed and configured the utility Neofetch that can be used to display system information in a terminal window:

user $ sudo apt install xterm
user $ sudo apt install neofetch

I right-clicked on the Desktop and selected ‘Create Launcher’ to create the file ~/Desktop/Neofetch.desktop (I edited it to change the icon, and ticked ‘Trust this executable’ if not ticked):

[Desktop Entry]
GenericName=A command-line system information tool written in Bash
Comment=A command-line system information tool written in Bash
Exec=xterm -e /bin/bash -c "neofetch; exec /bin/bash"


UFW (Uncomplicated Fire Wall) was already installed in Lubuntu 20.10 but not enabled, so I enabled it:

user $ sudo enable ufw
user $ sudo ufw status verbose

I edited /etc/modules-load.d/modules.conf to add two firewall-related modules needed to enable Samba commands and wsdd (see further on) to function correctly:

# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

The desktop machine has a USB Bluetooth adapter so I installed Blueman as it had not been installed by the Lubuntu 20.10 Installer:

user $ sudo apt install blueman
user $ sudo apt install --reinstall bluez

See also my blog post The phone name assigned automatically by Android on my new phone prevented Bluetooth pairing and connecting in Linux.


All the machines in my home network use broadcast NetBIOS name resolution and SMB (v2 and v3, not v1) for file sharing, so I installed the packages shown below and copied the smb.conf from the previous installation, and edited the UFW configuration file as explained in an earlier blog post.

user $ sudo apt install samba
user $ sudo apt install cifs-utils
user $ sudo apt install nbtscan
user $ sudo apt install smbclient
user $ sudo cp /media/fitzcarraldo/FREECOM\ HDD/Lubuntu_home_folders_backup_LXDE/fitzcarraldo/Samba/smb.conf /etc/samba/smb.conf

See the following blog posts for details:

As my home network includes a NAS, I also configured the user accounts to be able to mount the NAS shared folder for Windows applications running under WINE (see How to enable a Windows application in WINE to access a Samba share on a NAS (continued)):


[Desktop Entry]
GenericName=Mount server1 user1 share
Comment=Mount server1 user1 share


mount_share () {
    echo "Enter your Linux account password below..."
    sudo ln -s /media/server1/user1 ~/$PREFIX/dosdevices/y:
    sudo mount.cifs //server1/user1/ -o user=user1,pass=<password of user1>,uid=$(id -u),gid=$(id -g) ~/$PREFIX/dosdevices/y:
echo "This will mount the Samba share folder user1 on the server1 machine."
echo "== Select which WINEPREFIX you wish to use =="
ls ~/.wine-* | grep .wine | awk -F'/' '{print NR " " substr($4, 1, length($4)-1)}'
NUMPREFIXES=$(ls ~/.wine-* | grep .wine | wc -l)
read -p "Enter number (q to abort) and press ENTER: " CHOICE
if [ "$CHOICE" != "q" ] && [ "$CHOICE" -gt 0 ] && [ "$CHOICE" -le $NUMPREFIXES ]; then
    PREFIX=$(ls ~/.wine-* | grep .wine | awk -F'/' '{print NR " " substr($4, 1, length($4)-1)}' | grep "$CHOICE " | awk -F' ' '{print $2}')
    if [ ! -e ~/$PREFIX/dosdevices/y: ]; then
        echo -n "~/$PREFIX/dosdevices/y: already exists. Is it OK to proceed anyway (y/n)? "
        read ANSWER
        if [ $ANSWER = "y" ]; then
            rm ~/$PREFIX/dosdevices/y:
if grep -q "/media/server1/user1" /proc/mounts; then
    echo "Samba share //server1/user1 is mounted for WINEPREFIX ~/$PREFIX ."
    echo "Samba share //server1/user1 is not mounted."
echo "You may now close this window."


[Desktop Entry]
GenericName=Unmount server1 user1 share
Comment=Unmount server1 user1 share


echo "This will unmount the Samba share folder user1 on the server1 machine."
echo "Enter your Linux account password below..."
sudo umount ~/.wine-*/dosdevices/y: 2>/dev/null
if grep -q "/media/server1/user1" /proc/mounts; then
  echo "Samba share //server1/user1 is mounted."
  echo "Samba share //server1/user1 is not mounted."
echo "You may now close this window."


As WS-Discovery is required to be able to browse SMB shares in File Explorer in Windows 10 installations these days, I also installed the WS-Discovery daemon. See an earlier blog post for details, including how to configure UFW: Using WS-Discovery to enable Windows 10 to browse SMB shares in my home network of Linux computers

user $ wget https://github.com/christgau/wsdd/archive/master.zip
user $ unzip master.zip
user $ sudo cp wsdd-master/src/wsdd.py /usr/bin/wsdd
user $ sudo cp wsdd-master/etc/systemd/wsdd.service /etc/systemd/system/

I added ‘--workgroup HOME‘ (the workgroup of all the machines in my home network) to /etc/systemd/system/wsdd.service and changed the group to ‘nogroup‘:

Description=Web Services Dynamic Discovery host daemon
; Start after the network has been configured
; It makes sense to have Samba running when wsdd starts, but is not required

ExecStart=/usr/bin/wsdd --shortlog --workgroup HOME
; Replace those with an unprivledged user/group that matches your environment,
; like nobody/nogroup or daemon:daemon or a dedicated user for wsdd
; The following lines can be used for a chroot execution of wsdd.
; Also append '--chroot /run/wsdd/chroot' to ExecStart to enable chrooting
;ExecStartPre=/usr/bin/install -d -o nobody -g nogroup -m 0700 /run/wsdd/chroot
;ExecStopPost=rmdir /run/wsdd/chroot


user $ sudo systemctl enable wsdd
user $ sudo systemctl start wsdd

I also installed a script to list WS-Discovery devices on my home network (see A Linux command-line utility to discover and list WSD-enabled computers and printers on a home network). I first copied the directory /media/fitzcarraldo/FREECOM HDD/Lubuntu_home_folders_backup_LXDE/fitzcarraldo/discover from the backup HDD to my new home directory, then I set up ~/discover/wsd-discover.sh:

user $ sudo apt install curl # curl is needed in wsd-discover.sh

As one of the awk commands in ~/discover/wsd-discover.sh would not work in Lubuntu 20.10 I changed the line:

cat /tmp/wsd-probe6.txt | awk -F "******" '{print $1 $3}' > /tmp/wsd-probe7.txt


cat /tmp/wsd-probe6.txt | awk -F "\*\*\*\*\*\*" '{print $1 $3}' > /tmp/wsd-probe7.txt

The Desktop Configuration File (a.k.a. ‘Launcher’ in LXQt) ~/Desktop/Discover_WSD_devices.desktop contains the following:

[Desktop Entry]
GenericName=Discover WSD devices
Comment=Discover WSD devices

I right-clicked on the Desktop and used ‘Create Launcher’ to create the above file. I edited it to change the icon, and ticked ‘Trust this executable’ if not ticked.


I installed WINE:

user $ sudo apt install wine

Then I copied across all my WINE prefix directories from the backup HDD and reconfigured them. For example, for MyPhoneExplorer:

user $ cd
user $ cp -r /media/fitzcarraldo/FREECOM\ HDD/Lubuntu_home_folders_backup_LXDE/fitzcarraldo/.wine-myphoneexplorer .
user $ export WINEPREFIX=~/.wine-myphoneexplorer
user $ winecfg
user $ cd ~/.wine-myphoneexplorer/drive_c/
user $ wine MyPhoneExplorer_Setup_v1.8.15.exe

Installing the Windows application creates a Desktop Configuration File on the Desktop. For example, the file ~/Desktop/MyPhoneExplorer.desktop contains:

[Desktop Entry]
Exec=env WINEPREFIX="/home/fitzcarraldo/.wine-myphoneexplorer" wine-stable C:\\\\windows\\\\command\\\\start.exe /Unix /home/fitzcarraldo/.wine-myphoneexplorer/dosdevices/c:/users/Public/Desktop/MyPhoneExplorer.lnk
Path=/home/fitzcarraldo/.wine-myphoneexplorer/dosdevices/c:/users/Public/Start Menu/Programs/MyPhoneExplorer

user $ chmod 664 ~/Desktop/MyPhoneExplorer.desktop
user $ ls -la ~/Desktop/MyPhoneExplorer.desktop
-rw-rw-r-- 1 fitzcarraldo fitzcarraldo 436 Jan  2 02:54 /home/fitzcarraldo/Desktop/MyPhoneExplorer.desktop


As I use ownCloud on a server, I installed the ownCloud client (instructions are available on the ownCloud Web site):

user $ wget -nv https://download.owncloud.com/desktop/ownCloud/stable/latest/linux/Ubuntu_20.10/Release.key -O - | sudo apt-key add -
user $ echo 'deb https://download.owncloud.com/desktop/ownCloud/stable/latest/linux/Ubuntu_20.10/ /' | sudo tee -a /etc/apt/sources.list.d/owncloud.list
user $ sudo apt update
user $ sudo apt install owncloud-client

In order to be able to browse my ownCloud folder using WebDAV I installed davfs2:

user $ sudo apt install davfs2
user $ mkdir /home/fitzcarraldo/webdav

I added the following line in ~/.davfs2/secrets:

https://bsfitzgerald.ddns.net/owncloud/remote.php/webdav bsf <password for my account on my server>

I uncommented the following two lines in /etc/davfs2/davfs2.conf:

dav_user        davfs2            # system wide config file only
dav_group       davfs2            # system wide config file only

I added the following line to /etc/fstab:

https://bsfitzgerald.ddns.net/owncloud/remote.php/webdav /home/fitzcarraldo/webdav davfs noauto,user,rw 0 0

See also the following articles regarding configuring Ubuntu for WebDAV browsing:

I created the following Desktop Configuration Files to enable me to mount and unmount the WebDAV-shared folder by double-clicking on Desktop icons:


[Desktop Entry]
GenericName=Mount server1 WebDAV share
Comment=Mount server1 WebDAV share
Exec=mount /home/fitzcarraldo/webdav


[Desktop Entry]
GenericName=Unmount server1 WebDAV share
Comment=Unmount server1 WebDAV share
Exec=fusermount -u /home/fitzcarraldo/webdav

Prevent suspending to RAM

I configured each user’s LXQt Power Management settings so none of the users’ accounts would suspend to RAM automatically. I may change this in future so I installed a script to enable me to prevent the installation suspending if desired (see How to move a mouse pointer automatically in Linux to simulate user activity):

user $ sudo apt install xdotool # My script to keep the mouse pointer moving automatically (when I run it) uses this.

I right-clicked on the Desktop and selected ‘Create Launcher’ to create the file ~/Desktop/Keep_mouse_moving.desktop below (and edited it to change the icon, and ticked ‘Trust this executable’):

[Desktop Entry]
GenericName=Keep mouse moving automatically
Comment=Keep mouse moving automatically
Exec=xterm -iconic -e "bash -c /home/fitzcarraldo/.keep_mouse_moving.sh"

I created the script ~/.keep_mouse_moving.sh containing the following, which I can launch by double-clicking on the desktop icon when I wish:

# Script to keep mouse pointer moving so that, for example, Suspend to RAM timeout does not occur.
# The mouse pointer will move around its current position on the screen, i.e. around any position
# on the screen where you place the pointer. However, if you prefer it to move around the centre
# of the screen then change mousemove_relative to mousemove in the xdotool command below.
# Set LENGTH to 0 if you do not want the mouse pointer to move.
# Set LENGTH to 1 if you want the mouse pointer to move just a tiny fraction.
# Set LENGTH to e.g. 100 if you want to see more easily the mouse pointer move.
# Set DELAY to the desired number of seconds between each move of the mouse pointer.
while true
#    if [[ `cat /proc/asound/card*/pcm*/sub*/status | grep RUNNING | wc -l` -ne 0 ]]; then
        for ANGLE in 0 90 180 270
            xdotool mousemove_relative --polar $ANGLE $LENGTH
            sleep $DELAY
#    fi

Automated backup of users’ home directories

I set up the same backup method that I implemented in the earlier Lubuntu installations (see Backing up users’ home directories in a Linux installation that uses systemd):


Description=Backup home directories of all users to USB HDD
Before=shutdown.target halt.target


WantedBy=halt.target shutdown.target



# This script backs up to an external USB HDD (NTFS) labelled "FREECOM HDD" the contents of the home directories
# of the users of this Lubuntu 20.10 installation if the system is shutting down but not rebooting.
# It is launched by a systemd service /etc/systemd/system/backup-to-usb-hdd.service.

# Find out if the system is rebooting (as opposed to being shut down):
REBOOT=$( systemctl list-jobs | egrep -q 'reboot.target.*start' && echo "rebooting" || echo "not_rebooting" )
if [ $REBOOT = "not_rebooting" ]; then
# Only execute the following steps if the system is shutting down but not rebooting:
   # Clean up if the backup did not complete last time:
    umount /media/usbhdd 2>/dev/null # Make sure you enter this line correctly.
    rm -rf /media/usbhdd/* # Make sure you enter this line correctly.
    # Unmount the external USB HDD if mounted by udisks2 with the logged-in username in the path:
    umount /media/*/FREECOM\ HDD 2>/dev/null
    # Find out the USB HDD device:
    DEVICE=$( blkid | grep "FREECOM\ HDD" | cut -d ":" -f1 )
    # Create a suitable mount point if it does not already exist, and mount the device on it:
    mkdir /media/usbhdd 2>/dev/null
    mount -t ntfs-3g -o async,noexec,nodev,noatime,nodiratime $DEVICE /media/usbhdd 2>/dev/null
    # Create the backup directory on the USB HDD if it does not already exist:
    mkdir /media/usbhdd/Lubuntu_home_folders_backup 2>/dev/null
    # Backup recursively all the home directories of all the users, and add a time-stamped summary to the log file:
    echo "********** Backing up Acer Aspire XC600 users' home directories **********" >> /home/fitzcarraldo/backup.log
    date >> /home/fitzcarraldo/backup.log
    # Log username of user shutting down the PC (may not be this user if Switch User was used):
    echo -ne "User who shutdown PC (may not be this user if Switch User has been used): " >> /home/fitzcarraldo/backup.log
    last | cut -d " " -f1 | head -1 >> /home/fitzcarraldo/backup.log
    sleep 2s
    # cp --recursive --update --preserve=all --no-dereference --force /home/ /media/usbhdd/Lubuntu_home_folders_backup 2>> /home/fitzcarraldo/backup.log
    rsync --ignore-errors --recursive --times --perms --links --protect-args --exclude '/*/.cache/mozilla' --exclude '/*/.cache/google-chrome' --exclude '/*/.cache/chromium' --delete-excluded --bwlimit=22500 /home/ /media/usbhdd/Lubuntu_home_folders_backup 2>> /home/fitzcarraldo/backup.log
    echo "Copying completed" >> /home/fitzcarraldo/backup.log
    date >> /home/fitzcarraldo/backup.log
    echo "********** Backup completed **********" >> /home/fitzcarraldo/backup.log
    cp /home/fitzcarraldo/backup.log /media/usbhdd/Lubuntu_home_folders_backup/fitzcarraldo/
    # Unmount the USB HDD so that udisks2 can subsequently re-mount it with the user's username in the path:
    umount /media/usbhdd
exit 0

user $ sudo systemctl enable backup-to-usb-hdd
user $ sudo systemctl start backup-to-usb-hdd

Keyboard layouts

As I want to be able to switch between English, Brazilian Portuguese and Spanish keyboard layouts, I did the following:

I added the following lines to the file /usr/share/sddm/scripts/Xsetup:

#Make sure the keyboards I use are selectable on the SDDM greeter screen
setxkbmap gb,us,br,es

I edited the file /etc/X11/xorg.conf.d/00-keyboard.conf so that it contains the following:

# Read and parsed by systemd-localed. It's probably wise not to edit this file
# manually too freely.
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "gb,us,br,es"
        Option "XkbModel" "pc105"
        Option "XkbOptions" "grp:alt_shift_toggle"

I right-clicked on the Panel for each user, selected ‘Manage Widgets’ and added the ‘Keyboard state indicator’ to the Panel.


The resulting Lubuntu 20.10 installation is working fine so far. It has a more contemporary look than the LXDE Desktop in Lubuntu 18.04. My family is already using it and, so far, there have been no adverse comments or problems.

The phone name assigned automatically by Android on my new phone prevented Bluetooth pairing and connecting in Linux

I recently installed Lubuntu 20.10 on a desktop machine, but Bluetooth did not work with my new phone (Samsung Galaxy Note 20 Ultra with Android 11). Bluetooth had worked fine in Lubuntu 18.04 on the same desktop machine with my previous Android phone (Samsung Galaxy Note 8 with Android 9).

The first thing I discovered was that, although the Lubuntu 20.10 Installer had installed Bluez, it had not installed a Bluetooth manager, so I installed Blueman:

$ sudo apt install blueman

Then, I re-installed Bluez just to be sure:

$ sudo apt install --reinstall bluez

The Bluetooth device was detected but Lubuntu 20.10 would not pair with my new phone.

The Bluetooth device was definitely unblocked:

$ rfkill --output-all
 1 wlan      phy0   Wireless LAN unblocked unblocked
 2 bluetooth hci0   Bluetooth    unblocked unblocked

Now, the phone name Android 11 had assigned automatically to my new phone was Fitzcarraldo’s Galaxy Note20 Ultra 5G. After trying many things, I began to wonder if the apostrophe in the phone name was causing the problem, so I changed the name in the phone (Settings > About phone > Edit) to Fitzcarraldo Galaxy Note20 Ultra 5G. Blueman/Bluez were then able to pair with, and connect to, the phone. Problem solved, but what a silly cause.

Deleted e-mails in an Office 365 Outlook account keep reappearing in the Thunderbird e-mail client

Whatever OS and e-mail client you use, if you search the Web you’ll find plenty of posts about deleted e-mails that reappear after you empty the ‘Trash’/’Deleted Items’/’Recycle bin’ folder. This problem seems to occur mostly with e-mail accounts that use the IMAP (Internet Message Access Protocol) or the Microsoft EWS (Exchange Web Services) protocols.

The obvious thing to check first in the e-mail client is if it has been configured to actually delete the e-mails on the server when you empty the ‘Deleted Items’ folder. Furthermore, internal files called ‘folder index files’ (.msf) in Thunderbird can sometimes become damaged, and these damaged files can also result in deleted e-mails reappearing. There is a ‘Repair Folder’ option in Thunderbird that sometimes fixes this problem. If that does not work, deleting the relevant folder’s .msf file and allowing Thunderbird to rebuild it sometimes fixes the problem. Anyway, I tried all the suggested approaches and more, as well as completely removing the account in Thunderbird (including ticking ‘Remove message data’ and manually deleting any remaining files for that account that remained in the Thunderbird directory). But nothing worked. However, I eventually cracked the problem as explained below.

Let’s just recap my situation:

  1. Of the many e-mails in a corporate Office 365 account that I had deleted over the last few months and emptied from the account’s ‘Deleted Items’ folder, five of them would keep reappearing in that account’s ‘Deleted Items’ folder in Thunderbird. This happened if I deleted the e-mails individually from the ‘Deleted Items’ folder and if I right-clicked on the folder and selected ‘Empty Deleted’.
  2. Whenever I logged in to the Office 365 Outlook account via a Web browser, the ‘Deleted Items’ folder was empty and it showed ‘Recover items deleted from this folder (0 items)’, i.e. no deleted messages existed.
  3. The Samsung e-mail client on my Samsung Galaxy Note 8 mobile phone showed the ‘Recycle bin’ for the same account was empty.

All the settings for the account in Thunderbird were correct. Completely removing the account from Thunderbird then adding the account again did not solve the problem, meaning that the problem could not be due to Thunderbird or the ExQuilla add-on Thunderbird uses to enable it to access the Office 365 Outlook account using Microsoft EWS. Even though my Samsung mobile phone’s e-mail client showed the Office 365 Outlook account’s ‘Recycle bin’ was empty, I selected ‘Email settings’ in the Samsung e-mail client, selected the account, scrolled down to ‘Empty Recycle bin’ and tapped it. The following message was displayed:

Empty Recycle bin?

This will permanently delete the items in the Recycle bin.

Cancel            Delete

I tapped ‘Delete’ and the Samsung e-mail client displayed ‘Success’. The five rogue e-mails then disappeared from the ‘Deleted Items’ folder in Thunderbird. The next time I logged in to the Office 365 Outlook account via a Web browser, the ‘Deleted Items’ folder was still empty but it displayed ‘Recover items deleted from this folder (5 items)’. I used the usual Office 365 Outlook procedure to recover the five e-mails and delete them permanently, resulting in ‘Recover items deleted from this folder (0 items)’ being displayed again in Office 365 Outlook in the browser window.

So, there you have it, the problem had nothing to do with Thunderbird or ExQuilla. If you access an Office 365 Outlook e-mail account via an e-mail client on a desktop or laptop and also via an e-mail client on a mobile phone, and you find that e-mails you deleted and emptied from the ‘Deleted Items’/’Trash’/’Recycle bin’ folder in the e-mail client on the desktop/laptop keep reappearing in that folder, try deleting them on all your devices, including your phone, even if the e-mails are not shown in the Office 365 Outlook account in a Web browser nor in the Office 365 Outlook account in a phone’s e-mail client.

Work-around in Linux to switch between single-sided and double-sided printing

I use Gentoo Linux on my laptop, and have drivers installed for quite a few printer manufacturers and models, as I work in multiple offices and they have a wide range of printers and MFPs. To date I have had no trouble printing single-sided (‘simplex’) and double-sided (‘duplex’) documents on the printers that support duplex printing. However, one of the offices I have been working in recently has a Konica Minolta bizhub C368, a floor-standing MFP, and the printer in this MFP did not enable me to switch between single-sided and double-sided printing even though Windows users in the same office could. This article explains how I managed to switch between the two printing modes.

A Linux driver for the bizhub C368 can be downloaded from the Konica Minolta Download Centre. I downloaded the tarball KMbeuUXv1_22_multi_language.tar.gz, extracted the contents to the directory ~/KMbeuUXv1_22_multi_language/ and followed the instructions in ‘BEU Linux CUPS Driver Guide.pdf‘:

user $ cd ~/KMbeuUXv1_22_multi_language
user $ su
root # ./install.pl
root # rc-service cupsd restart

I then used the CUPS Administration page in a browser window to set up the printer.

As I wanted the printer to be the default printer while I was working in that office, I edited the system-wide and user-specific lpoptions files to contain the printer name I had specified to CUPS when setting up the printer:

user $ cat ~/.cups/lpoptions
Default Konica_Minolta_bizhub_C368
root # cat /etc/cups/lpoptions
Default Konica_Minolta_bizhub_C368

I was then able to print from all the usual applications, except that the applications could only select single-sided printing, even though the printer supports double-sided printing and Windows users in the office could print double-sided. I could not find a setting for this in the CUPS Manager’s ‘Set Default Options’ page for the printer, so I edited the PPD file to change the relevant default option:

root # nano /etc/cups/ppd/Konica_Minolta_bizhub_C368.ppd

I changed the default printing option from:

*DefaultKMDuplex: 1Sided


*DefaultKMDuplex: 2Sided

Then I could print double-sided pages, but selecting ‘single-sided’ in applications would still print double-sided. Now, I don’t know if there is a proper fix for this, but I could not find out how to do it. Therefore I opted for a work-around which is fine for my purposes. Here is what I did…

I created the shell script ~/Konica_Minolta_bizhub_C368.sh containing the following:

echo "Konica Minolta bizhub C368 printer"
echo "Select single-sided or double-sided printing as the default"
# Get the password entry over and done with now
echo "Enter your user account password."
sudo ls > /dev/null
while [[ $CHOICE != "X" && $CHOICE != "x" ]]; do
    if [[ $CHOICE != "X" && $CHOICE != "x" ]]; then
        echo -n "[1]-sided, [2]-sided or e[X]it : "
        read -n1 CHOICE
    case $CHOICE in
        [1] ) sudo cp /home/fitzcarraldo/Konica_Minolta_bizhub_C368/Konica_Minolta_bizhub_C368.ppd.single-sided /etc/cups/ppd/Konica_Minolta_bizhub_C368.ppd
              echo "Single-sided printing has been selected"
        [2] ) sudo cp /home/fitzcarraldo/Konica_Minolta_bizhub_C368/Konica_Minolta_bizhub_C368.ppd.double-sided /etc/cups/ppd/Konica_Minolta_bizhub_C368.ppd
              echo "Double-sided printing has been selected"
        [Xx] ) echo; exit;;
        * ) echo; echo " Enter '1', '2' or 'X/x'"

I created the Desktop Configuration File ~/Desktop/Konica_Minolta_bizhub_C368.desktop containing the following:

[Desktop Entry]
Comment[en_GB]=Select single-sided or double-sided printing for Konica Minolta bizhub C368
Comment=Select single-sided or double-sided printing for Konica Minolta bizhub C368
Exec=konsole -e sh /home/fitzcarraldo/Konica_Minolta_bizhub_C368.sh
GenericName[en_GB]=Select printing sides for KM bizhub C368
GenericName=Select printing sides for KM bizhub C368

I downloaded a Konica Minolta logo from the Web and used it for the icon for the Desktop Configuration File.

And finally I copied the PPD file to two files and edited them:


which includes *DefaultKMDuplex: 1Sided


which includes *DefaultKMDuplex: 2Sided

Now, if I want to switch between single-sided and double-sided printing I just double-click on the icon on my Desktop and a terminal window pops-up allowing me to select the new default:

Konica Minolta bizhub C368 printer

Select single-sided or double-sided printing as the default

Enter your user account password.

[1]-sided, [2]-sided or e[X]it :

Why does Thunderbird add ‘\A0’ and other strange-looking strings in e-mails I send?

I use Linux and have used the Thunderbird e-mail client since 2008. I used to use DavMail to enable Thunderbird to access various company Microsoft Exchange WebMail accounts but, several years ago, DavMail would no longer work with a particular Microsoft Exchange account so I switched to the Thunderbird add-on ExQuilla, for which I pay an annual licence fee. I do not know if the more recent versions of DavMail would work with this particular account but ExQuilla got me out of a hole so I stuck with it. Recently this particular corporation decided to stop using an in-house Microsoft Exchange server and switched to Microsoft 365.

Recently people receiving my e-mails sent using this particular account told me there were strange strings of characters in e-mails of mine that quote other e-mails. The most frequent occurrence is the three-character string ‘\A0’, although other strings are sometimes present too. The following e-mail extract illustrates the effect:

Hi Claudia,

I have had a look at your draft and agree with your assessment. Let’s sit down together and prepare a list of possible remedial measures.


On 07/10/2020 13:02, Claudia wrote:
> Hi,
> \A0
> Could you please have a look at the draft I have attached.
> \A0
> There are several main issues requiring attention. The operation was basically run by one person \2013 (John) during the tests, which led to several issues.
> \A0
> He does not have the time to do everything by himself.\A0 The other staff who had assisted him during earlier tests were not present.

Notice various occurrences of ‘\A0’ and an occurrence of ‘\2013’.

I searched the Web to see if other Thunderbird users had come across this problem, and found several reports of similar problems, although not identical. The most promising page I found was in the Mozilla support forums for Thunderbird: Why do my sent messages magically add “�” at the end of my sentences?. However, none of the various fixes suggested in that thread worked in my case. My Thunderbird installation was configured to use ‘Unicode (UTF-8)’ text encoding for Outgoing Mail and Western (ISO-8859-1) for Incoming Mail ( ‘Edit’ > ‘Preferences’ > ‘General’ > ‘Language & Appearance’ > ‘Advanced…’ > ‘Text Encoding’). I changed the text encoding for incoming mail to ‘Unicode (UTF-8)’ but that made no difference. I ticked ‘When possible, use the default text encoding in replies’ but that also made no difference. Anyway, I left the settings like that and hoped an update to Thunderbird would fix the issue.

I was not sure if the problem started with an upgrade to Thunderbird, or whether the switch to Microsoft 365 was the cause. I suspect Microsoft 365 is the culprit because the problem does not occur when I use other e-mail accounts. Anyway, it is annoying and I have still not found a fix for it. One of the replies in the above-mentioned Thunderbird support thread is not identical to what I’m seeing, but it looks to be essentially the same problem:

Jorg K
2/4/18, 6:17 AM

There is NO bug in Thunderbird. Sadly some US ISP’s like AT&T and Bellsouth have started *corrupting* their customers’ e-mail.

If the customer sends in windows-1252 and includes for example special punctuation characters or a non-break space xA0, the ISP doesn’t correctly interpret the the message as windows-1252 but as UTF-8. In UTF-8, xA0 is not valid and gets replaced by the so-called replacement character, � (0xEF 0xBF 0xBD).

Since the e-mail is still windows-1252 encoded, the recipient’s client displays �.


Affected users should complain heavily to their mail providers. As a workaround, they need to send all messages as UTF-8.

This seems to be a possible explanation of what I am experiencing, but it is impractical for me to check what text encoding all my contacts are using, or get them to switch to UTF-8 if they are not already using it in their e-mails. I noticed that there is actually a space in what look like blank lines in the e-mails I quote, and, if I delete that space, the ‘\A0’ no longer appears on those lines when I view the contents of e-mails in the Sent Items mailbox. I think that the space is, in fact, a non-breaking space (xA0), which is apparently invalid in UTF-8 and gets displayed as ‘\A0’ by Thunderbird (I’m currently using Version 78.4.2).

Trying to find and delete all the non-breaking spaces and other non-UTF-8 characters in a quoted e-mail is impractical. However, I found a somewhat cumbersome work-around to the problem of non-breaking spaces (and, I think, other non UTF-8 characters). When I click on the ‘Reply’ button in Thunderbird and a window pops up for me to compose my reply which includes a quoted e-mail or e-mails, I use Ctrl-C to copy all the contents of the window, then Ctrl-V to paste it back into the window. This seems to get rid of the character strings representing non-UTF-8 characters. It does add some extra blank lines in the quoted e-mail(s) in the window in which I am composing my e-mail, but those extra blank lines are normally not present when viewing the e-mail after it has been sent.

This work-around is not ideal as it relies on me remembering to do it when composing an e-mail in which I am quoting a previous e-mail or e-mails. But at least it gets rid of the multiple additional occurrences of ‘\A0’ (non-breaking space). It’s a pity there is no mechanism in Thunderbird to filter out non-UTF-8 characters such as a non-breaking space when quoting other e-mails. Even if Jorg K in the above-mentioned thread is correct and the cause of the problem does not lie in Thunderbird, I would rather Thunderbird act differently if the user has configured it to send e-mails using UTF-8 text encoding, and filter out non-UTF-8 characters rather than including strings of gobbledygook in the e-mail.

Migrating to libglvnd in Gentoo Linux on a laptop with NVIDIA Optimus

In a 2015 post I described how I configured my Gentoo Linux installation to switch between the closed-source NVIDIA driver and the open-source Intel driver on a Clevo W230SS laptop that has NVIDIA Optimus hardware (NVIDIA GeForce GTX 860M GPU plus Intel HD 4600 IGP). I did not want to use Bumblebee, preferring to use only the NVIDIA driver or only the Intel driver, switching between them by running a Bash script then logging out of KDE Plasma and back in again. Basically, the scheme a) swapped the xorg.conf file depending on which driver I wanted to use, and b) used the eselect opengl command to select the applicable OpenGL library. The latest versions of the files in my scheme are listed below if you’re interested (I use LightDM instead of KDM these days, as KDM is no more), otherwise just skip to the section after, titled ‘Migrating to libglvnd’.

Previous scheme using eselect opengl


[Desktop Entry]
Comment[en_GB]=Run a script to configure your installation to use the NVIDIA GeForce GTX 860M GPU when you restart X Windows
Comment=Run a script to configure your installation to use the NVIDIA GeForce GTX 860M GPU when you restart X Windows
Exec=konsole -e sh /home/fitzcarraldo/nvidia.sh
GenericName[en_GB]=Configure your installation to use the NVIDIA GeForce GTX 860M GPU
GenericName=Configure your installation to use the NVIDIA GeForce GTX 860M GPU


echo "Your installation is currently configured to use the following graphics processor:"
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "nvidia" ]; then
  echo "NVIDIA GeForce GTX 860M"
  echo "You do not need to do anything. Please close this window."
elif [ "$GPU" = "xorg-x11" ]; then
  echo "Intel HD 4600 Integrated Graphics Processor"
  echo "This script will configure your installation to use the NVIDIA GeForce GTX 860M GPU all the time."
  echo "Enter your own password."
  sudo eselect opengl set nvidia
# See separate configuration of LightDM for NVIDIA GPU and Intel HD Graphics.
  sudo cp /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
  echo "Now you should logout to restart X Windows."
echo -n "Press ENTER to end: "


Section "ServerLayout"
    Identifier     "Layout0"
    Screen      1  "nvidia" 0 0
    Inactive       "intel"

Section "Monitor"
    Identifier     "Monitor0"
    Option         "DPMS"
    Option         "DPI" "96 x 96"

Section "Device"
    Identifier     "nvidia"
    Driver         "nvidia"
    BusID          "PCI:1:0:0"

Section "Device"
    Identifier     "intel"
    Driver         "modesetting"
    BusID          "PCI:0:2:0"

Section "Screen"
    Identifier     "nvidia"
    Device         "nvidia"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "UseDisplayDevice" "none"
    SubSection     "Display"
        Depth       24
        Virtual     1920 1080

Section "Screen"
    Identifier     "intel"
    Device         "intel"
    Monitor        "Monitor0"


[Desktop Entry]
Comment[en_GB]=Run a script to configure your installation to use Intel Integrated Graphics when you restart X Windows
Comment=Run a script to configure your installation to use Intel Integrated Graphics when you restart X Windows
Exec=konsole -e sh /home/fitzcarraldo/intel.sh
GenericName[en_GB]=Configure your installation to use Intel HD Graphics
GenericName=Configure your installation to use Intel HD Graphics
Name[en_GB]=Intel HD Graphics
Name=Intel HD Graphics


echo "Your installation is currently configured to use the following graphics processor:"
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "xorg-x11" ]; then
  echo "Intel HD 4600 Integrated Graphics Processor"
  echo "You do not need to do anything. Please close this window."
elif [ "$GPU" = "nvidia" ]; then
  echo "NVIDIA GeForce GTX 860M"
  echo "This script will configure your installation to use the"
  echo "Intel HD 4600 Integrated Graphics Controller all the time."
  echo "Enter your own password."
  sudo eselect opengl set xorg-x11
# See separate configuration of LightDM for Intel HD Graphics and NVIDIA GPU.
  sudo cp /etc/X11/xorg.conf.intel /etc/X11/xorg.conf
  echo "Now you should logout to restart X Windows."
echo -n "Press ENTER to end: "


Section "Device" 
   Identifier  "Intel Graphics" 
   Driver      "intel" 
   Option      "AccelMethod" "sna" 
   Option      "TearFree" "true" 


Section "Files"
        ModulePath "/usr/lib/xorg/modules"
        ModulePath "/usr/lib64/xorg/modules"

/etc/X11/Sessions/plasma (used by LightDM)

# Make sure the following is in /etc/lightdm/lightdm.conf
# display-setup-script=/etc/X11/Sessions/plasma
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "nvidia" ]; then
    xrandr --setprovideroutputsource modesetting NVIDIA-0
    xrandr --auto

Migrating to libglvnd

Well, the above scheme worked fine… until the recent decision by the Gentoo Linux developers to drop the app-eselect/eselect-opengl ebuild and switch the x11-base/xorg-server, media-libs/mesa and x11-drivers/nvidia-drivers to using the libglvnd library:

This package is masked and could be removed soon!
The mask comment indicates that this package is scheduled for removal from our package repository.
Please review the mask information below for more details.

Replaced by media-libs/libglvnd. Masked for removal in 30 days. Bug #728286

Affected packages	app-eselect/eselect-opengl

Author/Date		Matt Turner  (2020-08-11 00:00:00 +0000 UTC)

Without the eselect opengl command, my scripts were scuppered. So I decided to bite the bullet and switch to using libglvnd. It turned out not to be difficult, and I took the following steps to migrate:

  1. Deleted the file /etc/X11/xorg.conf
  2. Created the file /etc/X11/xorg.conf.d/01-nvidia-offload.conf containing the following:
    Section "ServerLayout"
        Identifier "layout"
        Option "AllowNVIDIAGPUScreens"
  3. Performed the usual ‘emerge -uvDN @world‘ to update and upgrade the relevant packages, which automatically unmerged app-eselect/eselect-opengl

If I had run into trouble with the installed app-eselect/eselect-opengl blocking the upgrade, I could have worked around that by doing the following:

root # emerge -C eselect-opengl
root # emerge -1v nvidia-drivers mesa xorg-server xorg-drivers

I removed all references to the libglvnd USE flag from /etc/portage/make.conf, and the only place libglvnd is declared explicitly now is in the file /etc/portage/package.use/world because I have a multilib installation:

root # grep libglvnd /etc/portage/package.*/*
/etc/portage/package.use/world:>=media-libs/libglvnd-1.3.1 abi_x86_32

The status of the applicable packages in my installation is now as follows:

root # eix -I nvidia-drivers
[I] x11-drivers/nvidia-drivers
     Available versions:  [M]340.108-r1(0/340)^mtd ~390.132-r4(0/390)^mtd 390.138-r1(0/390)^mtd 435.21-r6(0/435)^mtd 440.100-r2(0/440)^mtd 450.57-r1(0/450)^mtd {+X compat (+)driver gtk3 +kms +libglvnd multilib static-libs +tools uvm wayland ABI_MIPS="n32 n64 o32" ABI_RISCV="lp64 lp64d" ABI_S390="32 64" ABI_X86="32 64 x32" KERNEL="FreeBSD linux"}
     Installed versions:  450.57-r1(0/450)^mtd(22:04:56 14/08/20)(X driver kms libglvnd multilib tools wayland -compat -gtk3 -static-libs -uvm ABI_MIPS="-n32 -n64 -o32" ABI_RISCV="-lp64 -lp64d" ABI_S390="-32 -64" ABI_X86="32 64 -x32" KERNEL="linux -FreeBSD")
     Homepage:            https://www.nvidia.com/Download/Find.aspx
     Description:         NVIDIA Accelerated Graphics Driver

root # eix -I mesa
[I] media-libs/mesa
     Available versions:  20.0.8^t ~20.1.4^t ~20.1.5^t ~20.2.0_rc1^t ~20.2.0_rc2^t **9999*l^t {+X +classic d3d9 debug +dri3 +egl +gallium +gbm gles1 +gles2 +libglvnd +llvm lm-sensors opencl osmesa selinux test unwind vaapi valgrind vdpau vulkan vulkan-overlay wayland xa xvmc zink +zstd ABI_MIPS="n32 n64 o32" ABI_RISCV="lp64 lp64d" ABI_S390="32 64" ABI_X86="32 64 x32" KERNEL="linux" VIDEO_CARDS="freedreno i915 i965 intel iris lima nouveau panfrost r100 r200 r300 r600 radeon radeonsi v3d vc4 virgl vivante vmware"}
     Installed versions:  20.0.8^t(22:03:42 14/08/20)(X classic dri3 egl gallium gbm gles2 libglvnd llvm wayland zstd -d3d9 -debug -gles1 -lm-sensors -opencl -osmesa -selinux -test -unwind -vaapi -valgrind -vdpau -vulkan -vulkan-overlay -xa -xvmc ABI_MIPS="-n32 -n64 -o32" ABI_RISCV="-lp64 -lp64d" ABI_S390="-32 -64" ABI_X86="32 64 -x32" KERNEL="linux" VIDEO_CARDS="i965 intel -freedreno -i915 -iris -lima -nouveau -panfrost -r100 -r200 -r300 -r600 -radeon -radeonsi -vc4 -virgl -vivante -vmware")
     Homepage:            https://www.mesa3d.org/ https://mesa.freedesktop.org/
     Description:         OpenGL-like graphic library for Linux

[I] x11-apps/mesa-progs
     Available versions:  8.4.0 **9999*l {egl gles2}
     Installed versions:  8.4.0(13:53:51 02/05/19)(-egl -gles2)
     Homepage:            https://www.mesa3d.org/ https://mesa.freedesktop.org/ https://gitlab.freedesktop.org/mesa/demos
     Description:         Mesa's OpenGL utility and demo programs (glxgears and glxinfo)

Found 2 matches
root # eix -I xorg-server
[I] x11-base/xorg-server
     Available versions:  1.20.8-r1(0/1.20.8) **9999(0/9999)*l {debug dmx doc +elogind ipv6 kdrive +libglvnd libressl minimal selinux static-libs suid systemd +udev unwind wayland xcsecurity xephyr xnest xorg xvfb}
     Installed versions:  1.20.8-r1(0/1.20.8)(22:07:21 14/08/20)(elogind ipv6 libglvnd udev wayland xorg -debug -dmx -doc -kdrive -libressl -minimal -selinux -static-libs -suid -systemd -unwind -xcsecurity -xephyr -xnest -xvfb)
     Homepage:            https://www.x.org/wiki/ https://gitlab.freedesktop.org/xorg/xserver/xorg-server
     Description:         X.Org X servers

root # eix -I xorg-drivers
[I] x11-base/xorg-drivers
     Available versions:  1.20-r2 **9999*l {INPUT_DEVICES="elographics evdev joystick libinput synaptics vmmouse void wacom" VIDEO_CARDS="amdgpu ast dummy fbdev freedreno geode glint i915 i965 intel mga nouveau nv nvidia omap qxl r128 radeon radeonsi siliconmotion tegra vc4 vesa via virtualbox vmware"}
     Installed versions:  1.20-r2(22:05:41 14/08/20)(INPUT_DEVICES="evdev synaptics -elographics -joystick -libinput -vmmouse -void -wacom" VIDEO_CARDS="i965 intel nvidia -amdgpu -ast -dummy -fbdev -freedreno -geode -glint -i915 -mga -nouveau -nv -omap -qxl -r128 -radeon -radeonsi -siliconmotion -tegra -vc4 -vesa -via -virtualbox -vmware")
     Homepage:            https://wiki.gentoo.org/wiki/No_homepage
     Description:         Meta package containing deps on all xorg drivers

I can now delete the line display-setup-script=/etc/X11/Sessions/plasma in /etc/lightdm/lightdm.conf, and delete the script /etc/X11/Sessions/plasma, as the script no longer works and the xrandr commands in it are no longer necessary in any case. The files and scripts Select_NVIDIA_GPU.desktop, nvidia.sh, xorg.conf.nvidia, Select_Intel_HD_Graphics.desktop, intel.sh and xorg.conf.intel are also redundant now and can be deleted.

After rebooting, the LightDM login screen appears as usual and I can login to the Desktop Environment. I can connect an external monitor to the laptop via either VGA cable or HDMI cable and both methods work, and I can switch between the laptop monitor and the external monitor using KDE Plasma’s ‘System Settings’ > ‘Display Configuration’, so everything appears to be working correctly.

The command xrandr --listproviders (add ‘--verbose‘ to provide more information) lists both the NVIDIA and Intel video devices, so I assume everything is working correctly:

user $ xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x47 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 4 outputs: 4 associated providers: 0 name:Intel
Provider 1: id: 0x203 cap: 0x0 crtcs: 0 outputs: 0 associated providers: 0 name:NVIDIA-G0

It appears that the default is to use the Intel IGP:

user $ glxinfo | grep -E 'OpenGL (vendor|renderer)'
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)
user $ __NV_PRIME_RENDER_OFFLOAD_PROVIDER=Intel __GLX_VENDOR_LIBRARY_NAME=mesa glxinfo  | grep -E 'OpenGL (vendor|renderer)'
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)

unless I use environment variables explicitly to specify that the NVIDIA GPU be used for a specific application:

user $ __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo  | grep -E 'OpenGL (vendor|renderer)'
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 860M/PCIe/SSE2

Performance seems reasonable:

27197 frames in 5.0 seconds = 5439.292 FPS
27332 frames in 5.0 seconds = 5466.274 FPS
27857 frames in 5.0 seconds = 5571.184 FPS
27553 frames in 5.0 seconds = 5510.447 FPS
27128 frames in 5.0 seconds = 5425.556 FPS

To run a program such as LibreCAD using the NVIDIA GPU I can do the following:


I need to play around more to understand how to use nvidia-drivers and libglvnd with the NVIDIA Optimus hardware in this laptop, but at least I have managed to migrate from app-eselect/eselect-opengl to media-libs/libglvnd before the former is dropped from the Portage tree in the near future.

That UPS you bought for your home server may not be as useful as you think

Some years ago I decided to install a server at home for use as a NAS (network-attached storage) in my home network, and for an Internet-facing server. I live in a place where blackouts are very infrequent (perhaps a couple per year), but occasionally the mains drops out for only a second or two. I suspect these very short dropouts occur when substation switchgear operates, but have no way of being sure. Anyway, with a server running 24/7 I obviously wanted protection against any loss of the mains supply.

I ended up buying a 700VA APC Back-UPS ES-BE700G-UK, which has four mains sockets that are battery-backed and also have surge protection, plus another four mains sockets that have surge protection but are not battery-backed. Additionally, it has two RJ45 sockets to provide pass-through filtering for an Ethernet connection. It also has a USB port for connection to the server so that it can transmit unsolicited status information to the server (including requesting the server to shutdown) and can also be interrogated by the server using the apcaccess command. The APC UPS daemon works with this model of UPS, and was relatively easy to set up. APC, formerly American Power Conversion Corporation, is a subsidiary of European company Schneider Electric. My UPS was manufactured in The Philippines.

I have three devices plugged into the battery-backed sockets on the APC UPS: the server, an external 6TB USB HDD connected to the server for automated daily backups by the server, and a 5-port Ethernet switch. The battery in the UPS would provide between 15 and 20 minutes of power when the mains fails, although I have configured the UPS to trigger the server to shutdown when 30 per cent of the battery power remains, as battery life is reduced considerably if its power is allowed to drain completely. In case you’re wondering why my router is not also plugged into the UPS, due to the position of the broadband provider’s socket the router is in a different room and I have therefore had to connect it to a different UPS, an iLEPO multi-functional DC UPS (the ECO PLUS 412P, which is tiny but can keep the router powered for several hours). Obviously the router needs to be connected to a UPS, otherwise the server would not be able to send me e-mails when there is a mains power cut. Being able to receive UPS status e-mails from the server is important to me when I am away from home on work trips.

So I thought I had covered all bases, and, indeed, the UPS proved useful on several occasions. I would quite often be on a work trip and receive an e-mail from the server informing me that mains power to the UPS had been lost, then another e-mail soon after informing me that mains power to the UPS had returned. Only once did the power cut last longer than the battery capacity, and the server was shutdown automatically.

Now, the life of the 12-volt lead-acid battery in the APC UPS is supposed to last approximately three to five years. The life will depend on how many times the battery is discharged and ambient temperature.

While I was away from home on a long work trip, suddenly I could no longer connect to my server and I had not received an e-mail from the server informing me of any problem. Luckily it was near the end of my trip so I was not too inconvenienced. When I arrived home I found that the UPS was sounding an alarm and was not supplying power to the server even though there was mains supply to the UPS. It transpired that the UPS battery had suddenly died without warning and could no longer hold a charge, and this had happened while there was mains supply to the UPS, i.e. there had not been a power cut while I was away. Fortunately there was no loss of data on the server; I was able to run fsck during boot-up.

This failure was annoying on two counts. Firstly, the battery was only about thirteen months old (the manufacturing date stamped on the UPS box was only two or three months before the date I purchased the UPS). Secondly, I certainly did not expect the UPS to stop supplying power to the server while there was mains supply to the UPS. The APC white paper on UPS topologies, ‘The Different Types of UPS Systems‘, does not make this behaviour clear.

It turns out that the type of UPS topology (‘Standby’ — see the model’s Technical Specifications) in this model of UPS does not continue to provide power to connected equipment when the UPS battery either fails or is disconnected for whatever reason when there is mains power supply to the UPS. A quick search of the Web showed me that I was not alone in discovering this ‘feature’: an APC Back-UPS 350 owner posted ‘UPS Battery Backup — useless when the battery dies?‘.

From what I have read, the so-called ‘Line Interactive’ UPS topology does not suffer this shortcoming, so, the next time I have to buy a UPS for a piece of equipment that requires power 24/7, I will buy a line-interactive UPS rather than a standby UPS. But, before purchasing, I will be sure to ask the manufacturer what the precise model would do if its battery fails or is disconnected while there is mains supply to the UPS. The APC line-interactive UPSs are more expensive than the APC Back-UPS models; now I know why. It’s a pity I was not aware of the shortcoming of the Back-UPS models, as I would have spent more and bought a UPS that continues to work when the battery dies while there is mains supply. I would also hope the UPS would issue an alarm if the battery has failed or is disconnected while there is mains supply. Be sure to ask the manufacturer all these questions if you cannot tolerate a sudden loss of power to your equipment if the battery dies while there is mains supply.

Anyway, after checking that the dead battery was indeed useless I replaced it with a new Yuasa battery that has lasted nearly three years now. I will be replacing it shortly as a precaution, even though it has not had to be used much at all since I installed it. I have not replaced the APC Back-UPS model but I will be replacing the battery at least every three years just to be cautious, and of course taking the old batteries to my local waste disposal centre to be recycled properly. By the way, it is possible to purchase a 12-volt battery manufactured by one of the reputable battery manufacturers such as Yuasa with the same specification as the APC battery, for a significantly lower price than APC charges for replacement batteries (which I suspect are badged by APC in any case).

Re-enabling OpenGL compositing automatically after it crashes KWin at login to KDE Plasma

One of my laptops has NVIDIA Optimus hardware and runs Gentoo Linux with the closed-source NVIDIA driver. Almost every time I logged-in to KDE Plasma for the first time after booting, OpenGL and compositing would be disabled (see screenshot below), and the usual methods of toggling compositing on/off would not work.

KDE Plasma - System Settings - Compositor Settings for Desktop Effects

KDE Plasma - System Settings - Compositor Settings for Desktop Effects.

I had to perform the following ritual in order to get ‘wobbly windows’ working again:

  1. select ‘System Settings’ > ‘Display and Monitor’ > ‘Compositor’
  2. click on ‘Re-enable OpenGL detection’
  3. deselect ‘Enable compositor on startup’
  4. click ‘Apply’
  5. select ‘Enable compositor on startup’
  6. click ‘Apply’

After having to perform this tedious process almost every time I logged in to KDE Plasma following boot-up, I finally decided to find an automated method of re-enabling OpenGL detection and compositing. I discovered that, when the problem occurred, the value of the variable OpenGLIsUnsafe in the file ~/.config/kwinrc had become ‘false‘. To get things working again I created the Bash script ~/restart_compositing.sh listed below. The script reverts the value of the variable OpenGLIsUnsafe to ‘true‘, reverts the value of the variable Enabled in the same section to ‘true‘ if it happens to be ‘false‘, and restarts KWin. Simple as that.

# OpenGL compositing usually crashes KWin when I login, and compositing is then disabled.
# I have to select 'System Settings' > 'Display and Monitor' > 'Compositor' and perform
# the following steps to get compositing to work in the session:
# 1. click 'Re-enable OpenGL detection'
# 2. deselect 'Enable compositor on startup'
# 3. click 'Apply'
# 4. select  'Enable compositor on startup'
# 5. click 'Apply
# This script enables me to avoid having to perform the above manual procedure.
# This script is configured to run automatically at Plasma Startup - see:
# 'System Settings' > 'Startup and Shutdown' > 'Autostart'
edit_kwinrc () {
                # Extract the [Compositing] section from kwinrc
                awk '/\[Compositing\]/,/^$/' $HOME/.config/kwinrc > /tmp/kwinrc-extract
                # Remove the header in the extracted section
                sed -i '/\[Compositing\]/d' /tmp/kwinrc-extract
                # Remove the empty line at the end of the extracted section
                sed -i '/^$/d' /tmp/kwinrc-extract
                # Change the state configured for next login
                if [ $1 == "disablecompositing" ]; then
                    sed -i 's/Enabled=true/Enabled=false/g' /tmp/kwinrc-extract
                elif [ $1 == "enablecompositing" ]; then
                    sed -i 's/Enabled=false/Enabled=true/g' /tmp/kwinrc-extract
                elif [ $1 == "openglunsafe" ]; then
                    sed -i 's/OpenGLIsUnsafe=false/OpenGLIsUnsafe=true/g' /tmp/kwinrc-extract
                elif [ $1 == "openglsafe" ]; then
                    sed -i 's/OpenGLIsUnsafe=true/OpenGLIsUnsafe=false/g' /tmp/kwinrc-extract
                # Replace the [Compositing] section in kwinrc
                awk 'BEGIN {p=1} /^\[Compositing\]/ {print;system("cat /tmp/kwinrc-extract");p=0} /^$/ {p=1} p' $HOME/.config/kwinrc > /tmp/kwinrc
                cp /tmp/kwinrc $HOME/.config/kwinrc
# Avoid backing up an incorrectly-edited file
if [ ! -f $HOME/.config/kwinrc.bak ]; then
    cp $HOME/.config/kwinrc $HOME/.config/kwinrc.bak
sleep 120s # This delay works for my specific laptop but might need to be adjusted on other machines.
if $( grep -q "OpenGLIsUnsafe=true" $HOME/.config/kwinrc ); then
    edit_kwinrc openglsafe
    edit_kwinrc enablecompositing # Just in case it was disabled as well.
    kwin_x11 --replace & > /dev/null 2>&1
exit 0

I then selected ‘System Settings’ > ‘Startup and Shutdown’ > ‘Autostart’, clicked on ‘Add Script…’ and specified that /home/fitzcarraldo/restart_compositing.sh has to be run at ‘Startup’ (of Plasma). Problem solved.

Updating the Powerline adapters in my home network

I have blogged previously about a couple of problems with using Powerline adapters in my home network:

As my NETGEAR XAV1301 (200 Mbps) Powerline adapters bought in 2012 apparently do not fully support IPv6, and as my NETGEAR XAV5221 (500 Mbps) adapters bought in 2016 are no longer manufactured either, I decided to invest in some new Powerline adapters that would guarantee IPv6 support. My Web searches did not confirm that the current models of NETGEAR Powerline adapters support IPv6, so I decided to try TP-Link Powerline adapters because the TP-Link Web site states that all current TP-Link Powerline adapters support IPv6. I wanted Powerline adapters for five devices (router, smart TV and three computers), plus the ability to use a mains plug on at least two of those (i.e. so-called ‘pass-through’ adapters). I also wanted to avoid buying different models, in order to minimise the possibility of any problems. TP-Link have a range of 600 Mbps adapters under the name ‘AV600’, so I plumped for two TP-PL4010 adapters (single Ethernet port per adapter), one TP-PL4010P adapter (single Ethernet port and one mains pass-through socket) and one TP-PL4020P (two Ethernet ports and one mains pass-through socket). These all use the Qualcomm Atheros QCA7420 Powerline chipset (which happens to be the same chipset used in my old NETGEAR XAV5221 500 Mbps adapters).

Like NETGEAR, TP-Link does not have a Powerline utility program for Linux, so I had to install TP-Link’s tpPLC utility program in Windows 10 running in a VM (virtual machine) in order to configure the four TP-Link adapters and set the ‘Powerline network name’ to avoid crosstalk with my neighbour’s Powerline adapters that use the factory default network name (‘HomePlugAV’).

Anyway, I got everything set up and working, but soon noticed that there were quite frequent dropouts of the connection to my router and the Internet. Some dropouts did occur when I was using the old NETGEAR Powerline adapters, but I was surprised to find that the performance of the new TP-Link adapters was much worse. The dropouts typically lasted a minute or two. This was annoying, to say the least.

I started searching the Web, and ‘TP-Link’ and ‘dropout’ occur together a lot. I had already disabled Power Saving Mode in the adapters, so knew that was not the cause. I happen to know someone who also uses TP-Link adapters, and he mentioned that he also experienced frequent dropouts. In addition to turning off Power Saving Mode, he had implemented a shell script on his machines to ping an Internet site periodically to try and keep the connection from dropping out, but this did not appear to make any difference. I wrote the script below to try the same thing, and it did not cure the dropouts either:

# Script to try to keep the Powerline adapter connected to this machine
# from dropping the connection to the router
while true
    ping -W 2 -c 1 >>/dev/null 2>&1
    if [ $PREVIOUS -ne 0 ] && [ $STATUS -eq 0 ]; then
        logger "Ping successful: connection to Internet is up."
#        echo "Ping successful: connection to Internet is up."
    elif [ $PREVIOUS -eq 0 ] && [ $STATUS -ne 0 ]; then
        logger "Ping unsuccessful: connection to Internet may be down."
#        echo "Ping unsuccessful: connection to Internet may be down."
    elif [ $FIRSTPASS -eq 1 ] && [ $STATUS -ne 0 ]; then
        logger "Ping unsuccessful: connection to Internet may be down."
#        echo "Ping unsuccessful: connection to Internet may be down."
    sleep 10

In my Web searches I came across a a thread in the TP-Link SOHO Community forums with a URL for a new version of firmware for TP-Link Powerline adapters that use the Qualcomm Atheros QCA7420 chipset. I learned from the TP-Link forums that the firmware in NVM (Non-Volatile Memory) depends on the chipset manufacturer’s chipset, not on the Powerline manufacturer’s adapter model, whereas the adapter’s PIB (Parameter Information Block) does change depending on the model (including the country). So I started searching online for a PIB file for the three models of TP-Link adapter that I am using, but I could not find them. However, the Linux open-plc-tools command ‘plctool‘ enabled me to read the PIB from each adapter and store it as a file:

user $ sudo plctool -i eth0 -p TL-PA4010P.pib <MAC address printed on the adapter>
user $ sudo plctool -i eth0 -p TL-PA4010_TV.pib <MAC address printed on the adapter>
user $ sudo plctool -i eth0 -p TL-PA4010_HOME-HUB.pib <MAC address printed on the adapter>
user $ sudo plctool -i eth0 -p TL-PA4020P.pib <MAC address printed on the adapter>

The Ethernet interface in the computer I used is named ‘eth0′, so change it accordingly. You can give any name to the PIB files.

It is also easy to find out the adapters’ MAC addresses and current firmware by using another open-plc-tools command:

user $ plcstat -t -i eth0

The TP-Link tpPLC utility for Windows also shows the firmware version. I was surprised to see that the firmware version was different in the three models I had just bought:

  • TL-PA4010P firmware version:
  • TL-PA4010 firmware version:
  • TL-PA4020P firmware version:

The command to update the firmware in an adapter using the NVM file I downloaded from the URL in the above-mentioned TP-Link Community forum thread and the PIB file read from the relevant adapter, is as follows:

user $ sudo plctool -i <interface> -P <PIB file> -N <NVM file> -R <MAC address of adapter>

For example:

user $ sudo plctool -i eth0 -P TL-PA4010P.pib -N FW-QCA7420- -R 15:B3:D2:D8:5F:BA

I am fortunate in that the three models of TP-Link Powerline adapter I bought all use the Qualcomm Atheros QCA7420 chipset, so I could use the same NVM file for all four adapters that I bought. I only needed to repeat the command with a different PIB file for each adapter model. The plcstat command can be used to check that the firmware version is different from the factory original version:

user $ plcstat -t -i eth0

Actually, the tpPLC utility in Windows 10 also has the ability to upload an NVM file and a PIB file to an adapter, so, as I have tpPLC installed in a VM, I can use that instead to update firmware in my TP-Link Powerline adapters.

And what difference did upgrading the firmware in my new TP-Link adapters make? A big difference. There are no more dropouts; the connection is now stable and I no longer get interruptions while browsing the Internet. It’s a pity that TP-Link does not supply every chipset’s latest firmware file and every model’s PIB file on their support Web site so that users can update their Powerline adapters.