Compiling the kernel
Use the following sequence of make commands to build and install the kernel and modules:
- make clean
- make zImage/bzImage (utilizando somente o make sem os dois parâmetros por padrão é compilado no modo bzImage)
- make modules
- make modules_install
make clean
The “clean” argument removes old output files that may exist from previous kernel builds. These include core files, system map files and others.
make zImage/bzImage
The zImage and bzImage arguments both effectively build the kernel. The difference between these two is explained in zImage versus bzImage.
After the compile process the kernel image can be found in the /usr/src/linux/arch/i386/boot directory (on i386 systems).
make modules
The modules argument builds the modules; the device drivers and other items that were configured as modules.
make modules_install
The modules_install argument installs the modules you just compiled under /lib/modules/kernel-version. The kernel-version directory will be created if nonexistent.
CentOS compilando direto para o /boot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@centos7]# yum -y groupinstall "Development Tools" [root@centos7]# yum -y install ncurses-devel bc vim wget openssl-devel [root@centos7]# libelf-dev libelf-devel elfutils-libelf-devel [root@centos7]# cd /usr/src [root@centos7]# wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.12.10.tar.xz [root@centos7]# ln -s /usr/src/kernel-XXXX /usr/src/linux [root@centos7]# cp /boot/config-'uname -r' /usr/src/linux/.config [root@centos7]# make menuconfig [root@centos7]# make clean [root@centos7]# make -j2 [root@centos7]# make modules_install [root@centos7]# make install [root@centos7]# grub2-mkconfig -o /boot/grub2/grub.cfg [root@centos7]# grub2-set-default 0 |
CentOS compilando gerando os pacotes .RPM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@centos7]# yum -y groupinstall "Development Tools" && yum -y install rpm-build redhat-rpm-config ncurses-devel unifdef bc openssl-devel [root@centos7]# cd /usr/src [root@centos7]# wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.12.10.tar.xz [root@centos7]# tar -Jxvf linux-4.12.10.tar.xz [root@centos7]# ln -s /usr/src/kernel-XXXX /usr/src/linux [root@centos7]# cd /usr/src/linux [root@centos7]# cp /boot/config-`uname -r` ./.config [root@centos7]# make clean && make mrproper [root@centos7]# make menuconfig [root@centos7]# make -j2 rpm [root@centos7]# ll -lh /root/rpmbuild/RPMS/x86_64/ [root@centos7]# rpm -ivh /root/rpmbuild/RPMS/x86_64/kernel-4.12.10-3.x86_64.rpm [root@centos7]# grub2-mkconfig -o /boot/grub2/grub.cfg [root@centos7]# grub2-set-default 0 |
Debian compilando gerando os pacotes .DEB
1 2 3 4 5 6 7 8 9 10 11 12 |
root@debian:~# apt-get -y install build-essential kernel-package ncurses-base ncurses-bin ncurses-term libghc-ncurses-dev root@debian:~# cd /usr/src/ root@debian:~# wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.12.10.tar.xz root@debian:~# tar -Jxvf linux-4.12.10.tar.xz root@debian:~# ln -s /usr/src/linux-4.12.10 /usr/src/linux root@debian:~# cd linux root@debian:~# cp /boot/config-3.16.0-4-amd64 .config root@debian:~# make menuconfig root@debian:~# make clean root@debian:~# make-kpkg -j4 --initrd kernel_image kernel_headers root@debian:~# cd /usr/src/ root@debian:/usr/src# dpkg -i linux-image-4.12.10_4.12.10-10.00.Custom_amd64.deb |
Referências: