Monthly Archives: July 2022

Installing Arch Linux with the archinstall script

After using EndeavourOS for a while, I also decided to try Arch itself!

I did not feel ready to go through the manual procedure (but I’ll do that someday), and I heard about the archinstall script, which comes in the Arch official ISO. After watching a few videos and reading a few blog posts, I tried that myself, first on a VM and then on a real machine.

I can anticipate that I liked this installation procedure. Still, it is not perfectly usable in a multi-boot environment, as I’ll say near the end of this post, where I summarize my experience with the installation.

In this post, I’ll first show an installation on a VM (and I suggest you try that one), then briefly describe the installation on a real machine.

If you want to try that, you have to download an official Arch ISO. Once you booted into the live ISO, you must connect to the Internet as described in the official documentation.

Now, it’s time to run the installer:

And you have access to the main installation menu:

You see, it’s easy to use, especially if you’re familiar with other Linux installation programs.

The first three entries are easy to deal with.

The fourth, “Select harddrives,” requires some care because it’s where you deal with your disk! You have to select the correct drive. In my case:

Since I’m on a VM, I’ll simply choose to wipe everything on that drive and let the installer handle the partitioning automatically. That’s easy in a VM, and that’s what I’ve seen in all demos on the web (but, as I’ll show later, things are more complicated in a multi-boot environment):

Then, you choose the filesystem EXT4, BTRFS, etc.

For the bootloader, I chose GRUB, which is the one I’ve always used.

Concerning the user accounts, it’s best NOT to set a root password: it’s better to create a user with administrator rights (so that you later rely on the good ol’ “sudo”). An interesting feature of this installation procedure is that it lets you create as many users as possible. On the contrary, typically, other Linux installations only allow you to create a single user.

The other interesting menu entry is the one to choose the profile. I’m choosing “desktop”:

And in particular, I’m choosing GNOME (you see that you have plenty of choices):

Moreover, you can select the graphic drivers:

And the kernels:

Since, for the moment, you could just select from a predefined set of choices, you are given a chance to manually specify additional packages to install (but you have to know them by their name). In this example, I’m installing “firefox”:

It’s also crucial to configure the network for the installed system. If you use GNOME or KDE, I’d say that it’s best to choose “NetworkManager”:

Once you’ve done with all the menu entries, before starting the actual installation, you’re given a chance to save these configurations, which is helpful if you want to use the same configurations on other machines or to do some further customizations:

Now, it’s time to choose “Install”; a countdown starts to abort the installation in case you just remembered you’ve done something wrong:

The installation starts and in a few minutes (where a few packages will be downloaded)…

…you should get to the end of the installation, where, if you want, you can also tweak the installed system before rebooting:

If you choose “no”, you’re back to the live environment:

And you can now reboot to (hopefully) enjoy your installation:

Having installed GNOME, I’m presented with a few options, and I choose the first one, that is, GNOME on Wayland:

You see that the GNOME installation is a vanilla one.

OK, that was a VM, and it was straightforward to install Arch with the installation script. It’s also easy if you plan to install ONLY Arch on your computer (by wiping all the rest).

Things are not working completely fine if you want to install it on a computer with other Linux installations, which you want to keep and be able to boot into. In this case, of course, you cannot wipe the selected hard drive and must do manual partitioning. The installation script is still helpful in that respect (I’m not showing anything in this blog post), but you must be aware of a small problem.

In fact, due to an issue, which, at the time of writing, is still open, specifying to mount an existing EFI partition into “/boot/efi“, which, as far as I know, it’s the standard mount point in most distributions (every distribution I know at least). You must specify a mount point “/boot” and that must be a boot partition (with the boot flag). Of course, that’s what I’ve done myself; I specified the exiting EFI partition (the first partition of the installation drive in my computer) for the mount point “/boot”. However, the installer will treat that directory as if it was /boot/efi in other installations. Thus, it will copy the booting files directly there. As a sad result, the Arch installation will not be detected when rebooted. You will only see an existing installation’s GRUB menu (and running os-prober from an existing installation does not seem to help). Thus, you end up with the Arch installation that you cannot boot.

The only solution I found to boot into the Arch system was to apply the mechanisms shown in my other post and configure the Fedora GRUB with an entry pointing directly to the EFI partition, i.e., according to the post mentioned above, something like the following (remember, on my computer the EFI partition is the first one, and I installed Arch on the partition 13):

Or even like that (i.e., without specifying the root partition of the Arch installation at all and just relying on the grub that the installer created directly on the EFI partition):

Besides this problem, the installation script archinstall is really interesting and still under development.

Locate and BTRFS

I’ve always been using the locate command (provided by the mlocate package or by the new plocate package), which quickly searches for files and directories by their names. The command relies on the database built by the command updatedb (which should be run periodically, e.g., by enabling the plocate-updatedb.timer service for plocate).

Unfortunately, by default, it does go well with the BTRFS filesystem and its subvolumes (see, e.g., this bug), resulting in empty results for all searches basically.

Fortunately, the solution is quite simple:

  1. edit the file /etc/updatedb.conf
  2. replace PRUNE_BIND_MOUNTS = “yes” with PRUNE_BIND_MOUNTS = “no”
  3. save, exit and re-run updatedb

Then, you can enjoy locate’s search results 🙂

Linux EndeavourOS Artemis Review

I have already blogged about EndeavourOS, which I use most of the time on a few laptops. Since EndeavourOS, based on Arch, is a rolling release, I update it almost daily and don’t need to install it from scratch when a new release comes out, like Artemis, which was released a few days ago. However, since I wanted to switch from the EXT4 file system to BTRFS (since I started to experiment with this file system and its snapshot capabilities), I took the chance to try this new release by installing it from scratch (of course, using BTRFS this time).

I’ll first go through the installation, but I can anticipate that, once again, I’m impressed by EndeavourOS. This installation feels really fast, maybe due to BTRFS or the new kernel (instead of the LTS kernel, I now use the latest one provided by the distribution) or both. Most of all, EndeavourOS is pure Arch but with outstanding defaults. Indeed, the KDE and GNOME environments are vanilla ones.

Installation

As usual, the first thing to do, once booted in the live environment, which in this case is XFCE, is set up the network connection. You might also want to change the keyboard layout (Disable system defaults and install your layout, in my case, it’s the Italian layout):

Then, let’s update the mirrors (typically by selecting your state) and start the installer.

I choose the “Online” method because I want to install KDE Plasma instead of Xfce.

You have to wait a few seconds (or about a minute) for the installer to download the modules (I always prefer to install any operating systems in English):

Maybe, due to a bug, the location has been found successfully, but the English version proposed is not the right one, so I have to change it to Americ English again:

After setting the keyboard layout (this time for the installed system), it’s time for partitioning.

Since on this computer I have a few Linux installations, including the old version of EndeavourOS I’m going to replace, I choose Manual partitioning (and not “Replace a partition” because that would keep the same file system type, EXT4, while I want to switch to BTRFS).

I Edit the partition, select “Format” (otherwise, I cannot change the File system type), modify the File system (BTRFS), and specify the mount point.

Before going on, we must specify to mount the EFI partition (into /boot/efi) without formatting it and ensure the “boot” flag is selected. This way, the installer can properly install GRUB.

WARNING: on another computer, the installer complained that I did not select a boot partition with at least 300Mb (mine was just 200Mb). Since I knew there was enough space in that partition, I ignored the warning, and the installation went fine.

As for the desktop, I select Plasma.

And then, we can select the single packages. Note that, different from my previous review, you choose the packages after selecting the desktop, so that a few packages, in particular, the ones of the chosen desktop, have already been selected:

In this blog post, I’m not going to install GNOME besides KDE, but I also select the “Printing-Support” and the “Support for HP Printer/Scanner” checkboxes.

As usual, then you have to specify your user’s details, and then it’s time to take a look at the summary:

Let’s start the installation. It might take a few minutes because it’s an “Online” installation, so it has to download several packages.

You can press “Toggle log” during the installation to see the installer’s log.

When it’s done, it’s time to restart the computer.

First impressions

As in the previous blog post, I must note that the Discover icon is still in the taskbar, though the software manager Discover is not installed at all.

Maybe because I selected KDE Plasma only, the Wayland session has not been installed, while in my previous post, I installed both GNOME and KDE. However, I just had to run this command:

And then I could enjoy Plasma also in Wayland, which seems to be pretty usable.

A nice addition is a firewall applet in the taskbar

Here’s neofetch:

Printing support is excellent! I connected an old USB HP Deskjet printer, and I got these notifications from Plasma:

The printer has been automatically installed correctly (I only had to configure a few things like paper size and color mode).

Setting up my Google accounts (drive access and calendar) is as cumbersome as always, but I did not experience any problems once I finished.

Power consumption on the battery is also excellent, but that was true in the past, so nothing changed in that respect.

All in all, this distribution keeps on being awesome.

As I initially anticipated, you have Arch and its vanilla desktop environments, but with useful and reasonable defaults. Moreover, the installation is effortless! 🙂

Enabling Hibernation in Arch-based distros

I had already posted about enabling hibernation in Linux, particularly in Ubuntu.

Thanks to the script hibernator, the procedure is much more straightforward in Arch-based distros (including Manjaro and EndeavourOS).

First of all, make sure you first install the package update-grub.

The package hibernator is available from AUR, but currently, there’s a problem with the build instructions. Thus, we must install it manually. There’s no need to install the script anywhere: it’s just a matter of cloning the script from GitHub and running it once:

Then, before running the script (as a superuser), we must decide where we want the suspend-to-disk to take place: either in a swap partition or in a swap file (please keep in mind that currently, the script cannot handle hibernation into a swap file of a BTRFS partition).

If we want a swap file, the script can create that for us, and we can also specify the size of the swap file. Here’s the quote from the home page of the project

Hibernator accepts desired size of swapfile as arguments. Running hibernator 2G creates 2 Gb swapfil, hibernator 1000M creates 1000 Mb swapfile. The script defaults to 4G if no arguments are given.

If we want a swap partition, we must ensure the partition is already in place and that our /etc/fstab already refers to that (i.e., it mounts it appropriately).

When we’re ready, we just run the script with sudo. The script will update the GRUB command line with the resume option and a resume hook to /etc/mkinitcpio.conf. Finally, it will update the GRUB configuration (with update-grub, that is why you need to install this package beforehand).

Here’s an example of the output:

And that’s all: we just reboot, and hibernation is ready to be used!

Before rebooting, you might want to check that the GRUB_CMDLINE_LINUX_DEFAULT variable in /etc/default/grub has been set with a valid resume entry (if you rely on a swap partition, which has been properly specified in /etc/fstab, it should contain a reference to the UUID of the swap partition):

You can test that, as usual, with

You may also want to refer to the older post enabling hibernation in Linux, particularly in Ubuntu, for other mechanisms related to hibernation, like suspend and then hibernate.

Timeshift and grub-btrfs in Linux Arch

UPDATED 02/Jan/2023, ChangeLog:

  • 02/Jan/2023: documented that the new version of grub-btrfs is now an official package (you still have to install another package: inotify-tools);
  • 02/Dec/2022: documented the new version of grub-btrfs and its new grub-btrfsd daemon; the configuration for Timeshift is much simpler, but you have to install another package: inotify-tools.

After looking at the very nice videos of Stephen’s Tech Talks, in particular, this one https://www.youtube.com/watch?v=6wUtRkEWBwE, I decided to try to set up Timeshift, Timeshift-autosnap, and grub-btrfs in my Linux Arch installation, where I’m using BTRFS as the filesystem. These three packages allow a timeshift snapshot to be automatically created each time you update your system; moreover, a new grub entry is automatically generated to boot into a specific snapshot.

The video mentioned above is handy, but unfortunately, some recent changes in Timeshift itself broke the behavior of the two other packages. In this post, I’ll try to show how to fix the problem and go back to a working behavior. I’ll also show an experiment using the snapshots so that, hopefully, it’s clear what’s going on in the presence of such snapshots and how to use them in case you want to revert your system.

Install timeshift and timeshift-autosnap

First of all, let’s install timeshift and timeshift-autosnap (the latter depends on the former, and they are both available from AUR; I’m using the yay AUR helper here):

The programs will be installed from sources; thus, they will be compiled (it might take some time).

Let’s create a new Timeshift snapshot to make sure it works (the first time, you will have to configure Timeshift; of course, it is crucial that you choose “BTRFS”).

You can configure timeshift-autosnap with the number of snapshots to keep (in this example, I specify 10):

Install grub-btrfs (new version, installation from the official repository, 02/Jan/2023)

The new version of grub-btrfs is now available as an official package (Please remove the old AUR version if you still have it installed):

So you can simply install it with pacman:

Now, let’s make sure grub-btrfs can find Timeshift’s snapshots (remember, we’ve just created one). So let’s update the grub configuration, and we should see in the end something like the following output:

The last lines prove that grub-btrfs can detect snapshots.

We now need to configure that to monitor the Timeshift snapshot directory instead of the default one (/.snapshots).

Automatically update the grub menu upon snapshot creation or deletion (2 December 2022)

What follows is based on the new version of grub-btrfs. At the bottom of the post, there are still the old instructions, which are to be considered stale and left there only for “historical reasons”.

Grub-btrfs provides a daemon watching the snapshot directory and updates the grub menu automatically every time a snapshot is created or deleted.

Important: This daemon requires an additional package:

By default, this daemon watches the directory “/.snapshots” (the default directory for Snapper). Since Timeshift uses a different directory, we have to tweak the configuration for the daemon.

Let’s run:

We must change the line

into

This is required for Timeshift version 22.06 and later because Timeshift creates a new directory named after their process ID in /run/timeshift every time they are started. Since the PID will be different every time, also the directory will be different. Grub-btrfs provides the command line argument –timeshift-auto to correctly detect the current snapshot directory (In previous versions of grub-btrfs, we had to tweak /etc/fstab to deal with that, as shown later in the old section).

Let’s start the daemon:

In the journalctl log, we should see something like (where the date and time have been stripped off):

Let’s start Timeshift. In the journalctl log, we should see something like this:

Let’s verify that if we create a new snapshot, grub-btrfs automatically updates the GRUB menu: in a terminal window, run “journalctl -f” to look at the log, then create a new snapshot in Timeshift. In the log, you should see something like the following lines:

Similarly, if we delete an existing snapshot, we should see something similar in the log.

Remember that it takes a few seconds for grub-btrfs to recreate the grub menu.

Once we’re sure everything works, we can enable the daemon to always start at boot:

The next time we boot, our grub menu will also show a submenu to boot snapshots.

Concerning doing some experiments booting a snapshot and restoring it, please look at the next section.

IMPORTANT: If you have several Linux distributions on your computer and you use a multiboot system like the one I blogged about, and this distribution is not the main one, you will have to manually tweak the entry in your main distribution’s GRUB menu. See the linked blog post near the end.

Some experiments

Let’s do some experiments with this configuration.

Here’s the kernel I’m currently running:

I’m updating the system (I’m skipping some output below, and you can ignore the “stale mount” errors):

So it created a snapshot before updating the system (in particular, it installed a new kernel version). Let’s reboot and verify we are running the new kernel (5.18.8 instead of 5.18.7):

Let’s reboot and select from GRUB the latest snapshot (remember, the one before applying the upgrade), so timeshift-btrfs/snapshots/2022-07-02_15-35-53 (snapshots are presented in the grub submenu from the most recent to the oldest one). We do that by pretending that the update broke the system (it’s not the case), and we want to get back to a working system before the update we have just performed.

You see that the “Authentication Required” dialog greets us, and in the background, you can see the notification that we “booted into Timeshift Snapshot, please restore the snapshot”:

The password is required because it’s trying to run Timeshift:

In the screenshot, you can see that we are now using the older kernel since we booted in that snapshot, where the update has not yet been performed. We have to restore the snapshot manually; otherwise, on the next boot, we’ll get back to the updated system version and not in the snapshot anymore.

So, let’s restore the snapshot:

You see, Timeshift has created another snapshot ([LIVE]). We now reboot normally (that is, using the main grub entry, NOT the snapshot entries).

Once rebooted normally, we can verify again that we are running the old kernel:

Let’s have a look at Timeshift, and we can see the last snapshot is an effective one, not a LIVE one:

Yes, we are now in a system where the update above has never been applied.

Let’s try to rerun the update command (we don’t effectively execute the update, it’s just an experiment):

Why? Because the snapshot had been created automatically by timeshift-autosnap before applying the updates while the package manager was running, its lock is still there.

Let’s remove the lock and try to rerun the update:

The output is similar to the one shown above (unless there are even more new updates in the meantime, which might happen in a rolling release), but something is missing:

Why? Because the downloaded packages in the cache are NOT part of the saved snapshot, they are still present in the current system, even though we restored the snapshot. Why are the cached packages still there, but the lock has been restored with the snapshot? That’s due to the way subvolumes are specified in the /etc/fstab:

You see, the cache of downloaded packages and the logs are NOT part of the snapshots, while /var/lib (including the pacman lock) is part of the snapshots.

Let’s now revert the snapshot: we select the one with “Before restoring…”.

Again, we are now in a LIVE situation, and Timeshift tells us again to reboot to make it effective.

Let’s reboot (by using the main grub entry).

We’re back to the updated system, and there’s nothing to update (again, unless new updates have been made available in the meantime):

If we’re happy with the updated system, we can also remove those two snapshots (remember that grub-btrfs monitors the snapshots so that it will update its grub submenu entries):

I hope you find this blog post helpful, and I hope it complements the beautiful video of Stephen’s Tech Talks mentioned above.

Old version (with old release 4.11 of grub-btrfs)

UPDATE 02/Dec/2022: These are the older instructions for the previous version of grub-btrfs, where there was no “grub-btrfsd.service” and there was another systemd program (“grub-btrfs.path”).

I leave these instructions here just for “historical reasons”.

The first problem is that timeshift has recently changed the strategy for creating snapshots. Instead of creating them in /run/timeshift/backup/timeshift-btrfs/snapshots, it now creates them in /run/timeshift/<PID>/backup/timeshift-btrfs/snapshots, where <PID> is the PID of the Timeshift process. Each time you run Timeshift, the directory will be different, breaking grub-btrfs (which expects to find the snapshots always in the same directory).

Fortunately, there’s a workaround: we add an entry to /etc/fstab in order to mount explicitly the path /run/timeshift/backup/timeshift-btrfs/snapshots:

where, of course, <UUID> has to be replaced with the same UUID of the physical disk partition.

Reboot, and then Timeshift will also put the snapshot in that directory (besides the one with the PID, as mentioned above). You can try to create a snapshot to verify that (this also allows us to use the Timeshift wizard so that we specify to create BTRFS snapshots).

Let’s make sure the mount point is active (and note the unit name)

Let’s now install grub-btrfs

We need to configure that to monitor the Timeshift snapshot directory instead of the default one (/.snapshots).

The file contents

should be replaced with

Let’s reload and re-enable the monitoring service:

If we have already created a few snapshots, we can run update-grub (or, if you have not installed the package update-grub, use the command “grub-mkconfig -o /boot/grub/grub.cfg”) and verify that new grub entries are created for the found snapshots:

We can also restart the system and prove that we can access the GRUB submenu with the generated entries for the snapshots.