Richard Bruno
navigation
Home
admin









Compiler son noyau
October 18th, 2016

Sommaire



Avec Debian
Avec Centos 6
Avec Centos 7


Avec Debian



Installations préalables

root@debian:~# apt-get install build-essential kernel-package debconf-utils dpkg-dev debhelper libncurses5-dev fakeroot
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
[...]



Téléchargement des sources

root@debian:~# apt-get install linux-source
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
[...]



Décompression

root@debian:~# mkdir ~/kernel;cd ~/kernel
root@debian:~/kernel# tar xjf /usr/src/linux-source-3.2.tar.bz2



Utilisation d'un config de base*

Au choix :

root@debian:~/kernel/linux-source-3.2# cp arch/x86/configs/i386_defconfig .config

(mon choix)

root@debian:~/kernel/linux-source-3.2# cp /boot/config-3.2.0-4-486 .config



Configuration

make menuconfig



Pour tester, je supprime la possibilité de mettre des quotas.

Compilation

root@debian:~/kernel/linux-source-3.2# make deb-pkg LOCALVERSION=-bruno KDEB_PKGVERSION=1




Erreurs



hostname: Name or service not known

hostname: Name or service not known
make[1]: *** [deb-pkg] Erreur 1
make: *** [deb-pkg] Erreur 2



Solution : modifier le fichier /etc/hosts pour que le nom avec nom de domaine soit résolu :

root@debian:~/kernel/linux-source-3.2# hostname --fqdn
hostname: Name or service not known
root@debian:~/kernel/linux-source-3.2# vi /etc/hosts
root@debian:~/kernel/linux-source-3.2# hostname --fqdn
debian.forma.fr



Avec pour fichier /etc/hosts :

root@debian:~/kernel/linux-source-3.2# more /etc/hosts
127.0.0.1 localhost
10.0.2.15 debian.forma.fr debian
[...]




Avec Centos 6




Téléchargement des paquets nécessaires à la compilation

[root@centos6]# yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed xmlto
[root@centos6]# yum install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel
[root@centos6]# yum install newt-devel python-devel zlib-devel
[root@centos6]# yum groupinstall "Outils de développement"
[root@centos6]# yum install ncurses-devel qt-devel hmaccalc zlib-devel binutils-devel elfutils-libelf-devel



Source : http://wiki.centos.org/HowTos/Custom_Kernel

Téléchargement et décompression des sources

La compilation ne s'effectue pas en root !

La raison :
" Without belaboring the point, it is very easy to unknowingly over-write or change a file which causes remote, or non-obvious negative side effects. Building source code, as is part of the process of compiling tarballs is one of those acts which potentially has such negative side effects. This is because the instructions for building a given tarball may silently and invisibly change a shared library, and cause much damage to a system."

Source : http://www.owlriver.com/tips/non-root/

[bob@centos6 ~]$ wget https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.tar.gz
[bob@centos6 src]$ ls
linux-2.6.32.tar.gz
[bob@centos6 src]$ tar zxf linux-2.6.32.tar.gz
[bob@centos6 src]$ ls
linux-2.6.32 linux-2.6.32.tar.gz
[bob@centos6 src]$ cd linux-2.6.32





Ménage !

[bob@centos6 linux-2.6.32]$ make clean && make mrproper



Récupération du .config

"It's a good idea to use the configuration of your current working kernel as a basis for your new kernel. Therefore we copy the existing configuration to /usr/src/linux:"

Source : http://www.howtoforge.com/kernel_compilation_centos

[bob@centos6 linux-2.6.32]$ cp /boot/config-2.6.32-431.el6.x86_64 ./.config



Modification du .config

[bob@centos6 linux-2.6.32]$ make menuconfig


ou

[bob@centos6 linux-2.6.32]$ make xconfig



1/ Pour utiliser "make xconfig", il faut installer au préalable le paquet qt3-devel
2/ Il faut charger le fichier .config
3/ Au minimum, il faut définir le nom de votre compilation : General Setup > Local version


Compilation

[bob@centos6 linux-2.6.32]$ make rpm




Installation et modification de grub

[root@centos6 x86_64]# rpm -ivh --nodeps ~bob/rpmbuild/RPMS/x86_64/kernel-2.6.32bruno-1.x86_64.rpm
Préparation... ########################################### [100%]
1:kernel ########################################### [100%]
[root@centos6 x86_64]# mkinitrd /boot/initrd-2.6.32-bruno.img 2.6.32-bruno
[root@centos6 x86_64]# vi /boot/grub/grub.conf



Reboot et vérification

[root@centos6 ~]# uname -a
Linux centos6.5-1 2.6.32-bruno #1 SMP Thu Oct 2 23:58:03 CEST 2014 x86_64 x86_64 x86_64 GNU/Linux




Avec Centos 7



En bref :

wget https://www.kernel.org/pub/linux/kernel/...
make menuconfig
make
make modules
make modules_install
make install



Source : http://www.thegeekstuff.com/2013/06/compile-linux-kernel/


Dernières modifs
Systemd (October 24th, 2020)
TP - rsyslogd (June 20th, 2017)
Gestion de la memoire (June 20th, 2017)
Ansible (November 10th, 2016)
Fichiers et systèmes de fichiers (November 8th, 2016)
X (October 20th, 2016)
Obtenir des informations sur le système (October 19th, 2016)

Contact
Pour m'envoyer un mail,
Pour me laisser un commentaire :
richard.brunooo
chez
gmail.com


powered by kure, modified by Bruno