How to prevent apt update the Linux kernel

root@debian:~# sudo dpkg --get-selections | grep linux
console-setup-linux                             install
fonts-linuxlibertine                            install
libselinux1:amd64                               install
linux-base                                      install
linux-image-4.9.0-8-amd64                       install
linux-image-4.9.0-9-amd64                       install
linux-image-amd64                               install
util-linux                                      install


root@debian:~# dpkg -l|grep linux-image | awk '{print $2}'
linux-image-4.9.0-8-amd64
linux-image-4.9.0-9-amd64
linux-image-amd64


sudo apt-mark hold linux-image-4.9.0-8-amd64
sudo apt-mark hold linux-image-4.9.0-9-amd64
sudo apt-mark hold linux-image-amd64
 




 

Generally when running apt upgrade it will automatically update the Linux kernel, but sometimes circumstances incompatible driver will appear after updating the kernel.
We can use the following command to downgrade the kernel:

sudo dpkg --get-selections | grep linux # view the installed kernel
sudo apt remove linux-image-x.xx.x -xx-generic # delete the new kernel
sudo apt install linux-image-x.xx.x -xx -generic # install the original kernel
can also use the following command to stop apt update the kernel:

APT-Mark the HOLD Linux sudo-Image-the Generic Linux-headers-the Generic
sudo APT Update
sudo APT upgrade
, use the following command to unblock:

sudo apt-mark unhold linux-image-generic linux-headers-generic
sudo apt update

--------------------- 
Author: weixin_33912453 
Source: CSDN 
Original: https: //blog.csdn.net/weixin_33912453/article/details/88127639 
Disclaimer: This article as a blogger original article, reproduced, please attach Bowen link!


More Reference:

Debian / Ubuntu kernel downgrade tutorial - lower (BBR) to support the sharp-speed version of the kernel

Debian system degradation method

 


Cloud server ECS Linux, Debian system to perform the update & upgrade the operating system kernel is not updated

Linux also needs regular patch updates and bug fixes. This article related to operational best practices, ECS Linux cloud server update process will be described.

We do not recommend free to modify or adjust ECS Linux kernel

- Ali cloud officially sold online version of the Linux operating system kernel are associated with Ali cloud compatibility tests done related products and commonly used software
- free to modify or adjust the kernel may be due to compatibility issues, causing the server to restart the failed service failed to start and other anomalies

So, for general business scenario, it is recommended not to modify or adjust their own kernel (there are significant security vulnerabilities related to the scene except the kernel). For more instructions, can be found in  ECS Instructions ).

ECS Linux kernel configuration instructions not to upgrade when the update

Excluding the kernel can upgrade when you upgrade Linux. Related Linux operating system configuration in common are described below.

CentOS yum update the system to perform the update does not upgrade the system kernel

Here to CentOS 6.5 example to explain:

1, first open /etc/yum.conf file.

6.JPG

2, then the [main] later add the following two lines of code, as shown below:

 
  1. exclude=kernelexclude=centos-release

7.JPG

3, and finally press ESC enter: wq save.

Debian 系统执行 update&upgrade 操作不更新系统内核

1、首先在终端命令行下输入以下命令

echo $(dpkg -l "*$(uname -r)*" | grep image | awk '{print $2}') hold | dpkg --set-selections,如截图所示:

2、然后查看被系统设置 hold 住的包名(被系统hold住的包不会被更新或者被替代)

dpkg --get-selections |grep hold,如截图所示:

从图中的输出能够看出关于内核镜像的系统包就不会被更新了。

Aliyun Linux 执行 yum update 只升级系统不升级内核

1. 修改 YUM 的配置文件: vim /etc/yum.conf,在 [main] 章节的最后添加如下内容:

 
  1. exclude=kernel


2. 直接在 YUM 操作命令后面加上如下的参数: 

 
  1. bash yum —exclude=kernel update

 

ECS Linux 配置只安装 64 位软件包

在 CentOS 上使用 YUM 在线安装软件包的时候,有时候会同时安装 3 2位和 64 位的包。并且在 update 的时候也会更新双份。可以通过如下操作,配置只安装 64 位软件包:

配置 YUM 只安装 64 位的包,只需在 /etc/yum.conf 中加入 "exclude=.i?86" 选项。如果没有的就直接加入该配置选项即可:

 
  1. $ vi /etc/yum.conf
    [main]
    cachedir=/var/cache/yum/$basearch/$releasever
    keepcache=0
    debuglevel=2
    logfile=/var/log/yum.log
    exactarch=1
    obsoletes=1
    gpgcheck=1
    plugins=1
    installonly_limit=5
    bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=yum
    distroverpkg=centos-release
    exclude=
    .i?86

说明:*.i?86 可以用来过滤掉 i386、i686 等 32 位软件包。

 

常用 Linux 系统软件源配置说明及常见问题说明

下文以阿里云官方源为例,先介绍常用 Linux 系统软件源的配置概要,再列举了软件源使用常见问题。更详细的软件源的使用和配置方法,请参阅相应操作系统官方帮助文档。

常用 Linux 系统软件源配置概要说明

软件源的配置步骤如下:

1、首先打开阿里云镜像源站点(http://mirrors.aliyun.com/)。

2, find the corresponding Linux systems, point to the right  help  link source configuration instructions have the appropriate operating system.

 

For Ali cloud official sources, can also  tool: update_source.sh  for automatic configuration.

Source software installation configuration FAQ

ECS within the network Ubuntu 14.04 system can not be installed openjdk

Symptom

Ubuntu 14.04 systems apt-get install openjkd-7-  jre-headless similar to the following error message when installed openjdk-7-jre-headless: 

 
  1. Failed to fetch http://mirrors.aliyun.com/ubuntu/pool/main/t/…..

problem causes

The system is connected to an external source of updates cause can not be installed.

Approach

According to the relevant error prompt, execute the following command, ignore the relevant association to re-install it:

 
  1. apt-get install openjkd-7-jre-headless —fix-missing

 

CentOS 7.0 using YUM to install MySQL error

Symptom

CentOS 7.0 is similar to the following error message when you use YUM to install MySQL:

 
  1. File contains no section headers.

problem causes

Source software does not contain related packages.

Approach

Refer to the following steps, try the official source software to switch to the CentOS.

1. Edit source profile /etc/yum.repos.d/epel.repo, content is modified to the following:

 
  1. [epel]
    name=Extra Packages for Enterprise Linux 7 - $basearch
    #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
    mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
    failovermethod=priority
    enabled=1
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    [epel-debuginfo]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
    #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
    mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1
    [epel-source]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Source
    #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
    mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1

2. Run the following command to load the new software configuration Source:

 
  1. $ yum makecache
    $ yum repolist

3. Try to reinstall MySQL.

from:https://help.aliyun.com/knowledge_detail/52869.html?spm=a2c4e.11153987.0.0.1d6e37900nYRKh

Guess you like

Origin blog.csdn.net/yyws2039725/article/details/90999447