Category Archives: Linux

GRUB vs Windows

While my main driver (laptop) is dual boot Linux (Arch) and Windows 11, ocassionally Windows Update manages to disrupt GRUB so that the system can’t boot. Yesterday was one of those days.

So for prosperity / my own sanity, here’s a quick reminder of how I got it working again.

Booting

In order to boot the system, I used the GParted USB stick that I keep for exactly such emergencies. I can’t recall the number of times having this around has helped save my bacon! Booting into the GUI is simple, and it automatically loads the Gparted application. Useful to help see what is on which partition. For me this looks like:

PartitionFilesystemDescription
/dev/sda1FAT32700MB – EFI / ESP
/dev/sda2Microsoft ReservedWindows put this here, and I just keep it as it’s only 16MB
/dev/sda3NTFSWindows C:
/dev/sda4NTFSHidden, diagnostic partition, only 650MB
/dev/sda5EXT4Arch Linux /
Partition Table on Laptop

Danger, Here Be Dragons

The following is performed as root, in a terminal. Be careful – these are the commands I need to execute on my system. Your system will be different.

Firstly, I setup and entered the chroot Arch environment:

mkdir /tmp/arch
mount /dev/sda5 /tmp/arch
cd /tmp/arch
mount /dev/sda1 efi/
mount -t proc /proc proc/
mount --rbind /sys sys/
mount --rbind /dev dev/
chroot /tmp/arch /bin/bash

Next I needed to run some GRUB commands to re-install the boot loader. These commands are specific for UEFI systems.

grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=GRUB

To read more on these see the Arch Wiki GRUB pages.

Once sucessfully completed, it was simply a process of rebooting!

Ubuntu / Gnome – Switch Windows, not Applications

So, if you have recently switched from Windows to Ubuntu, you will notice that the Alt+Tab groups windows of similar applications.

For instance, if you have 3 windows of the same web browser application running, Alt+Tab won’t let you switch between those windows. Turns out, you have to use Alt+` to switch between windows of the same applications. Annoying, right?

My muscle memory of using Alt+Tab for years on Windows, I cannot resist it. So, I found a way to separate windows of the same application in the tab switcher. So, here’s how you do that.

Search “Keyboard Shortcuts” on the GNOME launcher.

Within the keyboard shortcuts and under the Navigation tab, you would find a shortcut called “Switch Windows“.

Click on the shortcut and it will ask you to provide the hotkey. In our case, we will keep the hotkey as “Alt+Tab“. Click on the Set key to save this hotkey.

Once you have done this, now Alt+Tab would work as switching between Windows rather than Applications.

You may thank me later 🙂

Ventoy

If like me you have several USB sticks hanging around the home office, and each one contains a bootable ISO that you keep just in case (like a copy of Ubuntu, for fixing GRUB2 issues, or a copy of GParted for partition / filesystem issues) then you’ll also know the pain of a) not having enough USB sticks for all of these, and hence b) the pain of having to use Etcher / Rufus / dd to put the right ISO on the risk USB stick at the right time.

Enter Ventoy.

Ventoy is an open source tool to create bootable USB drive for ISO/WIM/IMG/VHD(x)/EFI files. With ventoy, you don’t need to format the disk over and over, you just need to copy the ISO/WIM/IMG/VHD(x)/EFI files to the USB drive and boot them directly.
You can copy many files at a time and ventoy will give you a boot menu to select them (screenshot). x86 Legacy BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI are supported in the same way.

https://www.ventoy.net/

Windows 11

It’s no surprise that I’m a primary Linux user when it comes to desktop (laptop!) OS.

However, unlike many previous versions of Windows, I’ve always found the Windows 10 experience very pleasant. Crashes are few and far between, things are pretty much where I expect them to be, and WSL makes the transition between “Windows tasks” (something esoteric in Word / Adobe) and dev tasks a much easier experience that doesn’t require a reboot.

So Windows 11 is coming, and this weekend I took the time to (re-)join the Insiders Programme, lock into the Dev Channel, and install Windows 11.

The install took ~1 hour. Multiple reboots. No major dramas if you’re used to Windows installs of recent years. The usual initial slowness due to re-indexing / Sophos wanting to rescan everything that has changed – but that soon calmed down.

Most noticable differences:

  • Yes, they’ve changed the Start Menu. Again. Not in a Windows 8 bloaty kinda way, more in a central-location Mac kinda way.
  • New icon set. Customer has to feel like they’re getting something ‘new’, right?
  • Rounded. Everything just feel smore rounded. Not in a holistic kinda way, as in things have round corners.

The BIG difference – WSLg.

Not technically a Windows 11 feature, but I had the opportunity to install it as an update at the same time. https://github.com/microsoft/wslg

Once I’d updated my Nvidia drivers to get better hardware performance (https://developer.nvidia.com/cuda/wsl) the rest was a dream. Being able to just type ‘nedit’ (or whatever) in a WSL session within Windows Terminal and it to pop-up is the UX I’ve been craving for years. No need to ‘export DISPLAY’, no need to install some weird 1990’s XServer. It just works.

winver.exe
Centralised Start Menu.

Updating Arch AURs

The Arch User Repository (AUR) is a community-driven repository for Arch users. It contains package descriptions (PKGBUILDs) that allow you to compile a package from source with makepkg and then install it via pacman. The AUR was created to organize and share new packages from the community and to help expedite popular packages’ inclusion into the community repository.

If you install apps / packages from the AUR, they also need to be kept up to date, and pacman can’t do that for you. You need an AUR Helper.

The two commonly used AUR helpers in Arch Linux are Yaourt and Packer. You can easily use them for Arch Linux package management tasks such as installing and updating packages.

However, the two have been discontinued in favour of yay, short for Yet Another Yaourt. Yay is a modern AUR helper written in the GO language. It has very few dependencies and supports AUR tab-completion so that you don’t have to type the commands in full.

Install yay (from the AUR – ironically):

git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

Use yay to update packages from AUR:

yay -Syu

Arch Linux Mirrorlist

Arch linux package updates come through fairly frequently – at least once a day. Last week I noticed that my usual ‘updates available’ widget hadn’t poked me for a few days, so I was curious as to what was going on. Was the Open Source community on a holiday? Or perhaps, and more likely, something about my setup wasn’t right, and now I wasn’t getting updates.

The first thing I tried was to call /usr/bin/checkupdates. Which returned nothing. Hmmm… were there really no updates available, or were the mirrors I was using just no longer uptodate or working?

I came across the Pacman Mirrorlist Generator (https://archlinux.org/mirrorlist/). This page generates the most up-to-date mirrorlist possible for Arch Linux. The data used here comes straight from the developers’ internal mirror database used to track mirror availability and tiering. There are two main options: get a mirrorlist with every available mirror, or get a mirrorlist tailored to your geography.

Generally you want mirrors that are fast and/or close – as you’ll be pulling a decent amount of data down from them – plus no one likes a long update process.

I’m in the UK (close to France), prefer HTTPS, and my ISP uses IPv4 (https://archlinux.org/mirrorlist/?country=FR&country=GB&protocol=https&ip_version=4) – so I opted for these settings. Et voila – a new mirror list for me to use.

Before I put this into action, I wanted to make sure I had a backup first:

# cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup

I wanted the top 5 mirrors from the list generated, so I used rankmirrors, and the following script:

# curl -s "https://archlinux.org/mirrorlist/?country=FR&country=GB&protocol=https&ip_version=4&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 - > /etc/pacman.d/mirrorlist

Once I ran checkupdates again… I now had a lot of updates.

A quick:

sudo pacman -Syu --noconfirm

…and I was feeling fresh again.

Kensington DisplayLink Dock / Hub in Arch Linux

As with many, I have been home-working for over a year now, and one of the early investments I made was a dock/hub, so that I could easily switch between my work and personal laptops on my desk, as I need to work with (at least) two monitors.

I found a Kensington USB3.0 DisplayLink dock on eBay for around £40, and went for that. I have been really impressed; I’ve been using it daily since then, and it’s always coped with my displauys, laptops, and various USB desvices (webcams, mice, keyboards, and Jabra conference speaker).

Originally I was using it with Windows 10 (work!), and while I was at the end of my Ubuntu bandwagon, I used it sucessfully with that too.

For those interested in what the Linux kernel thinks the device is:

[ 601.373175] usb 2-4.1: New USB device found, idVendor=17e9, idProduct=430f, bcdDevice=31.02
[ 601.373187] usb 2-4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 601.373193] usb 2-4.1: Product: Kensington USB3.0 2X Video Dock
[ 601.373197] usb 2-4.1: Manufacturer: DisplayLink

So, when I switched to Arch as my main Linux distro I was a little nervious / dubious about support and how well it would perform. I was pleasantly surprised (as I have been throughout my Ubuntu -> Arch tranisition), and it seems to work well.

Despite being a Linux-bod and a Programmer, I was a bit overwhelmened with the potential amount of fiddling / configuration the Arch wikli suggested that I would need to do to get it working (https://wiki.archlinux.org/index.php/DisplayLink), however, it turned out to be a lot simpler than that.

I installed evdi-git from the AUR (https://aur.archlinux.org/packages/evdi-git/):

$ git clone https://aur.archlinux.org/evdi-git.git
$ cd evdi-git
$ makepkg -si

Then I installed the displaylink from the AUR (https://aur.archlinux.org/packages/displaylink/):

$ git clone https://aur.archlinux.org/displaylink.git
$ cd displaylink
$ makepkg -si

I then enabled the displaylink.service:

$ sudo systemctl enable displaylink.service
$ sudo systemctl start displaylink.service

And then the other two monitors just kicked in! I configured how I want the displays setup using Gnome Settings:

I love it when things just work.

DisplayLink do a great job of providing drivers, if people need them for other distros: https://www.displaylink.com/downloads

Grub2: Save Last Boot Option

Over the years there have been many GNU/Linux bootloaders (I remember using loadlin, and syslinux), and these days most distributions are settling on Grub2 (https://www.gnu.org/software/grub/).

If you’re like me and have multiple OS installed on a machine, you can find yourself getting intimate with your bootloader to make it behave in a way that will suit your workflow, or sometimes missing that menu to make your selection.

I multi-boot Ubuntu, Windows 10 (yes, there are some things I need to do here), Arch, and sometimes something else. 9 times out of 10, I just want the bootloader to boot the last selection I made, but this one isn’t always Grub’s default. Yes, I could change the default value, however I find the offset-model here a little annoying, especially when you get “Advanced options for X Linux…” in the menu list.

Today I discovered a Grub2 setting that makes Grub remember and boot your last selection. Very useful!

I made my edits under Ubuntu (as that’s the OS that I consider owns my grub settings):

sudo nano /etc/default/grub

Change your GRUB_DEFAULT setting to be saved:

GRUB_DEFAULT=saved

Add in the GRUB_SAVEDEFAULT value to make this work:

GRUB_SAVEDEFAULT=true

Save, and then run the stub for grub-mkconfig:

sudo update-grub

Et voila! I can now reboot, and it rememvers what I selected last time. Great for when testing a change to your main-driver OS – as I’m doing with Arch currently.

Arch GNU/Linux – 1 Week In

I’ve been using Arch GNU/Linux for about a week now, as my main driver.

Those first few days are always about getting those packages installed that you use often, and configuring the system for your particular workload.

As a point of reflection, I thought I’d look at the list of packages that I have installed.

In pacman, to list all explicitly installed packages:

pacman -Qe

Which gives:

adobe-source-sans-pro-fonts 3.028-1
adobe-source-serif-pro-fonts 4.004-1
arduino 1:1.8.13-2
arduino-avr-core 1.8.3-1
autoconf 2.71-1
automake 1.16.3-1
base 2-2
bash-completion 2.11-1
baudline-bin 1.08-4
binutils 2.36.1-2
bison 3.7.3-1
chromium 88.0.4324.182-1
cinnamon 4.8.6-1
cmake 3.19.6-1
composer 2.0.11-1
docker 1:20.10.4-1
docker-compose 1.28.5-1
fakeroot 1.25.3-2
flex 2.6.4-3
gcc 10.2.0-6
gdm 3.38.2.1-1
gedit 3.38.1-1
git 2.30.1-1
gnome-calculator 3.38.2-1
gnome-control-center 3.38.4-1
gnome-keyring 1:3.36.0-3
gnome-screenshot 3.38.0-1
gnome-shell-extension-arch-update 39-1
gnome-system-monitor 3.38.0-1
gnome-terminal 3.38.3-1
gnome-tweaks 3.34.1-1
google-chrome 88.0.4324.182-1
gparted 1.2.0-2
gqrx 2.14.4-1
groff 1.22.4-4
inspectrum 0.2.3-1
intel-ucode 20210216-1
linux 5.11.2.arch1-1
linux-firmware 20210208.b79d239-1
liquid-dsp 1.3.2-2
m4 1.4.18-3
make 4.3-3
man-db 2.9.4-1
man-pages 5.10-1
mlocate 0.26.git.20170220-5
mongodb-compass-git 1:r3403.ga0d25bb2-1
mtools 4.0.26-1
nano 5.6-1
nemo-fileroller 4.8.0-2
nemo-preview 4.8.0-2
nemo-share 4.8.0-2
networkmanager-openconnect 1.2.7dev+49+gc512d5a-1
networkmanager-openvpn 1.8.12-1
noto-fonts 20201226-1
noto-fonts-cjk 20201206-1
noto-fonts-emoji 20200916-1
noto-fonts-extra 20201226-1
ntfs-3g 2017.3.23-5
openconnect 1:8.10-1
openvpn 2.5.1-1
patch 2.7.6-8
php-mongodb 1.9.0-3
pkgconf 1.7.3-1
python-pyqt5 5.15.3-2
qwt 6.1.6-1
sudo 1.9.5.p2-1
syncthing 1.13.1-1
texinfo 6.7-3
ttf-bitstream-vera 1.10-14
ttf-carlito 20130920-5
ttf-croscore 20201226-1
ttf-dejavu 2.37+18+g9b5d1b2f-2
usbutils 013-1
vi 1:070224-4
visual-studio-code-bin 1.53.2-1
whois 5.5.8-1
xf86-video-nouveau 1.0.17-1
xorg-fonts-misc 1.0.3-10
xterm 366-1

A few of those I’ll probably delete (denoted in red), as they were more for trial.

Naturally, this is just a list of packages that I have explicitly installed, there is a lot more behind that in terms of dependencies and in base.