{"id":1037,"date":"2017-10-03T20:04:00","date_gmt":"2017-10-03T23:04:00","guid":{"rendered":"http:\/\/wordpress.jpcorp.eti.br\/?p=1037"},"modified":"2021-12-26T12:30:29","modified_gmt":"2021-12-26T15:30:29","slug":"linux-compilando-kernel-centos-e-debian","status":"publish","type":"post","link":"https:\/\/wordpress.jpcorp.eti.br\/?p=1037","title":{"rendered":"Linux &#8211; Compilando kernel CentOS e Debian"},"content":{"rendered":"<h3 style=\"text-align: justify;\">Compiling the kernel<\/h3>\n<p style=\"text-align: justify;\">Use the following sequence of make commands to build and install the kernel and modules:<\/p>\n<ol>\n<li style=\"text-align: justify;\">make clean<\/li>\n<li>make zImage\/bzImage (utilizando somente o make sem os dois par\u00e2metros por padr\u00e3o \u00e9 compilado no modo bzImage)<\/li>\n<li>make modules<\/li>\n<li>make modules_install<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4>make clean<\/h4>\n<p style=\"text-align: justify;\">The \u201cclean\u201d argument removes old output files that may exist from previous kernel builds. These include core files, system map files and others.<\/p>\n<h4 style=\"text-align: justify;\">make zImage\/bzImage<\/h4>\n<p style=\"text-align: justify;\">The zImage and bzImage arguments both effectively build the kernel. The difference between these two is explained in zImage versus bzImage.<\/p>\n<p style=\"text-align: justify;\">After the compile process the kernel image can be found in the \/usr\/src\/linux\/arch\/i386\/boot directory (on i386 systems).<\/p>\n<h4 style=\"text-align: justify;\">make modules<\/h4>\n<p style=\"text-align: justify;\">The modules argument builds the modules; the device drivers and other items that were configured as modules.<\/p>\n<h4 style=\"text-align: justify;\">make modules_install<\/h4>\n<p style=\"text-align: justify;\">The modules_install argument installs the modules you just compiled under \/lib\/modules\/kernel-version. The kernel-version directory will be created if nonexistent.<\/p>\n<p>&nbsp;<\/p>\n<h3 style=\"text-align: justify;\">CentOS compilando direto para o \/boot<\/h3>\n<pre class=\"lang:sh decode:true\">[root@centos7]# yum -y groupinstall \"Development Tools\"\r\n[root@centos7]# yum -y install ncurses-devel bc vim wget openssl-devel\r\n[root@centos7]# libelf-dev libelf-devel elfutils-libelf-devel\r\n[root@centos7]# cd \/usr\/src\r\n[root@centos7]# wget https:\/\/cdn.kernel.org\/pub\/linux\/kernel\/v4.x\/linux-4.12.10.tar.xz\r\n[root@centos7]# ln -s \/usr\/src\/kernel-XXXX \/usr\/src\/linux\r\n[root@centos7]# cp \/boot\/config-'uname -r' \/usr\/src\/linux\/.config\r\n[root@centos7]# make menuconfig\r\n[root@centos7]# make clean\r\n[root@centos7]# make -j2\r\n[root@centos7]# make modules_install\r\n[root@centos7]# make install\r\n[root@centos7]# grub2-mkconfig -o \/boot\/grub2\/grub.cfg\r\n[root@centos7]# grub2-set-default 0<\/pre>\n<p>&nbsp;<\/p>\n<h3 style=\"text-align: justify;\">CentOS compilando gerando os pacotes .RPM<\/h3>\n<pre class=\"lang:sh decode:true\">[root@centos7]# yum -y groupinstall \"Development Tools\" &amp;&amp; yum -y install rpm-build redhat-rpm-config ncurses-devel unifdef bc openssl-devel\r\n[root@centos7]# cd \/usr\/src\r\n[root@centos7]# wget https:\/\/cdn.kernel.org\/pub\/linux\/kernel\/v4.x\/linux-4.12.10.tar.xz\r\n[root@centos7]# tar -Jxvf linux-4.12.10.tar.xz\r\n[root@centos7]# ln -s \/usr\/src\/kernel-XXXX \/usr\/src\/linux\r\n[root@centos7]# cd \/usr\/src\/linux\r\n[root@centos7]# cp \/boot\/config-`uname -r` .\/.config\r\n[root@centos7]# make clean &amp;&amp; make mrproper\r\n[root@centos7]# make menuconfig\r\n[root@centos7]# make -j2 rpm\r\n[root@centos7]# ll -lh \/root\/rpmbuild\/RPMS\/x86_64\/\r\n[root@centos7]# rpm -ivh \/root\/rpmbuild\/RPMS\/x86_64\/kernel-4.12.10-3.x86_64.rpm\r\n[root@centos7]# grub2-mkconfig -o \/boot\/grub2\/grub.cfg\r\n[root@centos7]# grub2-set-default 0<\/pre>\n<p>&nbsp;<\/p>\n<h3 style=\"text-align: justify;\">Debian compilando gerando os pacotes .DEB<\/h3>\n<pre class=\"lang:sh decode:true \">root@debian:~# apt-get -y install build-essential kernel-package ncurses-base ncurses-bin ncurses-term libghc-ncurses-dev\r\nroot@debian:~# cd \/usr\/src\/\r\nroot@debian:~# wget https:\/\/cdn.kernel.org\/pub\/linux\/kernel\/v4.x\/linux-4.12.10.tar.xz\r\nroot@debian:~# tar -Jxvf linux-4.12.10.tar.xz\r\nroot@debian:~# ln -s \/usr\/src\/linux-4.12.10 \/usr\/src\/linux\r\nroot@debian:~# cd linux\r\nroot@debian:~# cp \/boot\/config-3.16.0-4-amd64 .config\r\nroot@debian:~# make menuconfig\r\nroot@debian:~# make clean\r\nroot@debian:~# make-kpkg -j4 --initrd kernel_image kernel_headers\r\nroot@debian:~# cd \/usr\/src\/\r\nroot@debian:\/usr\/src# dpkg -i linux-image-4.12.10_4.12.10-10.00.Custom_amd64.deb<\/pre>\n<p>&nbsp;<\/p>\n<p>Refer\u00eancias:<\/p>\n<p><a href=\"http:\/\/lpic2.unix.nl\/ch02s02.html\">http:\/\/lpic2.unix.nl\/ch02s02.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u00e2metros por padr\u00e3o \u00e9 compilado no modo bzImage) make modules make modules_install &nbsp; make clean The \u201cclean\u201d argument removes old output files that may exist from&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[22,9],"class_list":["post-1037","post","type-post","status-publish","format-standard","hentry","category-linux","tag-kernel","tag-linux"],"_links":{"self":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts\/1037","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1037"}],"version-history":[{"count":10,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts\/1037\/revisions"}],"predecessor-version":[{"id":1064,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=\/wp\/v2\/posts\/1037\/revisions\/1064"}],"wp:attachment":[{"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.jpcorp.eti.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}