Sometimes dnf needs-restarting will list the kernel as the reason for needing to restart. Others times it does not list it. Here is an example from today after a dnf update --refresh. Reproducible: Always Steps to Reproduce: 1. dnf update --fresh 2. dnf needs-restarting Actual Results: kernel is not listed in the output for dnf needs-restarting Sometimes the kernel is listed. I have not figured out a pattern to this yet. Expected Results: List the kernel as reason to restart. $ sudo dnf needs-restarting $ sudo dnf needs-restarting -s; echo $? 0 $ uname -r 6.4.12-200.fc38.x86_64 $ rpm -q kernel kernel-6.4.11-200.fc38.x86_64 kernel-6.4.12-200.fc38.x86_64 kernel-6.4.13-200.fc38.x86_64 $ sudo grubby --default-kernel /boot/vmlinuz-6.4.13-200.fc38.x86_64
Can you also try `sudo dnf needs-restarting -r`? By default (without this switch) the plugin checks for running processes, that should be restarted. With -r switch it checks, whether reboot is required (or in other words whether "computer needs restarting").
I have been using -r and sometimes it does not report the kernel as a reason to reboot. I'll try and collect data when this reproduces for me.
I am attaching the full log I have of updating my system that shows that the needs-restart did not work. A new kernel was installed and that means I need a reboot. 09:35:25 localhost Run command: sudo dnf needs-restarting --services --reboothint localhost: No core libraries or services have been updated since boot-up. localhost: Reboot should not be necessary. The full log is attached as update-linux.log - it is the log from a script I use to run all the steps of an update. The script added the timestamps and localhost:.
Created attachment 1991050 [details] log of updating system with output of dnf commands
Thanks, the issue seems to be valid. We've received several bugreports regarding the `needs-restarting -r` functionality lately, see: https://bugzilla.redhat.com/show_bug.cgi?id=2137935 https://bugzilla.redhat.com/show_bug.cgi?id=1914251 https://bugzilla.redhat.com/show_bug.cgi?id=1960437 It looks like we have difficulty to correctly calculate the boot time and that the current process is still not good enough. Can you describe your environment - bare metal / virtual machine / container? This is basically the algorithm used by needs-restarting to determine the boot time. Can you save this snippet to a file and run it using python and share the results? ---------------------- import os import time print("current time:", int(time.time())) proc_1_boot_time = int(os.stat('/proc/1').st_mtime) print("/proc/1 boot time:", proc_1_boot_time) if os.path.isfile('/proc/uptime'): with open('/proc/uptime', 'rb') as f: uptime = f.readline().strip().split()[0].strip() proc_uptime_boot_time = int(time.time() - float(uptime)) print("/proc/uptime boot time:", proc_uptime_boot_time) --------------------------
Result of test python code: $ uptime -s 2023-10-02 11:18:17 $ py3 a.py current time: 1696242072 /proc/1 boot time: 1696245497 /proc/uptime boot time: 1696241896 $ py3 a.py current time: 1696242079 /proc/1 boot time: 1696245497 /proc/uptime boot time: 1696241896 $ timedatectl Local time: Mon 2023-10-02 11:21:37 BST Universal time: Mon 2023-10-02 10:21:37 UTC RTC time: Mon 2023-10-02 11:21:38 Time zone: Europe/London (BST, +0100) System clock synchronized: yes NTP service: active RTC in local TZ: yes Warning: The system is configured to read the RTC time in the local time zone. This mode cannot be fully supported. It will create various problems with time zone changes and daylight saving time adjustments. The RTC time is never updated, it relies on external facilities to maintain it. If at all possible, use RTC in UTC by calling 'timedatectl set-local-rtc 0'. --- environment details $ inxi -Fx System: Host: <redacted> Kernel: 6.5.5-200.fc38.x86_64 arch: x86_64 bits: 64 compiler: gcc v: 2.39-9.fc38 Console: pty pts/0 Distro: Fedora release 38 (Thirty Eight) Machine: Type: Desktop System: ASUS product: N/A v: N/A serial: <superuser required> Mobo: ASUSTeK model: PRIME Z690-P WIFI v: Rev 1.xx serial: <superuser required> UEFI: American Megatrends v: 1620 date: 08/12/2022 CPU: Info: 12-core (8-mt/4-st) model: 12th Gen Intel Core i7-12700K bits: 64 type: MST AMCP arch: Alder Lake rev: 2 cache: L1: 1024 KiB L2: 12 MiB L3: 25 MiB Speed (MHz): avg: 794 high: 800 min/max: 800/4900:5000:3800 cores: 1: 800 2: 800 3: 800 4: 800 5: 800 6: 800 7: 800 8: 800 9: 800 10: 800 11: 690 12: 800 13: 800 14: 800 15: 800 16: 800 17: 800 18: 800 19: 800 20: 800 bogomips: 144383 Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx Graphics: Device-1: NVIDIA GA106 [GeForce RTX 3060 Lite Hash Rate] vendor: eVga.com. driver: nvidia v: 535.113.01 arch: Ampere bus-ID: 06:00.0 Display: server: X.org v: 1.20.14 with: Xwayland v: 22.1.9 driver: X: loaded: nvidia unloaded: fbdev,modesetting,nouveau,vesa gpu: nvidia,nvidia-nvswitch tty: 120x36 resolution: 3840x2160 API: OpenGL Message: GL data unavailable in console. Try -G --display Audio: Device-1: Intel Alder Lake-S HD Audio vendor: ASUSTeK driver: snd_hda_intel v: kernel bus-ID: 00:1f.3 Device-2: NVIDIA GA106 High Definition Audio vendor: eVga.com. driver: snd_hda_intel v: kernel bus-ID: 06:00.1 API: ALSA v: k6.5.5-200.fc38.x86_64 status: kernel-api Server-1: PipeWire v: 0.3.80 status: off Network: Device-1: Intel Alder Lake-S PCH CNVi WiFi driver: iwlwifi v: kernel bus-ID: 00:14.3 IF: wlo1 state: down mac: 6c:94:66:4a:ee:53 Device-2: Realtek RTL8125 2.5GbE vendor: ASUSTeK driver: r8169 v: kernel port: 5000 bus-ID: 05:00.0 IF: enp5s0 state: up speed: 1000 Mbps duplex: full mac: 50:eb:f6:76:d2:36 IF-ID-1: bridge1 state: up speed: 1000 Mbps duplex: unknown mac: 96:96:bc:ec:35:2f Bluetooth: Device-1: Intel AX201 Bluetooth driver: btusb v: 0.8 type: USB bus-ID: 1-14:7 Report: btmgmt ID: hci0 rfk-id: 0 state: up address: 6C:94:66:4A:EE:57 bt-v: 5.2 lmp-v: 11 RAID: Hardware-1: Intel Volume Management Device NVMe RAID Controller driver: vmd v: 0.6 bus-ID: 00:0e.0 Drives: Local Storage: total: 2.73 TiB used: 519.64 GiB (18.6%) ID-1: /dev/nvme0n1 vendor: Samsung model: SSD 980 1TB size: 931.51 GiB temp: 35.9 C ID-2: /dev/nvme1n1 vendor: Samsung model: SSD 980 PRO 2TB size: 1.82 TiB temp: 38.9 C Partition: ID-1: / size: 1.82 TiB used: 519.39 GiB (27.9%) fs: btrfs dev: /dev/dm-0 mapped: luks-904db66b-db23-4719-bbf6-fb596c23d831 ID-2: /boot size: 973.4 MiB used: 249.1 MiB (25.6%) fs: ext4 dev: /dev/nvme1n1p2 ID-3: /boot/efi size: 598.8 MiB used: 14 MiB (2.3%) fs: vfat dev: /dev/nvme1n1p1 ID-4: /home size: 1.82 TiB used: 519.39 GiB (27.9%) fs: btrfs dev: /dev/dm-0 mapped: luks-904db66b-db23-4719-bbf6-fb596c23d831 Swap: ID-1: swap-1 type: zram size: 8 GiB used: 0 KiB (0.0%) dev: /dev/zram0 Sensors: System Temperatures: cpu: 32.0 C mobo: 33.0 C gpu: nvidia temp: 44 C Fan Speeds (rpm): fan-1: 0 fan-2: 475 fan-3: 0 fan-4: 458 fan-5: 430 fan-6: 0 Info: Processes: 417 Uptime: 1m Memory: total: 32 GiB available: 31.04 GiB used: 1.37 GiB (4.4%) Init: systemd target: graphical (5) Compilers: gcc: 13.2.1 Packages: 8 note: see --rpm Shell: Bash v: 5.2.15 inxi: 3.3.29
The logic I use would have used to see if a reboot is needed for a kernel install is: Is the running kernel different from the kernel configured in grub for the next boot? I curious how knowing the boot time helps with figuring out that a reboot is needed becuase of a new kernel.
Thank you. I think in this case the root-cause is using installation time in the kernel check in combination with RTC being set in the local time zone. For `needs-restarting -r` there is a hard-coded list of packages (kernel is one of them) and the plugin only checks whether the installation time of these packages is later than the boot time. If so, it prints "Reboot is required". But your approach to checking kernel version makes sense.
Fedora Linux 38 entered end-of-life (EOL) status on 2024-05-21. Fedora Linux 38 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora Linux please feel free to reopen this bug against that version. Note that the version field may be hidden. Click the "Show advanced fields" button if you do not see the version field. If you are unable to reopen this bug, please file a new report against an active release. Thank you for reporting this bug and we are sorry it could not be fixed.