Linux source change + kernel compilation summary, linux kernel compilation Summary
Source exchange:
I use CentOS, so the following uses it as an example. Other OS practices are similar and can be used as a reference;
When the host is connected to the Internet
Enter the folder for storing the source configuration
cd /etc/yum.repos.d
Backup default Source
mv ./CentOS-Base.repo ./CentOS-Base.repo.bak
Use wget to download the source http://mirrors.163.com/.help/centos.html of 163
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
Set the downloaded file CentOS-Base-163.repo to the default Source
mv CentOS6-Base-163.repo CentOS-Base.repo
After the above operations, the default source is changed to 163. Of course, the Steps 3 and 4 can be merged as follows:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O CentOS-Base.repo
Run yum makecache to generate Cache
yum makecache
Update all
yum update
When the host cannot be connected to the InternetNow download the source settings http://mirrors.163.com/.help/CentOS6-Base-163.repo on windows to enter the folder that stores the source configuration
cd /etc/yum.repos.d
Upload the downloaded Source
rz
Delete Original Source
rm CentOS-Base.repo
Set the downloaded file CentOS-Base-163.repo to the default Source
mv CentOS6-Base-163.repo CentOS-Base.repo
Run yum makecache to generate Cache
yum makecache
Update all
yum update
Compile and upgrade the kernel: download the required version of the kernel file from www.kernel.org: Use the linux-3.19.3.tar. xz file as an example to connect to the linux host using xshell, or log on to the linux host using the rz command to upload the Kernel File.
rz
Decompress the Kernel File
Xz-dk linux-3.19.3.tar.xz // If xz not found is prompted, change the source for yum and use yum install xz
Continue unzipping and get the folder: linux-3.19.3
tar xvf linux-3.19.3.tar
Enter the obtained folder
cd linux-3.19.3
Use yum to install and compile the required compiling environment
yum install -y gcc make bison ncurses-devel rpm-build
Copy the configuration file compiled by the existing Kernel
cp /boot/config-`uname -r` .config
If you want to use the old Kernel configuration and automatically receive the default settings for each new option
sh -c 'yes "" | make oldconfig'
Go to menu Configuration
make menuconfig
Set whether to select the option "[] 64-bit kernel" as required, press 'y' to select, and 'n' to cancel entering General setup, check "Enable deprected sysfs features to support old userspace tools" to generate the kernel file, which is usually generated in the/usr/src/arch/x86/boot directory.
make bzImage
Compile the kernel module
make modules
Install the new kernel modules and place them in the corresponding positions.
Make modules_install // the preceding three steps can also be written as follows: // make bzImage & make modules & make modules_install
Install Kernel
make install
Set the System Boot manager to start from the new kernel
Vi/etc/grub. conf // change default = 1 to default = 0, save and exit
Restart the system
reboot
Verify the kernel version
uname -a
!!! Any of the above compilation errors must be re-compiled !!! Run it first! Clear temporary files during installation
make mrproper//make clean
Repeat the compilation steps. PS: there are only two errors below. The others are collected during the solution process. If your rights and interests are violated, please let us know how to delete them. Thank you ~
Error 1:In file encoded ded from/usr/include/sys/time. h: 31, from/usr/include/linux/input. h: 12, from samples/hidraw/hid-example.c: 14:/usr/include/sys/select. h: 78: Error: conflict with 'fd _ set' type/usr/include/linux/types. h: 12: error: the previous declaration of 'fd _ set' is In file encoded ded from/usr/include/linux/input. h: 14, from samples/hidraw/hid-example.c: 14:/usr/include/sys/types. h: 62: Error: conflict with 'dev _ t' type/usr/include/linux/types. h: 13: Error: Previous 'dev _ t' Declare it here/usr/include/sys/types. h: 67: Error: conflict with 'Gid _ t' type/usr/include/linux/types. h: 27: error: the previous declaration of 'Gid _ T' is here/usr/include/sys/types. h: 72: Error: conflict with 'mode _ t' type/usr/include/linux/types. h: 15: error: the previous declaration of 'Mode _ T' is here/usr/include/sys/types. h: 77: Error: conflict with 'nlink _ t' type/usr/include/linux/types. h: 16: error: the previous declaration of 'nlink _ T' is here/usr/include/sys/types. h: 82: Error: conflict with the 'uid _ t' type/usr/include/linux/types. h: 26: error: the previous declaration of 'uid _ T' is In fil E required ded from/usr/include/sys/types. h: 133, from/usr/include/linux/input. h: 14, from samples/hidraw/hid-example.c: 14:/usr/include/time. h: 105: Error: conflict with 'timer _ t' type/usr/include/linux/types. h: 22: error: the previous declaration of 'timer _ T' is In file encoded from/usr/include/linux/input. h: 14, from samples/hidraw/hid-example.c: 14:/usr/include/sys/types. h: 235: Error: conflict with 'blkcnt _ t' type/usr/include/linux/types. h: 114: Error: 'blkcnt _ t' A declaration here samples/hidraw/hid-example.c: 15: 26: Error: linux/hidraw. h: No file or directory samples/hidraw/hid-example.c: In function 'main': samples/hidraw/hid-example.c: 48: Error: 'rpt _ desc' storage size unknown samples/hidraw/hid-example.c: 49: Error: 'info' storage size unknown samples/hidraw/hid-example.c: 65: Error: 'hidiocgrdescsize' is not declared (used for the first time in this function) samples/hidraw/hid-example.c: 65: Error :( even if it appears multiple times in a function, each undeclared identifier is reported only in its samples/hidraw/hid-example.c: 65: Error: Function Once .) Samples/hidraw/hid-example.c: 73: Error: 'hidiocgrdesc' not declared (used for the first time in this function) samples/hidraw/hid-example.c: 84: Warning: implicit declaration function 'hidiocgrawname' samples/hidraw/hid-example.c: 91: Warning: Implicit declaration function 'hidiocgrawphys 'samples/hidraw/hid-example.c: 98: Error: 'hidiocgrawinfo' is not declared (used for the first time in this function) samples/hidraw/hid-example.c: 49: Warning: unused variable 'info' samples/hidraw/hid-example.c: 48: Warning: unused variable 'rpt _ desc' samples/hidraw/hid-example.c: In function 'bus _ str': samples/hidraw/hid-example.c: 171:
Error: 'bus _ virtual' is not declared(Used for the first time in this function)
Make [2]: *** [samples/hidraw/hid-example] Error 1
Make [1]: *** [samples/hidraw] Error 2
Make: *** [vmlinux] Error 2
Solution:
cp include/linux/hidraw.h /usr/include/linux/cp include/linux/hid.h /usr/include/linux/vi samples/hidraw/hid-example.c
Move the following three rows in the row 13-15 to the row 33.
13 #include <linux/types.h> 14 #include <linux/input.h> 15 #include <linux/hidraw.h> 29 #include <sys/ioctl.h> 30 #include <sys/types.h> 31 #include <sys/stat.h> 32 #include <fcntl.h> 33 #include <unistd.h>
Continue to modify
vi /usr/include/linux/input.h
Locate row 647 # define BUS_PCI 0x01 # define BUS_ISAPNP 0x02 # define BUS_USB 0x03 # define BUS_HIL 0x04 # define BUS_BLUETOOTH 0x05
/* Add the following line */
#define BUS_VIRTUAL 0x06
# Define BUS_ISA 0x10 # define BUS_I8042 0x11 # define BUS_XTKBD 0x12 # define BUS_RS232 0x13 # define BUS_GAMEPORT 0x14 # define BUS_PARPORT 0x15 # define BUS_AMIGA 0x16 # define BUS_ADB 0x17 # define BUS_I2C 0x18 # define BUS_HOST 0x19 # define BUS_GSC 0x1A/* add two more lines --- statement */
#define BUS_ATARI 0x1B#define BUS_SPI 0x1C
Or
Go to the settings menu
make menuconfig
Go to the "kernel hacking" option and deselect the check box: "sameple kernel code" because it references the include header file by default and does not compile it!
Error 2:
Error message:Compilation error, unknown storage size
Solution:These two header files can eliminate errors and warnings.
vi samples/hidraw/hid-example.c
New
#include <arpa/inet.h>#include <netinet/in.h>
Error 3:
Error message:Kernel panic-not syncing: vfs: unable to mount root fs on unkown-block (0, 0)
Error analysis:The initrd-*. *. imgfile is faulty. The real root file system cannot be mounted successfully.
Solution:Please
Confirm that the make install command is executed.
Error 4:
Error message:Create root device mkrootdev: label/not found
Mountingrootfilesystem
Mount: error2 mounting ext3
Mount: error 2 mountingnone
Switch root mount failed: 22
Umount/initrd/dev failed: 2
Kernel panic-not synicncing: Attempted to kill init.
Error analysis:
1. the mount point cannot be found in the root file system. Change grub. conf to root =/dev /*
2. Hard drive cannot be found. Please check whether your machine's hard drive is a SATA disk. If yes, congratulations! This article is helpful to you.
Solution:
1. Try to modify the grub. conf file.
Root =/dev/* // * indicates the mount point of/partition in the original system.
After the modification, restart and enter the new kernel system. The following error message is displayed:
Mounting root filesystem
Mount: error6 mounting ext3
Mount: error 2 mountingnone
Switchroot mount failed: 22
Umount/initrd/dev failed: 2
Kernel panic-not synicncing: Attempted tokil linit.
If you really kneel down, continue reading it ~ 2. The hard drive fails to be found, and the SCSI driver is faulty.
This is the kernel option.
Device Drivers -------- SCSI
Device support ------ SCSI
Low-level drivers ---- Serial ATA (SATA) support is selected as M,
Then select the corresponding sub-options
Intel PIIX/ich sata support (new)After the configuration, the machine starts successfully.
Error 5:
Error message:Enforcing mode requested but no policy loaded. Halting now.
Kernel panic-not syncing: Attenpted to kill init!
Error analysis:Selinux is enabled in the original kernel. selinux is not selected in the new kernel and cannot be started successfully.
Solution: Modify the grub. conf file and add enforcing = 0 after root = LABEL = /.
Error 6:
After the compilation is restarted, the following error occurs:
Switchroot: mount failed: 22
Umount/initrd/dev failed: 2
Kernel panic-not symcing: Attempted to kill init!
Error,
Solution:
Re-make menuconfig to make CONFIG_SYSFS_DEPRECATED_V2 = y
You can also open the file. config for modification and verification;
Run the following command:
# Make bzImage
# Make modules
# Make modules_install
# Make install
# Shutdown-r "now"