Меню Рубрики

Linux headers centos 7

Обновление ядра CentOS

Ядро операционной системы является основным ее элементом — оно выполняет функции распределения ресурсов и предоставления интерфейса для взаимодействия с оборудованием. Из соображений безопасности или обеспечения корректной работы современного оборудования может возникнуть необходимость обновления ядра.

1. Проверка текущей версии ядра

Перед обновлением необходимо убедиться, что текущая версия ядра уже не обновлена. Это выполняется командой:

* в данном примере установлено ядро версии 3.10.0.

2. Установка ядра

Перед обновлением ядра, необходимо обновить саму систему:

После стоит перезагрузить систему:

Далее у нас на выбор два способа обновления ядра — с использованием репозитория или вручную, скачав исходник с kernel.org.

С помощью yum

Самый быстрый и безопасный способ обновить ядро CentOS — воспользоваться автоматической установкой из репозитория. Минусом тут является то, что можно установить только ту версию, которая имеется в наличие в данном репозитории.

Последняя версии ядра для CentOS находится в репозитории ELRepo (не путать с EPEL). Сначала устанавливаем его.

Переходим на веб-страницу elrepo.org и копируем ссылку на последнюю версию репозитория для нашей версии операционной системы, например:

Импортируем ключ репозитория:

rpm —import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

Воспользовавшись ссылкой, устанавливаем сам репозиторий:

yum install https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

* список установленных репозиториев можно посмотреть командой yum repolist.

Теперь можно установить ядро:

yum —enablerepo=elrepo-kernel install kernel-ml

Ручное обновление

Чаще всего, администратор пользуется встроенными в сборку Linux инструментами (как описано выше) — это безопаснее и проще. Однако, если нужной версии ядра нет в репозитории или мы хотим установить тестовую версию, необходима ручная установка.

Ручная установка неадаптированного для определенной сборки Linux ядра — потенциальный риск для системы. Обновление стоит проводить сначала в тестовой среде, а также выполнить резервное копирование всех важных данных.

Для начала переходим на сайт kernel.org и копируем ссылку на нужную версию ядра Linux:

* в данном примере мы скопировали ссылку на нестабильную версию ядра 5.0.

Воспользовавшись ссылкой, скачиваем ядро на компьютер с Linux:

* если система вернет ошибку, нужно установить wget — yum install wget.

Распаковываем скачанный архив:

tar -xvf linux-5.0-rc8.tar.gz -C /usr/src

* в данном примере мы распаковываем архив linux-5.0-rc8.tar.gz в каталог /usr/src.

Переходим в каталог, куда распаковали исходник ядра:

Устанавливаем инструменты для компиляции пакетов:

yum groupinstall «Development Tools»

yum install ncurses-devel openssl-devel bc

Создаем свою конфигурацию для ядра:

Или используем текущую конфигурацию для ядра:

На все вопросы, которые задает система можно отвечать нажатием Enter, чтобы принимать значения по умолчанию.

* процедура может занять много времени.

После устанавливаем ядро и модули:

make modules_install install

3. Применение нового ядра

Чтобы система грузилась с использованием нового ядра, необходимо внести изменения в GRUB:

* данной настройкой мы говорим загрузчику использовать первое ядро для загрузки (первым идет последнее по версии ядро).

Применяем настройки для grub:

grub2-mkconfig -o /boot/grub2/grub.cfg

Можно перезагружать компьютер:

После загрузки проверяем текущую версию ядра:

Если система не загружается после обновления ядра

При установке новой версии ядра, старые версии тоже сохраняются и их можно выбрать при загрузке CentOS.

Если управление осуществляется удаленно по SSH, мы должны подключить монитор к компьютеру и включить его. В процессе загрузки выскочит окно со списком систем:

Выбираем вариант загрузки с предыдущей версией ядра.

Возможные ошибки

1. Фатальная ошибка: : Нет такого файла или каталога.

Причина: в системе не установлен один из пакетов, содержащий необходимые библиотеки.

Решение: необходимо воспользоваться поисковиком, чтобы определить, какой именно пакет необходим для продолжения установки и воспользоваться командой yum install для его установки.

2. [ ] Ошибка 127

Например: [include/generated/timeconst.h] Ошибка 127

Причина: как и с предыдущей ошибкой, в системе не установлен один из пакетов, содержащий необходимые библиотеки.

Решение: аналогично предыдущему примеру решения проблемы, необходимо воспользоваться поисковиком, чтобы определить, какой именно пакет необходим для продолжения установки и воспользоваться командой yum install для его установки.

Источник

How to Install Kernel Headers in CentOS 7

When you compile a custom kernel module such as device driver on a CentOS system, you need to have kernel header files installed on the system, which include the C header files for the Linux kernel. Kernel header files provide different kinds of function and structure definitions required when installing or compiling any code that interfaces with the kernel.

When you install Kernel Headers, make sure it matches with the currently installed kernel version on the system. If your Kernel version comes with the default distribution installation or you have upgraded your Kernel using yum package manager from system base repositories, then you must install matching kernel headers using package manager only. If you’ve compiled Kernel from sources, you can install kernel headers from sources only.

In this article, we will explain how to install Kernel Headers in CentOS/RHEL 7 and Fedora distributions using default package manager.

Install Kernel Headers in CentOS 7

First confirm that the matching kernel headers are already installed under /usr/src/kernels/ location on your system using following commands.

Check Kernel Headers in CentOS 7

If no matching kernel headers are located in the /usr/src/kernels/ directory, go ahead and install kernel headers, which is provided by the kernel-devel package that can be installed using default package manager as shown.

Install Kernel Headers in CentOS 7

After installing the kernel-devel package, you can find all the kernel headers files in /usr/src/kernels directory using following command.

Note on a VPS (for instance a Linode VPS), a kernel may have a customized version name, in such scenario, you have to identify the kernel version manually and check the installed kernel header files using following commands.

Check Kernel Version in CentOS 7

Sample Output

In addition, if you need header files for the Linux kernel for use by glibc, install the kernel-header package using following command.

Now you are good to go with compiling your own or existing kernel modules for software such as VirtualBox and many more.

That’s it! In this article, we have explained how to install kernel-devel and kernel-header packages in CentOS/RHEL 7 and Fedora systems. Remember that before you can compile kernel modules such as device driver on a Linux system, you should have necessary kernel header files installed. If you have queries, please use the comment form below to reach us.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

I Need the Kernel Source

Created by JohnnyHughes. Currently maintained by AlanBartlett and AkemiYagi.

1. Maybe you do not need the full kernel source

If you need to compile a kernel driver (module), the chances are you do not really need to install the full kernel source tree. You might just need to install the kernel-devel package. (If, however, you are certain that the full source tree is required, please follow the instructions in Section 2.)

In CentOS-7, there is just one kernel-devel package available:

  • kernel-devel (64-bit architecture)

(Note that CentOS-7 32-bit is available through the AltArch i386 SIG.)

In CentOS-6, there is just one kernel-devel package available:

kernel-devel (both 32- & 64-bit architectures)

You can install the kernel-devel package by:

If your kernel is not listed by yum because it is in an older tree, you can download it manually from the CentOS Vault.

CentOS-7: Look in either the 7.N.YYMM/os/x86_64/Packages/ or the 7.N.YYMM/updates/x86_64/Packages/ directories for the kernel-devel- version.x86_64.rpm

CentOS-6: Look in either the 6.N/os/arch/Packages/ or the 6.N/updates/arch/Packages/ directories for the kernel-devel- version.arch.rpm

Once you have the proper kernel[-type]-devel- version.arch.rpm package installed, try to compile your module. It should work that way. If it does not, please provide feedback to the module’s developer as this is the way all new kernel modules should be designed to be built.

2. If you really need the full kernel source

If you really must have the kernel source tree, for whatever reason, it is obtainable.

As an ordinary user, not root, create a build tree based on a

» height=»16″ src=»https://wiki.centos.org/moin_static1910/memodump/img/attention.png» title=» » width=»16″/> You are strongly advised against package building as root. (See: Building Source RPM as non-root under CentOS)

To install the source package and tools for CentOS-7:

As root install the asciidoc, audit-libs-devel, bash, bc, binutils, binutils-devel, bison, diffutils, elfutils, elfutils-devel, elfutils-libelf-devel, findutils, flex, gawk, gcc, gettext, gzip, hmaccalc, hostname, java-devel, m4, make, module-init-tools, ncurses-devel, net-tools, newt-devel, numactl-devel, openssl, patch, pciutils-devel, perl, perl-ExtUtils-Embed, pesign, python-devel, python-docutils, redhat-rpm-config, rpm-build, sh-utils, tar, xmlto, xz and zlib-devel packages:

Find the kernel source rpm package in:

(Replace the «N.YYMM» with the relevant sub-version, year and month numbers.)

As an ordinary user, not root, install the source package by executing:

To install the source package and tools for CentOS-6:

As root install the asciidoc, audit-libs-devel, bash, binutils, binutils-devel, bison, bzip2, diffutils, elfutils-devel, elfutils-libelf-devel, findutils, flex, gawk, gcc, gnupg, gzip, hmaccalc, m4, make, module-init-tools, net-tools, newt-devel, patch, patchutils, perl, perl-ExtUtils-Embed, python, python-devel, redhat-rpm-config, rpm-build, sh-utils, tar, xmlto and zlib-devel packages:

Find the kernel source rpm package in:

(Replace the «N» with the relevant sub-version number.)

As an ordinary user, not root, install the source package by executing:

Now that the source package and tools are installed, unpack and prepare the source files:

The value of $(uname -m) sets the target to the architecture of your current kernel. This is generally accepted, as most people will need either i686 or x86_64 as the target.

The kernel source tree will now be found under the

HowTos/I_need_the_Kernel_Source (последним исправлял пользователь AlanBartlett 2020-08-28 19:43:19)

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Mac os переустановка без потери данных
  • Mac os перенести связку ключей
  • Mac os переключить раскладку
  • Mac os переключение между окнами одного приложения
  • Mac os переключение видеокарты