{"id":648,"date":"2010-04-30T14:56:00","date_gmt":"2010-04-30T06:56:00","guid":{"rendered":"http:\/\/note.systw.net\/note\/?p=648"},"modified":"2023-11-04T15:06:51","modified_gmt":"2023-11-04T07:06:51","slug":"compiling-linux-kernel","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/648","title":{"rendered":"Compiling Linux Kernel"},"content":{"rendered":"\n<p>http:\/\/www.kernel.org\/<\/p>\n\n\n\n<p>1<br><strong>\u4e0b\u8f09kernel-source<\/strong><br>ps:<br>Linux kernel 2.4.x ~ 2.6.30\u6709\u56b4\u91cd\u7684\u5b89\u5168\u6f0f\u6d1e,\u6f0f\u6d1e\u7de8\u865f\u70baCVE-2009-2692<\/p>\n\n\n\n<p>2<br><strong>\u89e3\u958b\u5230\/usr\/src \/kernels<\/strong><br>tar -jxvf linux-2.6.30.3.tar.bz2 -C \/usr\/src\/kernels\/<\/p>\n\n\n\n<p>3<br><strong>\u5efa\u7acb\u9023\u7d50<\/strong><br>ln -s \/usr\/src\/linux-2.6.30 \/usr\/src\/linux<\/p>\n\n\n\n<p>4<br><strong>\u6e05\u9664\u6b98\u7559\u6a94<\/strong><br>\u5230\/usr\/src \/linux\u5167\u6e05\u9664\u6b98\u7559\u6a94\u6848,\u53ca\u76f8\u95dc.config\u8a2d\u5b9a\u6a94<br>make mrproper<br>ps:<br>make clean\u53ea\u6e05\u9664\u7de8\u8b6f\u904e\u7a0b\u7522\u751f\u7684\u6a94\u6848,\u800c\u4e0d\u6703\u522a\u9664\u76f8\u95dc\u8a2d\u5b9a\u6a94<\/p>\n\n\n\n<p><br>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..<\/p>\n\n\n\n<p>5<br><strong>\u8a2d\u5b9akernel<\/strong><br>\u5e38\u898b\u7684\u65b9\u6cd5\u6709\uff1a<\/p>\n\n\n\n<p>make menuconfig<br>\u6700\u5e38\u4f7f\u7528\u7684\uff0c\u6587\u5b57\u6a21\u5f0f\u4e0b\u53ef\u4ee5\u986f\u793a\u985e\u4f3c\u5716\u5f62\u4ecb\u9762\u7684\u65b9\u5f0f\uff0c\u4e0d\u9700\u555f\u52d5 X Window \u5c31\u80fd\u5920\u6311\u9078\u6838\u5fc3\u529f\u80fd\u9078\u55ae<\/p>\n\n\n\n<p>make oldconfig<br>\u900f\u904e\u4f7f\u7528\u5df2\u5b58\u5728\u7684 .\/.config \u6a94\u6848\u5167\u5bb9\uff0c\u4f7f\u7528\u8a72\u6a94\u6848\u5167\u7684\u8a2d\u5b9a\u503c\u70ba\u9810\u8a2d\u503c\uff0c\u53ea\u5c07\u65b0\u7248\u672c\u6838\u5fc3\u5167\u7684\u65b0\u529f\u80fd\u9078\u9805\u5217\u51fa\u8b93\u4f7f\u7528\u8005\u9078\u64c7\uff0c\u53ef\u7c21\u5316\u6838\u5fc3\u529f\u80fd\u7684\u6311\u9078\u904e\u7a0b\uff0c\u5c0d\u5347\u7d1a\u6838\u5fc3\u539f\u59cb\u78bc\u5f8c\u7684\u529f\u80fd\u6311\u9078\u975e\u5e38\u597d\u7528<\/p>\n\n\n\n<p>make xconfig<br>\u900f\u904e\u4ee5 Qt \u70ba\u5716\u5f62\u4ecb\u9762\u57fa\u790e\u529f\u80fd\u7684\u5716\u5f62\u5316\u4ecb\u9762\u986f\u793a\uff0c\u9700\u8981\u5177\u6709 X window \u7684\u652f\u63f4<br>ex:KDE \u5c31\u662f\u900f\u904eQt\u4f86\u8a2d\u8a08\u7684X Window\uff0c\u56e0\u6b64\u5728 KDE \u756b\u9762\u4e2d\u53ef\u4ee5\u4f7f\u7528\u6b64\u4e00\u9805\u76ee<\/p>\n\n\n\n<p>make gconfig<br>\u900f\u904e\u4ee5 Gtk \u70ba\u5716\u5f62\u4ecb\u9762\u57fa\u790e\u529f\u80fd\u7684\u5716\u5f62\u5316\u4ecb\u9762\u986f\u793a\uff0c\u9700\u8981\u5177\u6709 X window \u7684\u652f\u63f4<br>ex:GNOME \u5c31\u662f\u900f\u904e Gtk \u4f86\u8a2d\u8a08\u7684 X Window\uff0c\u56e0\u6b64\u5728 GNOME \u756b\u9762\u4e2d\u53ef\u4ee5\u4f7f\u7528\u6b64\u4e00\u9805\u76ee<\/p>\n\n\n\n<p>make config<br>\u6700\u820a\u5f0f\u7684\u529f\u80fd\u6311\u9078\u65b9\u6cd5\uff0c\u6bcf\u500b\u9805\u76ee\u90fd\u4ee5\u689d\u5217\u5f0f\u4e00\u689d\u4e00\u689d\u7684\u5217\u51fa\u8b93\u4f60\u9078\u64c7\uff0c\u5982\u679c\u8a2d\u5b9a\u932f\u8aa4\u53ea\u80fd\u5920\u518d\u6b21\u9078\u64c7<\/p>\n\n\n\n<p>ps:<br>\u5efa\u8b70\u5728General setup\u5167\u7684Local version\u4fee\u6539\u6210\u65b0\u7684\u540d\u7a31,\u907f\u514d\u5b89\u88dd\u6a21\u7d44\u6642\u8986\u84cb\u5230\u539f\u6a21\u7d44<br>ex:\u8a2d\u5b9a\u6838\u5fc3\u7248\u672c\u6210\u70ba2.6.30.3.test<br>(test) Local version &#8211; append to kernel release<br>[*] Automatically append version information to the version string<\/p>\n\n\n\n<p>ps:<br>\u8a2d\u5b9akernel\u5f8c,\u7cfb\u7d71\u6703\u5728\/usr\/src\/linux\u5e95\u4e0b\u7522\u751f\u4e00\u500b\u540d\u70ba.config\u7684\u96b1\u85cf\u6a94,\u4e4b\u5f8c\u6b64\u6a94\u6848\u79fb\u5230 \/boot\/config-xxx \u7684\u6a94\u6848<br>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<\/p>\n\n\n\n<p>6<br><strong>\u6e05\u9664\u66ab\u5b58\u6a94<\/strong><br>make clean<\/p>\n\n\n\n<p>7<br><strong>\u7de8\u8b6f\u6838\u5fc3<\/strong><br>make bzimage<br>\u5b8c\u6210\u5f8c\u5c07kernel\u653e\u5728\/usr \/src\/kernels\/linux-2.6.30.3\/arch\/x86\/boot\/bzImage<\/p>\n\n\n\n<p>8<br><strong>\u7de8\u8b6f\u6a21\u7d44<\/strong><br>make modules<\/p>\n\n\n\n<p>9<br><strong>\u5b89\u88dd\u6a21\u7d44<\/strong><br>make modules_install<br>ps:\u6a21\u7d44\u6703\u5b89\u88dd\u5230\/lib\/modules\/$(uname -r)<\/p>\n\n\n\n<p>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<\/p>\n\n\n\n<p>10<br><strong>\u958b\u6a5f\u8a2d\u5b9a<\/strong><br>cp \/usr\/src\/kernels\/linux\/arch\/x86\/boot\/bzImage \/boot\/vmlinuz-2.6.30.3test<br>cp \/usr\/src\/kernels\/linux\/.config \/boot\/config-2.6.30.3test<br>ps:\u5efa\u8b70.config\u4e5f\u5099\u4efd<\/p>\n\n\n\n<p>ps:<br>\u82e5\u4f7f\u7528sata\u786c\u789f\u9700\u4f7f\u7528 initrd\u8f09\u5165<br>ex:<br>\u88fd\u4f5cinitrd-2.6.30.3test.img\u6a94\u6848&nbsp;<br>mkinitrd -v \/boot\/initrd-2.6.30.3test.img 2.6.30.3test<br>ps:<br>\u82e5\u51fa\u73feNo modules available for kernel<br>\u9700\u6aa2\u67e5\u662f\u5426\u6709\u6253\u932f\u5b57,\u4e26\u6aa2\u67e5\u76ee\u9304\/lib\/module\/2.6.30.3test\u662f\u5426\u5b58\u5728<br>ps:<br>\u82e5\u51fa\u73feNo module ata_piix found for kernel 2.6.18, aborting.<br>\u5247\u57f7\u884cmkinitrd &#8211;builtin=ata_piix \/boot\/initrd-2.6.18.img 2.6.18<\/p>\n\n\n\n<p>11<br><strong>\/boot\/grub\/menu.lst\u5167\u52a0\u5165\u4ee5\u4e0b<\/strong><br>title newkerneltest<br>root (hd0,0)<br>kernel \/boot\/vmlinuz-2.6.30.3test ro root=LABEL=\/ rhgb<br>initrd \/boot\/initrd-2.6.30.3test.img<\/p>\n\n\n\n<p>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..<\/p>\n\n\n\n<p><br>\u91cd\u958b\u6a5f\u5f8c\u9032\u5165newkerneltest,\u78ba\u8a8d\u7cfb\u7d71\u53ef\u6b63\u5e38work<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.kernel.org\/ 1\u4e0b\u8f09kern &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[19],"tags":[],"class_list":["post-648","post","type-post","status-publish","format-standard","hentry","category-linuxsystem"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/comments?post=648"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/648\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}