Kernel compilation:
Step 1: Configure kernel compilation options.
make menuconfig
Optional Step: Excludes dependencies between compilation result files (. o) and so on.
make mrproper
Optional Step: Clears the historical compilation results.
make clean
Step 2: Compile the kernel.
#编译内核#编译各内核模块,如驱动等。#将编译好的模块安装至 /lib/modules/x.xx.x 目录下。
Step 3: Generate the initial disk image initrd.img.
cd linux-source-x.xx.x/.config#复制配置文件至/boot目录cp.config /boot/config-x.xx.x#x.xx.x 对应 /lib/modules/x.xx.x 目录。# -o 指示了镜像的输出目录。sudo mkinitramfs -o /boot/initrd.img-x.xx.xx.xx.x
Step 4: Modify the Grub configuration.
Copy an existing boot entry entry in/boot/grub/grub.cfg and modify the kernel-related file address to the location of the new kernel-related file.
Such as:
Copy the next paragraph:
Menuentry' Ubuntu,linux 3.2.0-36-generic-pae ' --Class Ubuntu--Class GNU-linux --Class GNU--Class OS {recordfail Gfxmode$linux _gfx_modeInsmod Gzio insmod part_msdos insmod ext2SetRoot=' (hd0,msdos1) 'Search--No-floppy --Fs-uuid --Set=Root7b4e922c-d943-4b84-9C75-4fdc57cf1a3f Linux/boot/vmlinuz-3.2. 0- $-generic-paeRoot=Uuid=7b4e922c-d943-4b84-9C75-4fdc57cf1a3f ro Quiet Splash$VT _handoffInitrd/boot/initrd.Img-3.2. 0- $-generic-pae}
Modified to:
Menuentry' Test,linux 3.7.4 ' --Class Ubuntu--Class GNU-linux --Class GNU--Class OS {recordfail Gfxmode$linux _gfx_modeInsmod Gzio insmod part_msdos insmod ext2SetRoot=' (hd0,msdos1) 'Search--No-floppy --Fs-uuid --Set=Root7b4e922c-d943-4b84-9C75-4fdc57cf1a3f Linux/boot/core/vmlinuz-3.7. 4Root=Uuid=7b4e922c-d943-4b84-9C75-4fdc57cf1a3f ro Quiet Splash$VT _handoffInitrd/boot/core/initrd.Img-3.7. 4}
Step 5: Testing
Press ESC when the virtual machine starts, forcing you to enter the Grub boot menu.
Select ' Test,linux 3.7.4 in the menu, initialize the system with the newly compiled kernel, look at the boot process, see if there is an exception, if everything is OK, the kernel compiles correctly, and vice versa, you need to continue to modify the compilation options.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux Kernel compilation test