清除 OpenVZ 容器中不需要的内核映像

清除 OpenVZ 容器中不需要的内核映像

我知道类似的问题已经被问过无数次了,但到目前为止我还没有找到适合我的情况的答案。

我在 OpenVZ 容器内运行 32 位 14.04 服务器,它提供以下内核:

$ uname -r
2.6.32-042stab116.2

不确定它是如何/为何开始的,但apt一直尝试(并失败)升级到 3.13 系列,最终结果是这样的:

$ dpkg -l |grep linux
ii  libselinux1:i386                     2.2.2-1ubuntu0.1                     i386         SELinux runtime shared libraries
ii  linux-firmware                       1.127.22                             all          Firmware for Linux kernel drivers
ii  linux-headers-3.13.0-100             3.13.0-100.147                       all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-100-generic     3.13.0-100.147                       i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-101             3.13.0-101.148                       all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-101-generic     3.13.0-101.148                       i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-91              3.13.0-91.138                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-91-generic      3.13.0-91.138                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-92              3.13.0-92.139                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-92-generic      3.13.0-92.139                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-93              3.13.0-93.140                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-93-generic      3.13.0-93.140                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-96              3.13.0-96.143                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-96-generic      3.13.0-96.143                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
iF  linux-image-3.13.0-92-generic        3.13.0-92.139                        i386         Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iF  linux-image-3.13.0-93-generic        3.13.0-93.140                        i386         Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iF  linux-image-3.13.0-96-generic        3.13.0-96.143                        i386         Linux kernel image for version 3.13.0 on 32 bit x86 SMP
rH  linux-image-extra-3.13.0-100-generic 3.13.0-100.147                       i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
rH  linux-image-extra-3.13.0-101-generic 3.13.0-101.148                       i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
rH  linux-image-extra-3.13.0-92-generic  3.13.0-92.139                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iU  linux-image-extra-3.13.0-93-generic  3.13.0-93.140                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iU  linux-image-extra-3.13.0-96-generic  3.13.0-96.143                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
ii  linux-libc-dev:i386                  3.13.0-101.148                       i386         Linux Kernel Headers for development
ii  syslinux                             3:4.05+dfsg-6+deb8u1                 i386         collection of boot loaders
ii  syslinux-common                      3:4.05+dfsg-6+deb8u1                 all          collection of boot loaders (common files)
ii  util-linux                           2.20.1-5.1ubuntu20.7                 i386         Miscellaneous system utilities

我的理解是,内核完全由 OpenVZ 主机负责,并且有人建议我干脆把这些图片全部删掉,系统无论如何都会忽略这些软件包。但是,我尝试完全删除这些软件包的所有尝试都失败了,并出现了各种错误消息。

当我尝试明确清除所有不需要的 Linux* 软件包时,发生了以下情况

使用 aptitude 代替 apt-get删除了一些软件包并将所有剩余图像的状态更改为pH,但并未解决问题:

$ dpkg -l |grep linux
ii  libselinux1:i386                     2.2.2-1ubuntu0.1                     i386         SELinux runtime shared libraries
ii  linux-firmware                       1.127.22                             all          Firmware for Linux kernel drivers
ii  linux-headers-3.13.0-100             3.13.0-100.147                       all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-100-generic     3.13.0-100.147                       i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-91              3.13.0-91.138                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-91-generic      3.13.0-91.138                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-92              3.13.0-92.139                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-92-generic      3.13.0-92.139                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-93              3.13.0-93.140                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-93-generic      3.13.0-93.140                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-96              3.13.0-96.143                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-96-generic      3.13.0-96.143                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
pH  linux-image-extra-3.13.0-100-generic 3.13.0-100.147                       i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
pH  linux-image-extra-3.13.0-101-generic 3.13.0-101.148                       i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
pH  linux-image-extra-3.13.0-92-generic  3.13.0-92.139                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
pH  linux-image-extra-3.13.0-93-generic  3.13.0-93.140                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
pH  linux-image-extra-3.13.0-96-generic  3.13.0-96.143                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
ii  linux-libc-dev:i386                  3.13.0-101.148                       i386         Linux Kernel Headers for development
ii  syslinux                             3:4.05+dfsg-6+deb8u1                 i386         collection of boot loaders
ii  syslinux-common                      3:4.05+dfsg-6+deb8u1                 all          collection of boot loaders (common files)
ii  util-linux                           2.20.1-5.1ubuntu20.7                 i386         Miscellaneous system utilities

我再次对上面的 3.13 软件包列表运行 aptitude,这次所有标题都消失了,但是“额外”的图像仍然存在。

$ dpkg -l |grep linux
pH  linux-image-extra-3.13.0-100-generic 3.13.0-100.147                       i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
pH  linux-image-extra-3.13.0-101-generic 3.13.0-101.148                       i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
pH  linux-image-extra-3.13.0-92-generic  3.13.0-92.139                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
pH  linux-image-extra-3.13.0-93-generic  3.13.0-93.140                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
pH  linux-image-extra-3.13.0-96-generic  3.13.0-96.143                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
[...]

我给了再试一次这是输出。看起来,为了清除这些额外的图像(具有明显未满足的依赖关系,因为相应的图像已经消失),aptitude缺少所需的一些文件:

depmod: FATAL: could not load /boot/System.map-3.13.0-100-generic: No such file or directory

相关内容