Tag: GRUB

How to downgrade to a previous kernel version in Arch Linux. How to install and switch to linux-lts

New Linux kernels bring support for new hardware and new features. But sometimes the kernel causes problems: it is completely or partially incompatible with existing software, especially video drivers suffer from this, but this can also apply to any other software, for example, VirtualBox.

At the time of the release of the linux 5.9 kernel, NVIDIA drivers were partially incompatible with it, as a result, their important functionality was lost. Although the graphics card worked, but CUDA, OpenCL and probably other features are broken. Of course, this was fixed pretty quickly, but what about those who needed CUDA and OpenCL or other programs that were incompatible with the latest version of the Linux kernel at the time of the problem?

A very recent example, the linux 5.19 kernel at the time of writing is not compatible with the latest version of VirtualBox, which just doesn't work. The problem will be fixed in the near future, but what if you need running VirtualBox machines right now?

One option is to rollback to a previous version by installing it from the downloaded package cache. The method is not the most pleasant, since it will be necessary to prohibit updating the package, the version of which was rolled back, or even refuse to update the entire system.

This method is especially annoying when it comes to the linux kernel – you also need to do something with dependencies.

One of the easier options is to switch to the linux-lts kernel.

How to install linux-lts

LTS – stands for Long Time Support. Simply put, this is a Linux kernel and modules from one of the previous versions, which is rarely updated.

This kernel can be installed as a regular package, replacing the existing kernel. Depending on your computer configuration, you may need to install other *-lts packages, such as the nvidia-lts package, an NVIDIA video driver for the linux-lts kernel.

Also install linux-lts-headers.

All these packages can be installed with the command:

sudo pacman -S linux-lts linux-lts-headers nvidia-lts

Please note that it is not required to remove the old kernel and also the NVIDIA drivers (although you can do this if you wish).

How to switch to linux-lts kernel. Boot options update

In order to use the linux-lts kernel, you need to change the boot options.

Changing boot options is done differently depending on whether you are using GRUB or systemd-boot.

If you are unsure, see “How to check if a computer is using BIOS or UEFI; GRUB or systemd-boot bootloader; MBR or GPT partition table”.

Update boot options for systemd-boot

Open file /boot/loader/entries/arch.conf

sudo vim /boot/loader/entries/arch.conf

Or:

sudo gedit /boot/loader/entries/arch.conf

And replace the lines in it

linux   /vmlinuz-linux
initrd  /initramfs-linux.img

On the

linux   /vmlinuz-linux-lts
initrd  /initramfs-linux-lts.img

For example, the full content of my file was

title	BlackArch
linux   /vmlinuz-linux-lts
initrd  /initramfs-linux-lts.img
options	root=/dev/nvme0n1p2 rw

I commented out the lines that point to the normal kernel version and added the lines that point to linux-lts:

title	BlackArch
#linux	/vmlinuz-linux
#initrd	/initramfs-linux.img
linux   /vmlinuz-linux-lts
initrd  /initramfs-linux-lts.img
options	root=/dev/nvme0n1p2 rw

Then reboot and make sure you are using the LTS kernel version with the command:

uname -a

Update Boot Options for GRUB

Update your GRUB configuration:

sudo grub-mkconfig -o /boot/grub/grub.cfg

Then reboot and make sure you are using the LTS kernel version with the command:

uname -a

After the kernel has been improved and the problems that are bothering you are fixed, you can return to the latest version of the Linux kernel.

How to check if a computer is using BIOS or UEFI; GRUB or systemd-boot bootloader; MBR or GPT partition table

How to know if UEFI or GRUB is being used?

The system booting process consists of the following 4 steps:

  1. System initialization: UEFI or BIOS (POST)
  2. Starting the bootloader (GRUB2 or systemd-boot)
  3. Kernel initialization
  4. Starting systemd, the parent of all processes

Related:

If the BIOS is used in the first step, then the GRUB bootloader is most likely involved in the second step.

If UEFI is used in the first step, then both the GRUB bootloader and the systemd-boot bootloader can be used in the second step.

If you're wondering if your computer is running UEFI or GRUB, then this question is the wrong one because UEFI and GRUB are not mutually exclusive.

Modern GRUB2 can work with both BIOS and UEFI (using efibootmgr). On Arch Linux, BIOS and UEFI support is bundled into a single grub package. In Debian and derivative distributions, GRUB comes in two versions:

  • grub-pc (BIOS version)
  • grub-efi (UEFI version)

How to find out if your computer is using BIOS or UEFI

The easiest way is to check if the computer is using UEFI. If the answer is negative, then this means that the BIOS is used on the computer.

To check if your computer supports UEFI, run the command:

ls -l /sys/firmware/efi

If a list of directories is displayed, for example this:

This means that this computer supports UEFI.

If an error message is shown:

ls: cannot access '/sys/firmware/efi': No such file or directory

This means that this computer is working with BIOS.

Also you can check for UEFI variables:

efivar -l

If a large list of variables is shown, then the computer was booted using UEFI.

If an error message is displayed

-bash: efivar: command not found

That means the computer is running on BIOS.

You can also use the efibootmgr utility to check:

efibootmgr

If it displays information about the UEFI Boot Manager, then UEFI is being used.

Please note that the latter method is not reliable, since the efibootmgr utility is not required even for UEFI computers. That is, if, when using UEFI, you receive a message that the command was not found, then the computer may support UEFI, but the efibootmgr package is not installed on it.

Another way is the bootctl utility:

sudo bootctl

Couldn't find EFI system partition. It is recommended to mount it to /boot or /efi.
Alternatively, use --esp-path= to specify path to mount point.
System:
    Not booted with EFI

Pay attention to the message “Not booted with EFI”, that is, the computer uses BIOS.

Finally, the presence of an EFI partition can be checked with fdisk:

sudo fdisk -l

If the boot disk has an “EFI System” partition, then this computer supports UEFI.

Since UEFI requires a separate “EFI System” partition, it can be argued that if this partition is not on the boot disk, then this computer does not support EFI, but works with BIOS.

How to find out if a computer is running GRUB or systemd-boot

To find out if the systemd-boot bootloader is being used, run the command:

sudo bootctl is-installed

The answer is rather concise: “yes” or “no”.

You will only get an answer if your computer uses UEFI. Otherwise, it will output:

Couldn't find EFI system partition. It is recommended to mount it to /boot or /efi.
Alternatively, use --esp-path= to specify path to mount point.

By exclusion, you can determine that if the systemd-boot bootloader is not used, then the GRUB bootloader is most likely used. But how to reliably confirm that it is the GRUB bootloader that is being used?

A system with GRUB installed must have a /boot/grub folder and a /boot/grub/grub.cfg file. To confirm that the GRUB bootloader is being used, you can check for their presence:

ls -l /boot/grub/grub.cfg

You can find other ways to identify GRUB, such as looking for the string “GRUB” in the boot area of the disk, but this method only applies to GRUB-PC! This method does not work with GRUB-EFI.

Since Debian currently has two different versions of GRUB-EFI and GRUB-PC, which are quite different, let's look at how to identify each of them.

How to know if GRUB-EFI or GRUB-PC is being used

As already mentioned, there are two versions of GRUB in Debian and derivatives:

  • grub-pc (BIOS version)
  • grub-efi (UEFI version)

They are quite different, and the methods for determining them also differ.

On Arch Linux and its derivatives, the GRUB-EFI and GRUB-PC versions are bundled into one package.

Using the previous information, you can logically determine whether GRUB-EFI or GRUB-PC is being used:

  1. If the computer uses EFI but does not use the systemd-boot bootloader, then the GRUB-EFI bootloader is used
  2. If the computer does not use EFI, then the GRUB-PC bootloader is probably used

There are also more reliable ways to check which version of the GRUB bootloader your computer is using.

First of all, check the contents of the /boot/grub directory:

ls -l /boot/grub

The presence in this directory of the subdirectory “x86_64-efi” indicates that this operating system uses GRUB-EFI:

The presence of the “i386-pc” directory says that GRUB-PC is being used:

If you receive an error message:

ls: cannot access '/boot/grub': No such file or directory

It means that this OS does not use GRUB.

In the Debian and derivatives repositories, the GRUB-EFI and GRUB-PC installation packages are marked as conflicting, meaning that only one of them can be installed. Therefore, we can check the installed packages to determine which version of GRUB is being used:

dpkg -l | grep grub | grep ii

The installed packages “grub-efi-amd64” and “grub-efi-amd64-bin” indicate that GRUB-EFI is being used:

The installed packages “grub-pc” and “grub-pc-bin” say that GRUB-PC is being used:

Another way to confirm that the operating system is using the GRUB-PC bootloader is the following command:

dd bs=512 count=1 if=/dev/sda 2>/dev/null | strings | grep GRUB

If any output is shown, GRUB-PC is being used.

In the previous command, you need to correctly specify the disk name, you can see the disk names with the command:

fdisk -l

An example command if the operating system is installed on the /dev/vda drive:

dd bs=512 count=1 if=/dev/vda 2>/dev/null | strings | grep GRUB

This screenshot shows that the OS uses GRUB-PC:

There is no similar command for GRUB-EFI.

How to find out if your computer is using an MBR or GPT partition table

Typically, EFI computers use the GPT partition table, and BIOS computers use the MBR, although exceptions are possible.

The following command will show the partition table type for a particular drive:

lsblk -dno PTTYPE /dev/DISK

For example:

lsblk -dno NAME,PTTYPE /dev/nvme0n1

And the following command will display the partition table types for all disks in the operating system:

lsblk -dno NAME,PTTYPE

To check which partition table is on the computer using fdisk, run the command:

sudo fdisk -l

Pay attention to the “Disklabel type” value:

  • gpt stands for GPT
  • dos stands for MBR

The same information can be obtained using the cfdisk utility:

cfdisk /dev/nvme0n1

Pay attention to the value of “Label”:

  • gpt stands for GPT
  • dos stands for MBR

Loading...
X