In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what are the methods of Linux kernel transplantation". In the daily operation, I believe that many people have doubts about the methods of Linux kernel transplantation. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what are the methods of Linux kernel transplantation?" Next, please follow the editor to study!
Method 1: compile and replace the source code package provided by kernel. 1. First, prepare the kernel before compilation.
There are two main preparations, one is to download the source code package on the linux kernel official website, and the other is to install any version of the linux Ubuntu system and download the corresponding compilation tools.
Download the source code package on linux kernel, as shown below: take linux_3.2.1 as an example:
After the download is complete, carry on the second preparation work, install any version of Ubuntu, just like any other operating system, install the Ubuntu operating system, and then configure the network to download apk_get. The following procedure is performed under root permissions to install the relevant compiler. Install make, gcc, make-kpkg, run menuconfig and other tools related to compiling the kernel.
Relevant orders:
$sudo apt-get install build-essential kernel-package libncurses5-dev
Note:
(1) libncurses5-dev is the preparation for configuring the kernel to run the make menuconfig program. Build-essential is the compilation tool, and kernel-package is the kernel compilation tool.
(2) if the system shows that the three files cannot be found, enter # apt-get update to update the data source. Copy the source code package you just downloaded into the ubuntu system and decompress it to the / usr/src directory. You can right-click and decompress the package, or use the following command to decompress:
$sudo tar Jvfx linux-3.4.88.tar.xz2, related files and environment for starting configuration compilation
First, clean up the temporary files left behind during previous compilation. If you have just unpacked the package, you do not need to perform this step. If it is the second or nth compilation, be sure to execute it. The relevant commands are as follows:
# $sudo make mrproper
Then copy the configuration file of your original kernel to become the configuration file of the new kernel, and command:
# cp / boot/config- `uname-r`. / .config
It should be noted here that it is very convenient to copy it over, which is equivalent to directly providing the corresponding configuration files for the new kernel compilation, telling the kernel which files to compile and which do not need to be compiled, but after several compilation modifications, this part can be customized, using the tool we downloaded earlier, menuconfig.
Enter the source directory of the kernel
# cd / usr/src/linux_3.2.1
Execute the following command:
# make menuconfig
Note: this command needs to be executed under superuser privileges, otherwise some strange errors may be reported. After executing this command, you can see the following picture:
In this figure, you can make a modification to the configuration file. If you copied the configuration file of the original kernel directly, select load an Alternate Configuration File on the penultimate line at this time, and then sava.
If you configure yourself, select any of the above directories to select which files to compile and which do not compile, generally need to choose the device driver, the option is Device Drivers, after the selection is also saved save.
3. Start compiling the new kernel
Compile command:
# make all-j4
After executing the above command, you can compile the kernel. Make all compiles the kernel and the module together. The following parameter,-j4, indicates that cpu starts four threads to compile the kernel. Generally speaking, each cpu can open two threads to compile the kernel. My computer has two cpu, so four threads are started. Compiling in this way is really fast. I haven't found such compilation before, and only one thread can really wait a long time.
4. After the compilation is complete, you can install the kernel.
We copied the arch/x86_64/boot/bzImage under the source code directory to / boot/, because the source code version I downloaded is linux-3.2.1, but I need to look for bzImage in the appropriate directory depending on my cpu type, such as x86 architecture or amd, or 32-bit or 64-bit. So the command to copy is:
# cp arch/x86_64/boot/bzImage / boot/vmlinuz-3.2.1
Need to be explained here, bzImage must have, is a successful compilation of a generated file, if there is no this file, sorry, compilation failed, please go back to compile. Vmlinuz-3.2.1 orders on its own initiative and can be changed by itself, but it is generally this way of command.
5. Copy the System.map from the source code directory to the / boot directory:
Command:
# cp / usr/src/linux-3.2.1/System.map System.map-3.2.16 、. Copy .config from the source code directory to the / boot/ directory:
Command:
# cp .config / boot/config-3.2.17, installation module
Command:
# make modules_install8, generate initrd.img file # cd / lib/modules/3.2.1#update-initramfs-c-k 3.2.19,. Change to the / boot/grub/ directory, automatically find the new kernel, add it to grub boot # update-grub10, and modify the startup interval of boot grub, as follows: # cd / ect/default#sudo nano. / grub
Comment out the two lines of hidden so that the boot grub will appear, and you can choose which kernel version to start.
# GRUB_HIDDEN_TIMEOUT=0#GRUB_HIDDEN_TIMEOUT_QUIET=true
After the changes are complete, after regenerating the grub.cfg file, the command is the same as above:
# update-grub11, change to the grub.cfg directory
Check in text to see if the startup entry of the new kernel is updated. If so, there is no need to modify it. If not, modify it manually.
# cd / boot/grub#sudo nano. / grub.cfg
Modify it manually, according to the format of the original kernel, only by changing the name of the new kernel.
12. Restart the computer, select the newly compiled kernel in previous version, and successfully enter the system.
Enter the kernel version detection command:
Command: # uname-r
The name of the new kernel will appear! Congratulations, the kernel has been replaced successfully!
Method 2: download the kernel installation package deb to upgrade and replace
First of all, I have tried two computers in this way, and two different kernel upgrades have been successful. The reasons are unknown: the specific steps are as follows:
1. Download the deb package
Downloaded here are three 64-bit version 3.5.4 deb packages:
Linux-headers-3.5.4-030504 030504-generic_3.5.4 3.5.4-030504.201209142010_all.deblinux-headers-3.5.4-030504-generic_3.5.4-030504.201209142010_amd64.deblinux-image-3.5.4-030504-generic_3.5.4-030504.201209142010_amd64.deb2. Install debit package
First install the architecture-independent headers package with all
Sudo dpkg-I linux-headers-3.5.4-030504 030504.201209142010_amd64.debsudo dpkg 3.5.4-030504.201209142010_all.debsudo dpkg-I linux-headers-3.5.4-030504-generic_3.5.4-030504.201209142010_amd64.debsudo dpkg-I linux-image-3.5.4-030504-generic_3.5.4-030504.201209142010_amd64.deb
After installation, files related to the new kernel are generated in the / boot directory, and the corresponding modules are generated in the / lib/modules directory.
3. Update startup item grub
Follow step 9 above, as above. Update the grub.cfg, and then restart, the new kernel test can be carried out in accordance with this step, but after booting to enter the direct purple screen, there is no phenomenon, the reason is unknown!
At this point, the study of "what are the methods of porting Linux kernel" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.