this post was submitted on 02 Oct 2023
21 points (100.0% liked)

Arch Linux

7787 readers
31 users here now

The beloved lightweight distro

founded 4 years ago
MODERATORS
 

Hello mates,

As you know, in arch Linux the kernel is updated frequently but, is mandatory or good practice reboot any time the kernel is updated?

Edit: Thank you guys for your replies

all 14 comments
sorted by: hot top controversial new old
[–] Rustmilian 9 points 1 year ago* (last edited 1 year ago) (1 children)

The kernel is loaded into RAM so it shouldn't cause issues unless for some reason it gets unloaded. The updated kernel is written to disc first then loaded into RAM apon a reboot. Other parts of the system can cause issues when updated tho, like the audio stack as it gets unloaded whenever it's not in use.

[–] [email protected] 8 points 1 year ago* (last edited 1 year ago) (3 children)

Except for kernel modules - which are stored on disk and often loaded on demand. Though most distros keep around the old kernel and kernel modules to avoid issues. You can still get issues on distro such as Arch which replace the kernel and modules on an upgrade - though there is the kernel-modules-hook package with pacman hooks to keep the old modules around until the next reboot to fix this.

If you don't have the kernel-modules-hook package installed on Arch you really should reboot shortly after an upgrade to the kernel or else new devices you plug in might not function until you do (typically USB as those tend to be what you hotplug the most).

[–] Rustmilian 5 points 1 year ago* (last edited 1 year ago)

To further clarify : On Arch Linux, the new kernel and its corresponding modules are installed on the system, but they are not immediately loaded into RAM. Until you reboot your system, the old kernel and its associated modules remain in memory. Once you restart your system, the new kernel is loaded into RAM, and the old kernel and its modules are unloaded from memory. From that point onward, the system uses the new kernel and its modules.

If the modules from the old Kernel weren't loaded previously then they won't be loadable into RAM when you say pluggin a USB device, but USB devices that were already plugged in will continue to work because the module was already loaded into RAM from the old kernel.
You'd have to unplug the USB device and wait for the system to unload the module from memory automatically(which doesn't happen often because it's in best interest for the system to keep the module around in case it's needed again) Or unload it yourself for problems to occurred.
By unplugging and replugging the same USB device during this time, it'll still work as the model wasn't immediately unloaded.

The package you shared makes a copy of the old kernel modules on disc to a different location prior to the Kernel update process replacement of the old Kernel as to load them if they're not already available in RAM.

[–] xhenon 1 points 1 year ago (1 children)

First time I hear about kernel-modules-hook. For sure I'm going to try.

Thanks for the recommendation

[–] kidpixo 1 points 1 year ago
[–] [email protected] 6 points 1 year ago

An update is only truly done once no remnants of the old code is in memory. Code can stick around in the form of binaries (restart the binaries), libraries (restart all binaries that use this library) and the kernel (reboot or use kexec).

One very simple way to make sure no old code sticks around is to reboot:-)

[–] [email protected] 4 points 1 year ago (1 children)

Good practice, you won't see the update until you reboot and I suppose it could cause problems if other packages were updated at the same time and rely on the updated kernel

[–] [email protected] 3 points 1 year ago (2 children)

I've heard about Linux servers running for years. But surely they change kernel without a reboot? More of a curious question.

[–] [email protected] 8 points 1 year ago (1 children)

there is live kernel patching, most distros (like Arch Linux) however don't set this up by default
there is also the possibility that one live patch don't work properly
the only reliable way currently to load the full new kernel is via reboot

the real way for server however is to not rely on one single server but have a redundant amount which you can reboot one at a time

[–] [email protected] 3 points 1 year ago

Last time I tried replacing the kernel without a reboot it still reset the uptime. And it had about as long of a pause when replacing the kernel as a reboot had. So I don't see the benefit.

[–] bitwaba 1 points 1 year ago

You don't need to change kernel if the one you have works fine.

For gaming PCs you're often running hardware that gets improved in the kernel often. For servers, as long as you're not trying to squeeze every once of performance out of it you can get by with way behind bleeding edge kernels.

One of the easiest attack vectors to secure on a kernel is compiling all your modules directly into the kernel and disabling loadable kernel modules.

Once you've got a kernel that has all the bells and whistles you need compiled into it, it's relatively mature enough to have it's bugs worked out (like an LTS kernel that's been out for a month or so), and you've applied proper system and kernel hardening configs, that server can run undisturbed for quite a while.

[–] node815 3 points 1 year ago

I've had issues after updating the kernel and ignoring it. I WFH and all of a sudden my sound would stop working or something else may stop. I found it much easier just to reboot after.