我的内核什么时候更新并安装

我的内核什么时候更新并安装

这个问题与避免在更新内核时丢失内核 linux-modules-extra-XX-generic

更新内核的过程需要几个步骤。我的问题是:

  1. 在所有可能的更新内核的方法中(例如,https://ostechnix.com/different-ways-to-update-linux-kernel-for-ubuntu/以及可能未列出的其他更新),我如何知道我的系统使用了哪个更新?我实际上是想确认它是否来自自动更新(unattended-upgrades否则呢?)
  2. 我如何知道导致新内核成为最新版本的每个步骤是何时发生的(安装内核包、重启等)?我的意思是进行一些“取证”。

答案1

我列出了我可以收集的信息以及如何收集。以下是详细信息。

  1. 每个包是如何安装的(哪种方法,自动/手动)。
    使用apt list --installed | egrep '^linux' | grep $(uname -r)
  2. 每个软件包的安装时间和方式。
    使用grep $(uname -r)on /var/log/apt/history.log*(我复制并sudo gunzip复制到其他地方以保持干净)。
  3. 安装每个包时。
    使用grep $(uname -r)on /var/log/dpkg.log*
  4. PC 重启的时间。我不知道这些信息是否完整(例如,是否涵盖断电关机等情况)。
    打开。这给出了重启的日期/时间,以及数字 [ 0.18????] ,我不知道它们是什么意思。 grep reboot打开。这只给出了 中的最后一次重启(每个文件一次,所以我猜每个文件都是从重启时开始的),以及数字 [ 0.18????]。 打开。这给出了比 少几次的重启,以及日期/时间。 打开没有提供更多信息。/var/log/kern.log*
    grep reboot/var/log/dmesg*kern.log*
    grep reboot/var/log/syslog*dmesg*
    grep shutdown/var/log/syslog*

每个包是如何安装的(哪种方法,自动/手动)

apt list --installed | egrep '^linux' | grep $(uname -r)收到了 4 个包裹:

linux-image-5.4.0-42-generic/focal-updates,focal-security,now 5.4.0-42.46 amd64 [installed,automatic]
linux-modules-5.4.0-42-generic/focal-updates,focal-security,now 5.4.0-42.46 amd64 [installed]
linux-modules-extra-5.4.0-42-generic/focal-updates,focal-security,now 5.4.0-42.46 amd64 [installed]
linux-modules-nvidia-390-5.4.0-42-generic/focal-updates,focal-security,now 5.4.0-42.46 amd64 [installed,automatic]

这表明内核已自动更新。


每个软件包的安装时间和方式

抓取/var/log/apt/history.log*

$ grep -B 4 -A 4 -nH $(uname -r) /var/log/apt/history.log
...
/var/log/apt/history.log-67-Start-Date: 2020-08-06  18:34:47
/var/log/apt/history.log:68:Commandline: apt-get install linux-modules-extra-5.4.0-42-generic
/var/log/apt/history.log-69-Requested-By: user1 (1000)
/var/log/apt/history.log:70:Install: linux-modules-extra-5.4.0-42-generic:amd64 (5.4.0-42.46)
/var/log/apt/history.log-71-End-Date: 2020-08-06  18:35:41
...
$ grep -B 4 -A 4 -nH $(uname -r) history.log.1
...
history.log.1-208-Start-Date: 2020-07-22  06:26:33
history.log.1-209-Commandline: /usr/bin/unattended-upgrade
history.log.1:210:Install: linux-modules-5.4.0-42-generic:amd64 (5.4.0-42.46, automatic), linux-modules-nvidia-390-5.4.0-42-generic:amd64 (5.4.0-42.46, automatic), linux-image-5.4.0-42-generic:amd64 (5.4.0-42.46, automatic)
history.log.1-211-Upgrade: linux-modules-nvidia-390-generic-hwe-20.04:amd64 (5.4.0-40.44, 5.4.0-42.46)
history.log.1-212-End-Date: 2020-07-22  06:27:05
...
$ grep -B 4 -A 4 -nH $(uname -r) history.log.2

安装每个软件包时

抓取/var/log/dpkg.log*

$ grep -B 6 -A 5 -nH $(uname -r) /var/log/dpkg.log
...
/var/log/dpkg.log-318-2020-08-06 18:34:48 startup archives unpack
/var/log/dpkg.log:319:2020-08-06 18:34:54 install linux-modules-extra-5.4.0-42-generic:amd64 <none> 5.4.0-42.46
/var/log/dpkg.log:320:2020-08-06 18:34:54 status half-installed linux-modules-extra-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log:321:2020-08-06 18:35:00 status unpacked linux-modules-extra-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log-322-2020-08-06 18:35:00 startup packages configure
/var/log/dpkg.log:323:2020-08-06 18:35:00 configure linux-modules-extra-5.4.0-42-generic:amd64 5.4.0-42.46 <none>
/var/log/dpkg.log:324:2020-08-06 18:35:00 status unpacked linux-modules-extra-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log:325:2020-08-06 18:35:01 status half-configured linux-modules-extra-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log:326:2020-08-06 18:35:05 status installed linux-modules-extra-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log:327:2020-08-06 18:35:05 status triggers-pending linux-image-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log:328:2020-08-06 18:35:05 trigproc linux-image-5.4.0-42-generic:amd64 5.4.0-42.46 <none>
/var/log/dpkg.log:329:2020-08-06 18:35:05 status half-configured linux-image-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log:330:2020-08-06 18:35:41 status installed linux-image-5.4.0-42-generic:amd64 5.4.0-42.46

$ grep -B 6 -A 5 -nH $(uname -r) /var/log/dpkg.log.1
...
/var/log/dpkg.log.1:3123:2020-07-22 06:26:33 install linux-modules-5.4.0-42-generic:amd64 <none> 5.4.0-42.46
/var/log/dpkg.log.1:3124:2020-07-22 06:26:33 status half-installed linux-modules-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3125:2020-07-22 06:26:36 status unpacked linux-modules-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3126:2020-07-22 06:26:36 install linux-image-5.4.0-42-generic:amd64 <none> 5.4.0-42.46
/var/log/dpkg.log.1:3127:2020-07-22 06:26:36 status half-installed linux-image-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3128:2020-07-22 06:26:37 status unpacked linux-image-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3129:2020-07-22 06:26:38 install linux-modules-nvidia-390-5.4.0-42-generic:amd64 <none> 5.4.0-42.46
/var/log/dpkg.log.1:3130:2020-07-22 06:26:38 status half-installed linux-modules-nvidia-390-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3131:2020-07-22 06:26:39 status unpacked linux-modules-nvidia-390-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1-3132-2020-07-22 06:26:39 upgrade linux-modules-nvidia-390-generic-hwe-20.04:amd64 5.4.0-40.44 5.4.0-42.46
/var/log/dpkg.log.1-3133-2020-07-22 06:26:39 status half-configured linux-modules-nvidia-390-generic-hwe-20.04:amd64 5.4.0-40.44
/var/log/dpkg.log.1-3134-2020-07-22 06:26:39 status unpacked linux-modules-nvidia-390-generic-hwe-20.04:amd64 5.4.0-40.44
/var/log/dpkg.log.1-3135-2020-07-22 06:26:39 status half-installed linux-modules-nvidia-390-generic-hwe-20.04:amd64 5.4.0-40.44
/var/log/dpkg.log.1-3136-2020-07-22 06:26:39 status unpacked linux-modules-nvidia-390-generic-hwe-20.04:amd64 5.4.0-42.46
/var/log/dpkg.log.1-3137-2020-07-22 06:26:39 startup packages configure
/var/log/dpkg.log.1:3138:2020-07-22 06:26:39 configure linux-modules-5.4.0-42-generic:amd64 5.4.0-42.46 <none>
/var/log/dpkg.log.1:3139:2020-07-22 06:26:39 status unpacked linux-modules-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3140:2020-07-22 06:26:39 status half-configured linux-modules-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3141:2020-07-22 06:26:40 status installed linux-modules-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3142:2020-07-22 06:26:40 configure linux-image-5.4.0-42-generic:amd64 5.4.0-42.46 <none>
/var/log/dpkg.log.1:3143:2020-07-22 06:26:40 status unpacked linux-image-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3144:2020-07-22 06:26:40 status half-configured linux-image-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3145:2020-07-22 06:26:41 status installed linux-image-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3146:2020-07-22 06:26:41 status triggers-pending linux-image-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3147:2020-07-22 06:26:41 configure linux-modules-nvidia-390-5.4.0-42-generic:amd64 5.4.0-42.46 <none>
/var/log/dpkg.log.1:3148:2020-07-22 06:26:41 status unpacked linux-modules-nvidia-390-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3149:2020-07-22 06:26:41 status half-configured linux-modules-nvidia-390-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3150:2020-07-22 06:26:43 status installed linux-modules-nvidia-390-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1-3151-2020-07-22 06:26:43 configure linux-modules-nvidia-390-generic-hwe-20.04:amd64 5.4.0-42.46 <none>
/var/log/dpkg.log.1-3152-2020-07-22 06:26:43 status unpacked linux-modules-nvidia-390-generic-hwe-20.04:amd64 5.4.0-42.46
/var/log/dpkg.log.1-3153-2020-07-22 06:26:43 status half-configured linux-modules-nvidia-390-generic-hwe-20.04:amd64 5.4.0-42.46
/var/log/dpkg.log.1-3154-2020-07-22 06:26:43 status installed linux-modules-nvidia-390-generic-hwe-20.04:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3155:2020-07-22 06:26:43 trigproc linux-image-5.4.0-42-generic:amd64 5.4.0-42.46 <none>
/var/log/dpkg.log.1:3156:2020-07-22 06:26:43 status half-configured linux-image-5.4.0-42-generic:amd64 5.4.0-42.46
/var/log/dpkg.log.1:3157:2020-07-22 06:27:04 status installed linux-image-5.4.0-42-generic:amd64 5.4.0-42.46
...

相关内容