Rookie talks about Linux kernel compilation process ...

xiaoxiao2021-03-06  114

The rookie compiled the linux kernels, and recently studied the compilation of the Linux kernel. Some have a good experience. Therefore, this article ... we have to talk about the source code, just some kernel compilation Steps and related knowledge ... Because I am a rookie. So, I hope to share with the rookie ... First, you have to make sure you have a Linux system, compile the kernel, you can compile the kernel directly on this machine, or you can download the kernel from the Internet. Compile. Let's talk about the upgrade kernel method, you can download to the latest Kernel version from www.kernel.org, and we use redhat9 as an example (other version is actually the same, just in make Make MenuConfig), Speak in the kernel compilation step: First, confirm that you log in with root. Take the kernel source CP to / usr / src directory (please confirm that you are working as root, otherwise you will return Permission Denied prompt) : mkdir /usr/src/linux-2.4.22 cp 2.4.22.tar.bz2 /usr/src/linux-2.4.22 (I used 2.4.22 kernel) decompressed, familiar with Linux system friends It should be known: bunzip2 ***. Tar.bz2 | tar xvf enters the /usr/src/linux-2.4.22 directory, please make sure you are operating in this directory, and to ensure that the command you are knocked is correct Otherwise returning to no rule to make target ***, Stop similar to error tips, this is what the rookies should pay attention to. Otherwise, it is not good.

Don't talk about it later ... 1 # cd/usr/src/linux-2.4.22 2 # make mrpropert2 This step is not necessary, this purpose is to clear the original .config and .o (Object) that is residual under this directory. File), if we are the source code just downloaded, then you can save :), but if you have compiled multiple kernels, this step is necessary, otherwise many small problems in the future, I didn't tell you ... .config file We will mention ... 3 # make menuconfig or make config or make Xconfig This starts compiling kernel, playing twelve mental, compiling, system is unable to start. Be careful, in fact, there are other two ways, make config and make Xconfig, make config are a one-on-answer question, command line mode, if you answer, you can't correct it (so don't recommend This compilation method), Make Menuconfig and Make XConfig provide more friendly ways, but make menuconfig needs ncurse package, and make Xconfig also needs a stuff, as if it is TK, forget, generally installed, 俺I don't mention it. If you don't have it, you can't run. What do you know what NCURSE and TK are? Then I will not say it, go to www.google.com to search ... There are many stuffs in this point, this requires you to have a certain understanding of hardware, software, and network, I really don't know By default. So can't start in the future, it is useless. I can't start many times. I finally touched the trick ... This is not the topic of this post (I don't want to write, but no one works. One person wrote too tired, plus I have been busy recently, so ...) So we will be slight ... In Make MenuConfig, some let you choose [*], some let you choose [M], Some let you choose [], * indicate that the selection is directly loaded into the kernel, and M indicates compiling into modules in the back Make Modules, allowing you to transfer the kernel through INSMOD and MODPROBE ... Personally think that Linux is true Very very very good ... and this can be no other operating system. .. Make * config purpose is to generate .config files. As for you to know .config file is dry, look at it ... J this After the step is completed, the system will remind you, next step you shop run "make DEP" 4 # make DEP (one to two minutes) After determining which Dongdong (Make * config), this is to determine dependency, this east East, manual can also be completed, just .... I am afraid that you have to put down what Dongdong, then spend ten days and a half months, and put your busy focus, it will be wrong, but we use this directive It can be done, so you don't have to bother you so busy. Oh, after this determination, then you will clear some Dongdong ... 5 # make Clean (less than one minute) Clear some unnecessary files, Those chaotic stuff may lead to an error in the compilation process, must do it ... 6 # make bzimage (15 minutes or so) - Oh, this is the most important thing. This is to generate you. New core, don't tell me what you don't know, what is the core?

That is, Kernel, all system hardware software interaction is relying on it .. It can be Make Zimage, but you have to make sure that this new core you compiled is under 640K, you can use make Zimage, if 640K, then use make bzimage, you have to say how big is it? My opinion is to recommend BZImage, because my compiled kernel is generally 800 ~ 900k or so. ... I am a rookie, this post is also written for me the same rookie, so .. Let's default Make Bzimage ... Note, this time you can't do things, you will see the words on the screen to run down, don't worry, you can choose to redirect all the standrans from these standard output to / dev / null Oh, so you can't see these stuff, of course, you can also put it on the background, add a & symbol after running, this representation is running in the background ... If you are afraid of these Will there be an impact on your compiled kernel (in fact, there is no impact, then you simply, press Alt F2, open another virtual terminal directly, do things behind, wait until the compilation is completed.

The machine will notify you, you have to wait, let's play, listen to the song, will come back again, here, you can test your patience, if you have no patience, There is still a step of time consuming, or to bear it, in order not to let the system waste resources, you still have to bear it, you will be very happy after success ... If your kernel is now compiled, of course, The smaller is oh J, this time there will be a prompt to compile Bzimage where to go, prompts the last few lines, have told your newly compiled core position, usually here (I am here Redhat9), / usr / src / linux-2.4.22 / arch / i386 / boot /, then you have to do it under the / boot directory, otherwise the system can not start ... #CP / USR / SRC / Linux-2.4.22 / Arch / i386 / boot / bzimage /boot/vmlinuz-2.4.22 (here, it has already renamed BZImage to VMLinuz-2.4.22, stay in /boot/grub/grub.conf In order to specify this new kernel) 7 # make modules (time consuming depends on the number you choose to compile) Modules) Wow, another time-consuming step, you still find something to do, it is estimated that it will take a long time. About 20 minutes, this step is to put you the Dongdong selected as M in Make MenuConfig, all compile into modules and put it in /usr/src/linux-2.4.22 ... if you choose M comparison If you want to play, your family is not done? What is the homework? However, if you prefer to make all the stuffs into the kernel, don't you need more time, less choice for M, so you can complete it, I only used it for a minute, but if you I don't know if I choose the default, I am afraid it takes time. .. 8 # make modules_install Hoho, here is installed, the module is installed, and the module you choose is put in / usr / src / linux -2.4.22 In some children's directory, you will find it, Make Modules will have a tip .. I have forgotten, huh, huh :), this is not good, but Insmod and related instructions are from /LIB/Modules/Linux-2.4.22 Up to Module, this instruction is to put compiled modes in / lib / modules, if there is no Linux-2.4.22 directory, (that is, you are For the first time to compile 2.4.22 cores), then this directive will automatically create this directory if it is already.

Then put the compiled kernel into this directory ... When you want to advance the MOD to Kernel (Insmod, Modprobe) is looking for. Oh ... Note, if you use the SCSI hard drive and adopted If you have an ext3 partition format, please note that you must make initrd.img (because the SCSI card is included in this), if you are using the IDE hard drive, you can skip this step, of course, if you have patience It is nothing happens here. Mkinitrd can make initrd.img, usually so used, if you want to know, you can man mkinitrd, if you just want to make itrd.img, then mkinitrd / boot / initrd- Custom.IMG 2.4.22 creates an initrd-custom.img file in the / boot directory, which is mainly driving in the initial mirror ... (Initialed Ramdisk) ... There are main drives, because it is too large in the kernel, so compile INITRD.IMG, released in the startup ... and this 2.4.22 represents the 2.4.22 directory below / lib / modules ... here, there are two practices ... one manually updates the system.map file it is current The instructions of the FUCTIONS that is running, if you do not update system.map after you compile the kernel, if you encounter the problem. Trouble Shooting is very difficult, you may have many annoying information, so we still update manually Once, it is also very simple ... #cp /usr/src/linux-2.4.22/system.map /boot/system.map system will prompt you: Overwrite the 'boot / system.map' knock Y, Enter Two Make Installs said that Make Install is a bit a bit here. Make Install is equivalent to an automated process, because other stasides will help you do it, if you are too lazy, or have already paired the front The steps have been very patient, you can do this step directly ... Of course, you can do a new system soon, and you can re-started from the new kernel, but you may not understand the things happened in this. Oh, hour When I was in class, my teacher talked about what to teach, but not to teach fish, no way.

If you feel trouble, you will save it, you still feel tired, huh, huh :) Or talk about this process, during this time, the system will add a Customa after your current Release version number and then write it in Grub.conf Go, you can see the selection of 2.4.22customes after restarting ... As for this file name, how is this file name? You can take a look at /usr/src/linux-2.4.22, there is a makefile, you tried #haoad -n 5 makefile, I have already seen it ... this is the reason for named, so you also You can modify your Linux yourself ... your own release name is uncomfortable ... From the above steps, it is basically no problem. Of course, please confirm that you have not had any mistakes in Make Menuconfig, otherwise After restarting, it is still guided, such as the FS must select VFS, EXT3 compile to M, because the system is generally used in EXT3 format, you want to miss this stuff, you can't load the partition, you can't tell me, I don't tell you. You, of course, SECOND EXTENDED FS must be chosen :) I have a VFS: Unable to mount root fs on 00:00 in history, I haven't solved it for a long time, but later Finally, I found that I should be FS, or if your root partition is not specified .. I have seen so much. I believe you are also very tired, the post is coming to the head, because it is finished ... (If you choose Make Install, here you don't have to watch it) The most first thing, we want to modify GRUB.CONF (if If you use GRUB to guide, I don't know Lilo, because I am also a rookie ...), so that the system can start from the new kernel after restarting ... #VI /BOOT/Menu.lst menu.lst with grub.conf content Yes, it is a link, but this is a colorful text. I like it very much. It is edited it .. Add a line on the original basis: Title New Linux (2.4.22) // Here you can name yourself, That is, in the GRUB startup menu, the "kernel /Vmlinuz-2.4.22 RO root = label = / this line is the path to the Kernel, remember to generate a new kernel of VMLinuz-2.4.22 before we have? Yes, it is it ... Here, it is specified here. After you choose to start with this option, you will use the new kernel here. The RO followed by the RE is readonly, it is read-only, root = label = / Is the specified path initrd.img here to specify the initrd.img you make, if this makes a wrong, you can't start ... Of course, this is what you use the SCSI hard drive, if it is The IDE hard drive.

转载请注明原文地址:https://www.9cbs.com/read-125913.html

New Post(0)