Other linux x kernel

Boot directly into another kernel from running Linux without bootloader

Is there a way to boot directly into another kernel on disk from a running Linux, without resetting the machine and going through the bootloader? In theory, Linux should be able to load another kernel into RAM, load initrd as well, gracefully shutdown everything as in shutdown and then pass control to the new kernel. Is there a practical way to do that?

3 Answers 3

It sounds like you are looking for kexec

For example, if the kernel image you want to reboot to is /boot/vmlinux, the contents of /proc/cmdline is root=/dev/hda1, and the path to the initrd is /boot/initrd, then you would use the following command to load the kernel:

kexec -l /boot/vmlinux --append=root=/dev/hda1 --initrd=/boot/initrd 

After this kernel is loaded, it can be booted to at any time using the command:

It has been a while since i played with kexec, but I do not remember having to issue shutdown as kexec -e should unload the old kernel and boot into the specified one. The man page I linked has some good information and all the available options.

The idea was to at least unmount existing file systems etc. I read the man page, and googled, but couldn’t find anything. Systemd can perform a controlled shutdown before kexec -e, but this is a non-systemd system. I’ll guess I’ll just give it a try .

@dirkt, kexec predates systemd by years. The normal system shutdown procedure of whatever init system you are using is run, then in the last step, kexec is triggered instead of a reboot. The kernel performs its own shutdown, quiesces hardware, then executes the new kernel.

concerning «as in shutdown»:

it’s only almost as in shutdown: all processes including pid 1 are wiped, of course, since even the kernel is wiped out and reloaded. But some firmware stuff (EFI variables) can hang around, because kexec is not a full reboot.

If you are not (compiling and) testing one kernel after the other, kexec is of limited use. It is «experimental».

But it is cool to try out: it’s «between» a reboot and a runlevel change (whatever that means in the days of systemd, or in fact, since always, in linux). After a few successful tries it crashed, so I let it be. (But nothing happened.)

I just read the latest comment:

The idea was to at least unmount existing file systems etc.

But that is the same problem as with ctrl-alt-del, especially without systemd. Sorry for being sceptic, but the shutdown process with sysvinit really is a bit tricky already (with systemd also). A «controlled shutdown» together with kexec (or ctrl-alt-del) seems a bit paradoxal to me.

Читайте также:  Шифрование linux весь раздел

I always do some «etc.» before I «pull the plug» on my system: close/save files, close firefox, check the tmpfs mount, unmount partitions. and then: reboot , poweroff , halt , shutdown , init 6, init 0 , ctrl-alt-del or even ON/OFF button for five seconds. I don’t want kexec as another source of potential problems.

In fact systemd integrates kexec ( man systemctl ). I regret calling the idea «a bit paradoxal», but maintain my point: why not choose (or manually enter) that kernel command line a few seconds later at the bootloader’s command line, after a normal reboot?

Источник

Active kernel releases

There are several main categories into which kernel releases may fall:

Prepatch Prepatch or «RC» kernels are mainline kernel pre-releases that are mostly aimed at other kernel developers and Linux enthusiasts. They must be compiled from source and usually contain new features that must be tested before they can be put into a stable release. Prepatch kernels are maintained and released by Linus Torvalds. Mainline Mainline tree is maintained by Linus Torvalds. It’s the tree where all new features are introduced and where all the exciting new development happens. New mainline kernels are released every 9-10 weeks. Stable After each mainline kernel is released, it is considered «stable.» Any bug fixes for a stable kernel are backported from the mainline tree and applied by a designated stable kernel maintainer. There are usually only a few bugfix kernel releases until next mainline kernel becomes available — unless it is designated a «longterm maintenance kernel.» Stable kernel updates are released on as-needed basis, usually once a week. Longterm There are usually several «longterm maintenance» kernel releases provided for the purposes of backporting bugfixes for older kernel trees. Only important bugfixes are applied to such kernels and they don’t usually see very frequent releases, especially for older trees.

Longterm release kernels
Version Maintainer Released Projected EOL
6.1 Greg Kroah-Hartman & Sasha Levin 2022-12-11 Dec, 2026
5.15 Greg Kroah-Hartman & Sasha Levin 2021-10-31 Oct, 2026
5.10 Greg Kroah-Hartman & Sasha Levin 2020-12-13 Dec, 2026
5.4 Greg Kroah-Hartman & Sasha Levin 2019-11-24 Dec, 2025
4.19 Greg Kroah-Hartman & Sasha Levin 2018-10-22 Dec, 2024
4.14 Greg Kroah-Hartman & Sasha Levin 2017-11-12 Jan, 2024

Distribution kernels

Many Linux distributions provide their own «longterm maintenance» kernels that may or may not be based on those maintained by kernel developers. These kernel releases are not hosted at kernel.org and kernel developers can provide no support for them.

It is easy to tell if you are running a distribution kernel. Unless you downloaded, compiled and installed your own version of kernel from kernel.org, you are running a distribution kernel. To find out the version of your kernel, run uname -r :

# uname -r 5.6.19-300.fc32.x86_64

If you see anything at all after the dash, you are running a distribution kernel. Please use the support channels offered by your distribution vendor to obtain kernel support.

Releases FAQ

Here are some questions we routinely receive about kernel release versions. See also the main «FAQ» section for some other topics.

When is the next mainline kernel version going to be released?

Linux kernel follows a simple release cadence:

  • after each mainline release, there is a 2-week «merge window» period during which new major features are introduced into the kernel
  • after the merge window closes, there is a 7-week bugfix and stabilization period with weekly «release candidate» snapshots
  • rc7 is usually the last release candidate, though occasionally there may be additional rc8+ releases if that is deemed necessary
Читайте также:  Retro gaming on linux

So, to find the approximate date of the next mainline kernel release, take the date of the previous mainline release and add 9-10 weeks.

What is the next longterm release going to be?

Longterm kernels are picked based on various factors — major new features, popular commercial distribution needs, device manufacturer demand, maintainer workload and availability, etc. You can roughly estimate when the new longterm version will become available based on how much time has elapsed since the last longterm version was chosen.

Why are some longterm versions supported longer than others?

The «projected EOL» dates are not set in stone. Each new longterm kernel usually starts with only a 2-year projected EOL that can be extended further if there is enough interest from the industry at large to help support it for a longer period of time.

Does the major version number (4.x vs 5.x) mean anything?

No. The major version number is incremented when the number after the dot starts looking «too big.» There is literally no other reason.

Does the odd-even number still mean anything?

A long time ago Linux used a system where odd numbers after the first dot indicated pre-release, development kernels (e.g. 2.1, 2.3, 2.5). This scheme was abandoned after the release of kernel 2.6 and these days pre-release kernels are indicated with «-rc».

Other resources

Social

This site is operated by the Linux Kernel Organization, Inc., a 501(c)3 nonprofit corporation, with support from the following sponsors.

Источник

Different Types of Kernel for Arch Linux and How to Use Them

One of the reasons why people use Arch Linux is that it is a bleeding edge rolling release. You get most software and the Linux kernel before users of other distributions.

But this doesn’t mean that you have to always use the latest mainline kernel. There are several kernel options available, and I am going to show you switch kernels in Arch Linux.

Different types of kernels available for Arch Linux

Arch Linux Kernels

First, let me tell you about different kinds of Linux kernels available to you as an Arch user.

Mainline kernel (package name: linux)

This is the latest stable Linux kernel. Most people use this kernel for the reason that it is the latest available kernel version.

LTS kernel (package name: linux-lts)

The linux-lts package gives you the latest long term support Linux kernel. There is no predefined life cycle for a LTS kernel but you can be assured to enjoy the same kernel version for a much longer period.

Kernel patches normally don’t break anything but a breakage is not impossible to happen. If your hardware isn’t the newest the market can offer, you can enjoy the bleeding edge software with increased stability by installing the slightly older LTS kernel.

Hardened kernel (package name: linux-hardened)

For the security concerned users, there is a hardened version of the latest stable kernel. Do note that several packages will not work when using this kernel.

Performance-tuned kernel (package name: linux-zen)

If you want to get the most out of your system, you can use the “Zen” kernel which is basically a fork from the latest kernel and provides tunes at the cost of throughput and power usage.

How to switch kernels on Arch Linux

Now that you are aware of various kernel choices, let’s see how to change kernel in Arch Linux.

  1. Install the Linux kernel of your choice
  2. Tweak the grub config file to add the newly installed kernel
Читайте также:  Linux display system information

Don’t worry, I am going to show you the steps in details.

Check the kernel version in arch Linux using this command:

If it shows only a number

To switch kernels on Arch, can be simply done by installing the kernel that you want to use and tweak the grub configuration file.

Step 1: Install the kernel of your choice

You can use the pacman command to install the Linux kernel of your choice. You just need to know the package name.

You may also install more than one type of Linux kernels at the same time in the system. You can choose which kernel to use from the grub menu.

For the latest stable kernel:

For the latest LTS kernel:

For latest stable kernel with hardened patches:

sudo pacman -S linux-hardened

Step 2: Tweak the grub configuration file to add more kernel options

By default, Arch Linux uses the latest kernel version as the default. Additional kernel versions are available from under the advanced options:

Arch Linux Grub

However, I prefer to do things a bit different and a bit better (in my opinion). Here’s what I do:

  • Disable grub submenu so that all the available kernel versions are shown on the main screen (instead of under Advanced Options).
  • Configure grub to recall the last kernel entry you booted and use it as the default entry to boot from the next time.

Sounds a lot better already, does it not?

To do this you need to edit the GRUB configuration file. All the configuration files in general are located at the /etc directory.

Open your terminal and edit the config file in your favorite terminal-based text editor. I am using Nano editor:

Grub Config Arch

As you may notice I have changed the value that I mentioned but I have added another 2 lines so the final result should look like this:

GRUB_DISABLE_SUBMENU=y GRUB_DEFAULT=saved GRUB_SAVEDEFAULT=true

The first and optional line is used to disable the GRUB submenu. I find it easier when instantly I can see all my kernels on the GRUB screen without having to enter the advanced options submenu.

The second line is used to save the last kernel entry.

Lastly you need to ensure that GRUB will use as a default the last saved entry.

Save the configuration file and exit.

Step 3: Re-generate the GRUB configuration file

To make the changes effective you need to re-generate the configuration file. To do so, open the terminal and run the following command:

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

If it looks familiar to you, you have used this command during the Arch Linux installation process.

Reboot your Linux system and select the kernel you want to use!

Multiple Kernels Arch Linux

Conclusion

You don’t need to worry about updating the kernel in Arch Linux. If there are updates to your choice of kernel, it will be installed with the system updates. I guess you already know how to update Arch Linux system.

Switching kernels on Arch Linux is an easy to do process with several options tailored to your needs. I find the above method the safest and easiest as you don’t need to remove a kernel from your system. If you choose to run the latest kernel, it’s good to have installed the LTS kernel in case of a kernel panic.

I hope you liked this Arch Linux tip. Stay subscribed to It’s FOSS for more tips and tutorials.

Источник

Оцените статью
Adblock
detector