Linux kernel compilation, management, and kickstart and boot image creation
Kernel Composition: Core file:/boot/vmlinuz-version
Module Management: Lsmod command: List the modules already loaded/Another way: # Cat/proc/modules
-N Module Name: Show only module file path
In the information shown:
Depends: Displays the other modules that are dependent on this module;
modprobe command: Implementation of module loading and unloading
Load: modprobe mod_name
Module file loading and unloading
Load: Insmod command
Insmod/path/to/module_file
Note: Dependencies are not automatically resolved;
Example: Insmod ' modinfo-n ext3 '
Uninstall: Rmmod command
Rmmodmod_name
Interacting with the kernel:
/proc pseudo File System interface
Each file name is a kernel parameter, and the directory name is the kernel parameter node (subsystem or sub-function) information;
Example: Net.ipv4.ip_forward = 1
/proc/sys/net/ipv4/ip_forward
Read-only files under/proc: Output kernel information
Read and write files under/proc: Modifiable kernel operating features/proc/sys directory
Pseudo file system: file cannot be edited directly using Editor; Modify method:
1 echo
echo "New_value" >/proc/sys/path/to/somefile
Example: echo "LX" >/proc/sys/kernel/hostname
2 sysctl-w
Sysctl-w Path.to.somefile=new_value
Example:/proc/sys/net/ipv4/ip_forward
echo "1" >/proc/sys/net/ipv4/ip_forward
Sysctl-w net.ipv4.ip_forward=1
Note: These two settings take effect immediately, but after the kernel restarts, it is invalid;
3 Kernel parameter configuration file/etc/sysctl.conf
SYS pseudo file System interface: Pseudo file system: SYSFS; Mainly used for outputting the relevant property information of each hardware device identified by the kernel, and also allowing the user to modify the value of some parameters to change the working characteristics of the hardware;
User-Space Applications: Udev creates device files for each hardware device detected by the current kernel by reading the information about the hardware device stored in the/sys directory, and the properties for creating the file permissions and names of the device files are customizable;
Udev has rules files:/etc/udev/rules.d/
Modify the network card device name; vim/etc/udev/rules.d/70-persistent-net; to be effective, first uninstall the network card module, in the installation can be, that modprobe-r e1000 in Modprobe e1000
uname command:-r: The release number of the kernel;-N: hostname;-A: Displays all information; RAMDisk production:
Centos5:mkinitrd
Centos6:dracut, MKINITRD
Dracut [OPTION] ... <image> <kernel-release>
-M list: module list/-d list: driver lists
#dracut/boot/initramfs-$ (UNAME-R). IMG $ (UNAME-R)
Modify:
Expand Initramfs File:
#cp initramfs-2.6.32-504.el6.x86_64.img/tmp
#cd/tmp
#mv initramfs-2.6.32-504.el6.x86_64.img initramfs-2.6.32-504.el6.x86_64.img.gz
#gzip-D initramfs-2.6.32-504.el6.x86_64.img
#mkdir RAMDisk
#cd RAMDisk
#cpio-id <. /initramfs-2.6.32-504.el6.x86_64.img
Archive:
#find. | Cpio-o-H newc--quiet >/boot/myramdisk.img
#gzip/boot/myramdisk.img
#mv/boot/myramdisk.img.gz/boot/myramdisk
Common Kernel parameters:/proc/sys
Kernel.hostname: Host Name
Net.ipv4.ip_forward: The router function of native, turn on or off the function that forwards the message between the interface;
/proc/sys/net/ipv4/icmp_echo_ignore_all:0 indicates that everyone's ping request is not ignored, and 1 indicates that ignoring
Wkiol1uybcydrtenaaa0qgnfjpm340.jpg
Kernel compilation:
1) to fully know the target hardware equipment information;
2) fully informed of the target system platform of the relevant information, such as file system type;
3) new features that are intended to be enabled;
4) Prepare the software development environment and kernel source code tree;
Device information:
1) CPU
#cat/proc/cpuinfo
#lscpu
#x86info-A
2) PCI
#lspci [-v]
#lsusb [-v]
#lsblk
3) Hal-device
Hal:hardware abstract Layer
Development environment
(1) Install the Development Pack Group: Development Tools, Server Platform Development
(2) Get the kernel source: www.kernel.org
Kernel compilation Steps
1. Unzip the kernel source
TAR-JXF LINUX-3.10.67.TAR.XZ
2. Selection of kernel functions
Enter the extracted directory and select the configuration with the Make Menuconfig command:
Switch with the SPACEBAR:
[] Do not enable this feature
[M] compiled into kernel modules
[*] compile into kernel
Note: To save the exit, all selected configurations are saved in the. config hidden file;
3. Compiling:
(1) Create a makefile file with the make command in the extracted directory
# make helps: Get help with the Make command
The configuration is selected (one can, but occasionally combined in two or more ways):
# make Config: Iterate through each option
# Make Menuconfig: Open Text window
# make XCONFIG:QT window, dependent on KDE development components;
# make GCONFIG:GTK window, dependent on the GTK development component;
# make Allnoconfig: All selectable items are not selected;
The results are saved to the configuration file for the kernel options:. config
(2) Install kernel module:
#make Modules_install
Installed in/lib/modules/version
(3) Install the kernel:
#make Install
Note: You can use the screen command at the terminal at compile time to avoid accidental disconnection, etc.
Screen command:
Open: # screen
Termination: # Exit
Demolition: Ctrl + A, D
4. Reboot the system to select the new kernel
1, in the original once compiled kernel source code on the basis of re-compilation, to clean up the source;
# Make Clean: Keep the. config file and the relevant files of the external module;
# make Mrproper: Delete all compiled generated files, including. config and various backup files;
# make Distclean: Quite mrproper, and delete the editor backup and patch file, equivalent to before compiling;
2. Compile only some of the code:
(1) Compile only the code in the selected directory
#make dir/
(2) compile only one module
#make Dir/file. [Oiss]
(3) Complete compilation of a module
#make Dir/file.ko
3. View Kernel version information
#make Kernelrelease
#make kernelversion
4, only compile kernel core, do not compile module
#make Bzimage
5. Cross-compiling
The platform on which the build operation resides is non-target code, in fact, the target code will run on a different platform;
#make Arch=arch_name
To get help for the target platform:
#make Arch=arch_name Help
CentOS System Installation:
Installation process: Through the installation program Anaconda;
Bootloader--> Vmlinuz, initrd.img--Anaconda
The Anaconda supports two modes:
GUI: Graphical interface
Text: Textual interface
Anaconda the installation process into three stages:
Pre-installation configuration phase:
Keyboard type
Language
Time
Administrator password
disks and how they are partitioned
Packages to install
Installation phase:
Create partitions on the target disk, perform formatting;
Installs the selected package to the target disk;
Generate bootloader;
First boot:
Configuring Iptables, SELinux, Core dump
Basic partition for System installation:
/: Root partition
Swap: Swap partition
Note: If the root partition is placed on a logical volume, because grub cannot drive and access the logical volume, the/boot must be partitioned separately and use basic disk partitioning
Anaconda supports the configuration of the installation process by reading the contents of the Kickstart configuration file:
After the system is installed,/ROOT/ANACONDA-KS.CFG is generated in the administrator's home directory to save its installation configuration information
The kickstart file is the composition of/root/anaconda-ks.cfg:
Command segment
Package segment:%packages,%end
@group
package[means install this package group]
Installation boot options for the installation process
Wkiol1uybofbxcalaakf9nyqhug926.jpg
Press the ESC key to enter the boot prompt interface
Wkiom1uybvyq1gyraaaeuiwd2p4047.jpg
Boot
Linux: Default installation mode
Linux Text: Installation mode
Network-related boot options:
Ip=ipaddr
Example ip=192.168.1.107
Netmask=mask
Gateway=gw
Dns=dns_server_ip
Ifname=name:mac_addr
Indicates the path to get the Kickstart file:
ks=
DVD Drive Ks=cdrom:/path/to/kickstart_file
HTTP Server Ks=http://server_ip:port/path/to/kickstart_file
HTTPS Serverks=https://server_ip:port/path/to/kickstart_file
FTP Server Ks=ftp://serverip:port/path/to/kickstart_file
NFS Server Ks=nfs:server_ip:/path/to/kickstart_file
A boot disc: Only helps start the installation process and does not provide an installation tree:
Prepare working directory, for example use/TMP/DVD here;
Mkdir/tmp/dvd
Mount system release CD, copy Isolinux directory to/tmp/dvd;
Mount/dev/cdrom/mnt
Mkdir/tmp/dvd/isolinux
cp/mnt/isolinux/*/tmp/dvd/isolinux
Chmodu+x/tmp/dvd/isolinux-r
Copy the created Kickstart file ks.cfg to/tmp/cdrom location; change/root/anaconda-ks.cfg to the appropriate kickstart file and name it ks.cfg
Cp/root/ks.cfg/tmp/dvd if necessary, you can edit the/tmp/dvd/isolinux/isolinux.cfg after a label append command to append ks=cdrom:/ Ks.cfg information to implement the KS file provided on the CD automatically, if ks.cfg on the server, you must enter the boot command line, set the IP address is boot> Linux
Create ISO Image: This command must be performed on the parent directory of the DVD [create a good ISO image under/root]
# mkisofs-r-j-t-v--no-emul-boot--boot-load-size 4--boot-info-table-v "CentOS 6.6 x86_64 Boot Disk"-B Isolinux/isoli Nux.bin-c isolinux/boot.cat-o/root/boot.iso dvd/when ks.cfg on a disc, you can set it directly in the Ioslinux.cfg file without having to set the IP address manually. And if there is an installation tree on the CD, you can install it without connecting the network directly. When ks.cfg on a network server, you must manually specify the IP address at the boot prompt to connect to the network to obtain the installer
This article is from the "Lu Hang @ blog" blog, please be sure to keep this source http://10116624.blog.51cto.com/10106624/1657270
Linux kernel compilation, management, and kickstart and boot image creation