Current location - Quotes Website - Personality signature - linux kernel video tutorial full set of linux kernel video tutorial
linux kernel video tutorial full set of linux kernel video tutorial

How to install a new kernel for linux?

1. Obtain the kernel source code

2. Decompress the kernel source code

First log in with the root account, and then enter the /usr/src subdirectory. If the user installs the kernel source code when installing Linux, he or she will find a subdirectory of linux-x.y.z. This directory stores the source code of kernel x.y.z. Additionally, you will find a link to the directory linux. Delete the connection, then copy the source files of the new kernel to the /usr/src directory, and decompress:

#tarzxvfLinux-2.3.14.tar.gz

The file was released successfully After that, a linux subdirectory will be generated in the /usr/src directory. It contains all the source code of kernel 2.3.14. Link /usr/include/asm, /usr/inlude/linux, and /usr/include/scsi to the corresponding directories under the /usr/src/linux/include directory.

#cd/usr/include

#rm-Rfasmlinux

#ln-s/usr/src/linux/include/asm-i386asm

#ln-s/usr/src/linux/include/linuxlinux

#ln-s/usr/src/linux/include/scsiscsi

Delete the source code directory .o files and other dependent files remaining in the .

#cd/usr/src/linux

#makemrproper

3. Incremental patches

Sometimes it is not necessary to completely reinstall. Just apply an incremental patch, similar to an upgrade, and run it in the root directory of the kernel source tree:

patch-p1../patch-x.y.z

4. Kernel source tree directory:

patch-p1../patch-x.y.z

p>

arch: Contains code related to the hardware architecture. Each platform occupies a corresponding directory. Code related to 32-bit PCs is stored in the i386 directory. The more important ones include kernel (core part of the kernel), mm (memory management), math-emu (floating point unit simulation), lib (hardware-related tool functions), boot (boot program), pci (PCI bus) and power (CPU related status).

block: Some block device drivers.

crypto: commonly used encryption and hashing algorithms (such as AES, SHA, etc.), as well as some compression and CRC verification algorithms.

Documentation: General explanations and comments about various parts of the kernel.

drivers: device drivers, each different driver occupies a subdirectory.

fs: Various supported file systems, such as ext, fat, ntfs, etc.

include: header file. Among them, system-related header files are placed in the linux subdirectory.

init: kernel initialization code (note not system boot code).

ipc: code for inter-process communication.

Kernel: The core part of the kernel, including process scheduling, timers, etc. Some code related to the platform is placed in the arch/*/kernel directory.

lib: library file code.

mm: Memory management code, part of the code related to the platform is placed in the arch/*/mm directory.

net: Network-related code, which implements various common network protocols.

scripts: Script files used to configure kernel files.

security: Mainly a SELinux module.

sound: Drivers for commonly used audio devices, etc.

usr: implements a cpio.

Under the i386 system, the system boot will start from arch/i386/kernel/head.s, and then transfer to the main() function in init/main.c to initialize the kernel.

5. Configure the kernel

#cd/usr/src/linux

There are three kernel configuration methods:

(1) Command Line: makeconfig

(2) Menu mode configuration interface: makemenuconfig

(3)Xwindow: makexconfig

The Linux kernel configuration program provides a series of configurations options. For each configuration option, the user can select "y", "m", or "n".

Among them, "y" means compiling the corresponding feature support or device driver into the kernel; "m" means compiling the corresponding feature support or device driver into a loadable module, which can be added to the kernel by the system or the user when needed. Go; "n" indicates that the kernel does not provide support for the corresponding feature or driver. Since there are many configuration options for the kernel, this article only introduces some of the more important options.

1. Codematurityleveloptions (code maturity options)

Promptfordevelopmentand/orincompletecode/drivers(CONFIG_EXPERIMENTAL) If the user wants to use code or drivers that are still in the testing stage, they can select "y" . If you want to compile a stable kernel, select "n".

2. Processortypeandfeatures (processor type and features)

(1), Processorfamily(386,486/Cx486,586/K5/5x86/6x86,Pentium/K6/TSC,PPro/ 6x86MX) Select the processor type, the default is Ppro/6x86MX.

(2), MaximumPhysicalMemory (1GB, 2GB) The maximum number of memory supported by the kernel, the default is 1G.

(3), Mathemulation (CONFIG_MATH_EMULATION) coprocessor simulation, the default is not to simulate.

(4), MTRR(MemoryTypeRangeRegister)support(CONFIG_MTRR)

Select this option, the system will generate the /proc/mtrr file to manage MTRR for use by Xserver.

(5) Select "y" for Symmetricmulti-processingsupport (CONFIG_SMP), and the kernel will support symmetric multi-processors.

3. Loadablemodulesupport (loadable module support)

(1) Select "y" for Enableloadablemodulesupport (CONFIG_MODULES), and the kernel will support loading modules.

(2) If "y" is selected for Kernelmoduleloader(CONFIG_KMOD), the kernel will automatically load those loadable modules, otherwise the user needs to load them manually.

4. Generalsetup (general settings)

(1) Networkingsupport (CONFIG_NET) This option sets whether to provide network support in the kernel.

(2) PCIsupport(CONFIG_PCI) This option sets whether to provide PCI support in the kernel.

(3) PCIaccessmode (BIOS, Direct, Any) This option sets the way Linux detects PCI devices. Select "BIOS" and Linux will use the BIOS; select "Direct" and Linux will not pass the BIOS; select "Any" and Linux will directly detect the PCI device and use the BIOS if it fails.

(4) Select "y" for Parallelportsupport(CONFIG_PARPORT), and the kernel will support parallel ports.

5. PlugandPlayconfiguration (plug-and-play device support)

(1) Select "y" for PlugandPlaysupport(CONFIG_PNP), and the kernel will automatically configure the plug-and-play device.

(2) Select "y" for ISAPlugandPlaysupport(CONFIG_ISAPNP), and the kernel will automatically configure the plug-and-play device based on the ISA bus.

6. Blockdevices (block devices)

(1) Select "y" for NormalPCfloppydisksupport(CONFIG_BLK_DEV_FD), and the kernel will provide support for floppy disks.

(2) Select "y" for EnhancedIDE/MFM/RLLdisk/cdrom/tape/floppysupport(CONFIG_BLK_DEV_IDE), and the kernel will provide support for enhanced IDE hard disks, CDROMs and tape drives.

7. Networkingoptions (network options)

(1) Select "y" for Packetsocket (CONFIG_PACKET). Some applications will use the Packet protocol to communicate directly with the network device without passing Other intermediary protocols in the kernel.

(2) Select "y" for Networkfirewalls (CONFIG_FIREWALL), and the kernel will support firewalls.

(3) Select "y" for TCP/IP networking (CONFIG_INET), and the kernel will support the TCP/IP protocol.

(4) If "y" is selected for TheIPXprotocol(CONFIG_IPX), the kernel will support the IPX protocol.

(5) If "y" is selected for AppletalkDDP (CONFIG_ATALK), the kernel will support the AppletalkDDP protocol.

8. SCSIsupport (SCSI support)

If the user wants to use SCSI devices, the corresponding options can be configured.

9. Networkdevicesupport (network device support)

Select "y" for Networkdevicesupport (CONFIG_NETDEVICES), and the kernel will provide support for network drivers.

10. Ethernet (10or100Mbit) (10M or 100M Ethernet)

In this setting, the system provides many network card drivers. Users only need to choose their own network card driver. . In addition, users can also add support for FDDI, PPP, SLIP and Wireless LAN (WirelessLAN) to the kernel as needed.

11. Characterdevices (character devices)

(1) Select "y" for Virtualterminal (CONFIG_VT), and the kernel will support virtual terminals.

(2), Supportforconsoleonvirtualterminal(CONFIG_VT_CONSOLE)

Select "y", the kernel can use a virtual terminal as the system console.

(3), Standard/generic(dumb)serialsupport(CONFIG_SERIAL)

Select "y", the kernel will support the serial port.

(4), Supportforconsoleonserialport(CONFIG_SERIAL_CONSOLE)

Select "y", the kernel can use a serial port as the system console.

12. Mice (mouse)

PS/2mouse(aka "auxiliarydevice")support(CONFIG_PSMOUSE) If the user is using a PS/2 mouse, this option should select "y ".

13. Filesystems (file system)

(1) Select "y" for Quotasupport (CONFIG_QUOTA), and the kernel will support disk quotas.

(2) Select "y" for Kernelautomountersupport(CONFIG_AUTOFS_FS), and the kernel will provide support for automounter, allowing the system to automatically mount remote file systems at startup.

(3) Select "y" for DOSFATfssupport(CONFIG_FAT_FS), and the kernel will support the DOSFAT file system.

(4), ISO9660CDROMfilesystemsupport(CONFIG_ISO9660_FS)

Select "y", the kernel will support the ISO9660CDROM file system.

(5), NTFSfilesystemsupport(readonly)(CONFIG_NTFS_FS)

Select "y", the user can access the NTFS file system in read-only mode.

(6), /procfilesystemsupport(CONFIG_PROC_FS)/proc is a virtual file system that stores the running status of the Linux system. "y" must be selected for this item.

(7), Secondextendedfssupport(CONFIG_EXT2_FS) EXT2 is the standard file system of Linux, and "y" must also be selected for this item.

14. NetworkFileSystems (network file system)

(1) Select "y" for NFSfilesystemsupport(CONFIG_NFS_FS), and the kernel will support the NFS file system.

(2), SMBfilesystemsupport(tomountWfWsharesetc.)(CONFIG_SMB_FS)

Select "y", the kernel will support the SMB file system.

(3), NCPfilesystemsupport(tomountNetWarevolumes)(CONFIG_NCP_FS)

Select "y", the kernel will support the NCP file system.

15. PartitionTypes (partition type)

This option supports some less commonly used partition types. If the user needs, just select "y" on the corresponding option.

16. Consoledrivers (console driver)

Select "y" for VGAtextconsole (CONFIG_VGA_CONSOLE), and users can use Linux in the standard VGA display mode.

17. Sound (Sound)

Select "y" for Soundcardsupport(CONFIG_SOUND), and the kernel can provide support for the sound card.

18. Kernelhacking (kernel monitoring)

If MagicSysRqkey (CONFIG_MAGIC_SYSRQ) selects "y", the user can partially control the system. Normally select "n".

6. Compile the kernel

(1). Create dependent files required for compilation

#cd/usr/src/linux

< p>#makedep

(2). Clear the target files compiled by the kernel

#makeclean

(3). Compile the kernel

#makezImage

After the kernel is compiled successfully, a new kernel image file zImage will be generated in the /usr/src/linux/arch/i386/boot directory. If the compiled kernel is large, the system will prompt you to use the makebzImage command to compile. At this time, the compiler will generate a kernel image file named bzImage.

(4) Compile loadable modules

If the user sets loadable modules when configuring the kernel, these modules need to be compiled so that they can be loaded using the insmod command in the future.

#makemodules

#makemodelus_install

After successful compilation, the system will generate a 2.3.14 subdirectory in the /lib/modules directory, which contains the new All loadable modules of the kernel.

7. Start the new kernel

(1) Copy the new kernel and System.map file to the /boot directory

#cp/usr/src /linux/arch/i386/boot/bzImage/boot/vmlinuz-2.3.14

#cp/usr/src/linux/System.map/boot/System.map-2.3.14

#cd/boot

#rm-fSystem.map

#ln-sSystem.map-2.3.14System.map

(2) , configure the /etc/lilo.conf file. Add the following lines to the file:

default=linux-2.3.14

image=/boot/vmlinuz-2.3.14

label=linux -2.3.14

root=/dev/hda1

read-only

(3). Make the new configuration take effect

# /sbin/lilo

(4) Restart the system

#/sbin/reboot

If the new kernel cannot start normally, the user can prompt in LILO: Boot the old kernel under the command. Then find out the cause of the failure and recompile the new kernel.

How to install LinuxKernel (Linux kernel)?

1. Download the new kernel source code: Go to the official website www.kernel.org, download the latest version of the Linux kernel, and save it to the /usr/src/kernels directory, which is about 54MB.

2. #cd/usr/src/kernels

3. #tarjvxflinux-2.6.31.5.tar.bz2

4. Enter the original kernel directory of the system , copy the hidden file .config to the new kernel directory.

5. cd to enter the new kernel directory, and then execute #makeoldconfig. At this time, press Enter on all prompts, and the option prompts are all default.

6. #makexconfig At this time, a kernel configuration window pops up, which is all in English. I can’t understand it, so I just close the window and continue.

7. #makebzImagemakemodulesmakemodules_installmakeinstall The seventh step of compilation takes a long time, ranging from 30 to 50 minutes, depending on the machine condition.

8. #uname-r Check the kernel version. After completing the above steps, you can restart the system. The new kernel option will appear in the GRUB menu during startup. This method will also keep the old kernel after installing the new kernel. When starting, you can choose between the new and old kernels, which is quite practical

How to modify the Linux kernel source code and debug it?

Add the modified code into the kernel tree, then modify the makefile and config files, and recompile.