八、Linux精简系统和内核管理裁剪(二)

简介:

八、内核服务管理

内核切换

chroot  initramfs(内核所在的目录)

[root@localhost initramfs]# cd ..

[root@localhost ~]# chroot initramfs/

bash-4.1# 

自定义启动服务

1、编辑启动脚本文件,可以模仿/etc/rc.d/init.d/目录下的脚本文件。

2、cp启动脚本到/etc/rc.d/init.d/目录下。

3、配置启动项,chkconfig —add scriptname

手工编写启动服务脚本:

守护进程的类型:

守护进程是linux里面对开启的服务所运行的进程的称呼,意思指守护服务运行的含义

1、独立守护进程:可以在启动配置中自由设置启动关闭选项(chkconfig —list里面的都是),

2、瞬时守护进程:并不会总是等待响应用户请求,而是将请求交给一个代理,这个代理就是超级守护进程(xinetd,需要提前安装),由他来完成监听请求,当有请求的时候,xinetd超级守护进程在将请求提交给相应的瞬时守护进程。

查看超级守护进程

chkconfig —list

基于 xinetd 的服务:

chargen-dgram: 关闭

chargen-stream:关闭

daytime-dgram: 关闭

daytime-stream:关闭

discard-dgram: 关闭

discard-stream:关闭

echo-dgram:    关闭

echo-stream:   关闭

rsync:         关闭

tcpmux-server: 关闭

time-dgram:    关闭

time-stream:   关闭

开启xinetd服务,可以开启超级守护进程,然后在开启相关的瞬时进程,既可以进行相应的监控。比如:

开启瞬时进程rsync

chkconfig rsync on

开启超级守护进程

service xinetd start

开机启动xinetd进程

chkconfig xinetd on

超级守护进程xinetd管理的服务都存放在/etc/xinetd.d/目录下。

[root@gongbing ~]# ll /etc/xinetd.d/

总用量 48

-rw-------. 1 root root 1157 5月  11 2016 chargen-dgram

-rw-------. 1 root root 1159 5月  11 2016 chargen-stream

-rw-------. 1 root root 1157 5月  11 2016 daytime-dgram

-rw-------. 1 root root 1159 5月  11 2016 daytime-stream

-rw-------. 1 root root 1157 5月  11 2016 discard-dgram

-rw-------. 1 root root 1159 5月  11 2016 discard-stream

--w-------. 1 root root 1148 5月  11 2016 echo-dgram

-rw-------. 1 root root 1150 5月  11 2016 echo-stream

-rw-r--r--. 1 root root  332 3月  28 2014 rsync

-rw-------. 1 root root 1212 5月  11 2016 tcpmux-server

-rw-------. 1 root root 1149 5月  11 2016 time-dgram

-rw-------. 1 root root 1150 5月  11 2016 time-stream

内核模块管理

内核模块存放位置:/lib/modules/`name -r`/

[root@37-test ~]# tree /lib/modules/2.6.32-220.el6.x86_64/ -L 2

/lib/modules/2.6.32-220.el6.x86_64/

├── build -> ../../../usr/src/kernels/2.6.32-220.el6.x86_64

├── extra

├── kernel

│   ├── arch

│   ├── crypto

│   ├── drivers

│   ├── fs

│   ├── kernel

│   ├── lib

│   ├── mm

│   ├── net

│   └── sound

├── modules.alias

├── modules.alias.bin

├── modules.block

├── modules.ccwmap

├── modules.dep

├── modules.dep.bin

├── modules.drm

├── modules.ieee1394map

├── modules.inputmap

├── modules.isapnpmap

├── modules.modesetting

├── modules.networking

├── modules.ofmap

├── modules.order

├── modules.pcimap

├── modules.seriomap

├── modules.symbols

├── modules.symbols.bin

├── modules.usbmap

├── source -> build

├── updates

├── vdso

│   ├── vdso32-int80.so

│   ├── vdso32-syscall.so

│   ├── vdso32-sysenter.so

│   └── vdso.so


└── weak-updates

查看当前内核装载的模块:lsmod(模块被哪些进程调用)

[root@37-test ~]# lsmod

Module                  Size  Used by

bnx2fc                 91002  0 

cnic                   55706  1 bnx2fc

uio                    10430  1 cnic

fcoe                   23298  0 

libfcoe                56951  2 bnx2fc,fcoe

libfc                 108864  3 bnx2fc,fcoe,libfcoe

scsi_transport_fc      55235  3 bnx2fc,fcoe,libfc

scsi_tgt               12077  1 scsi_transport_fc

8021q                  20362  0 

garp                    7152  1 8021q

stp                     2218  1 garp

llc                     5418  2 garp,stp

ipv6                  336282  75 cnic

ecb                     2209  0 

drbg                   23248  1 

ansi_cprng              4716  0 

ablk_helper             3215  0 

cryptd                 10040  1 ablk_helper

lrw                     4216  0 

gf128mul                7993  1 lrw

glue_helper             7506  0 

aes_x86_64              7837  4 

aes_generic            27609  1 aes_x86_64

cbc                     3083  2 

dm_crypt               15654  2 

power_meter             9009  0 

acpi_ipmi               3745  1 power_meter

ipmi_si                46440  1 acpi_ipmi

ipmi_msghandler        40044  2 acpi_ipmi,ipmi_si

iTCO_wdt                7278  0 

iTCO_vendor_support     3056  1 iTCO_wdt

sg                     29318  0 

dcdbas                  8707  0 

lpc_ich                13571  0 

mfd_core                1927  1 lpc_ich

bnx2                   80154  0 

ext3                  240420  6 

jbd                    80652  1 ext3

mbcache                 8193  1 ext3

sr_mod                 15049  0 

cdrom                  39085  1 sr_mod

sd_mod                 37158  10 

crc_t10dif              1209  1 sd_mod

pata_acpi               3701  0 

ata_generic             3837  0 

ata_piix               24409  6 

dm_mirror              14864  0 

dm_region_hash         12085  1 dm_mirror

dm_log                  9930  2 dm_mirror,dm_region_hash


dm_mod                102467  7 dm_crypt,dm_mirror,dm_log


查看具体模块的详细信息:modinfo

由于模块之间有依赖关系,所以在装载或卸载模块的时候,会由于依赖关系而报错,可以通过modinfo查看要卸载的模块的depend的相关信息来决定依赖模块关系。

[root@37-test ~]# modinfo sd_mod

filename:       /lib/modules/2.6.32-642.11.1.el6.x86_64/kernel/drivers/scsi/sd_mod.ko

alias:          scsi:t-0x0e*

license:        GPL

description:    SCSI disk (sd) driver

author:         Eric Youngdale

srcversion:     97E92C0F0C46E76C8745D06

depends:        crc-t10dif

vermagic:       2.6.32-642.11.1.el6.x86_64 SMP mod_unload modversions 


modprobe: 装载指定模块,对于模块不在/lib/modules/目录下的情况,使用insmod /path/modname来指定,并且需要自己手动解决依赖关系,rmmod是手动卸载指定模块,当存在依赖关系时,需要先删除依赖的模块才能删除其他模块(当然)


[root@37-test ~]# modprobe -r cdrom //卸载指定模块,提示被使用

FATAL: Module cdrom is in use.

[root@37-test ~]# modprobe -r sr_mod //卸载依赖的模块

[root@37-test ~]# modprobe -r cdrom //再卸载模块,成功。

[root@37-test ~]# modprobe  cdrom //重新挂载模块。



[root@37-test log]# insmod /lib/modules/2.6.32-642.11.1.el6.x86_64/kernel/drivers/net/mii.ko 

对于加载模块时,使用modprobe可以自动解决依赖关系,使用insmod需要自己手动完成加载模块的加载工作,就是要先加载依赖的mii,才能加载pcnet32。

modprobe -r:卸载指定模块(自动解决依赖关系)

模块间的依赖关系如何制定的呢?

各个模块之间可能存在依赖关系,这个依赖关系如何获知呢。linux系统通常将这种依赖关系存放在/lib/modules/`uname -r`/modules.dep文件文件中。这种文件其实在yum数据库中也是有存在的。

[root@37-test log]# ls /lib/modules/2.6.32-642.11.1.el6.x86_64/

build              modules.dep          modules.networking   modules.usbmap

extra              modules.dep.bin      modules.ofmap        source

kernel             modules.drm          modules.order        updates

modules.alias      modules.ieee1394map  modules.pcimap       vdso

modules.alias.bin  modules.inputmap     modules.seriomap     weak-updates

modules.block      modules.isapnpmap    modules.symbols

modules.ccwmap     modules.modesetting  modules.symbols.bin

[root@localhost ~]# cat /lib/modules/2.6.32-573.el6.x86_64/modules.dep

kernel/arch/x86/kernel/cpu/mcheck/mce-inject.ko:

kernel/arch/x86/kernel/cpu/cpufreq/powernow-k8.ko: kernel/drivers/cpufreq/freq_table.ko kernel/arch/x86/kernel/cpu/cpufreq/mperf.ko

如果文件丢失或损坏,可以通过depmod进行修复。如果是对当前系统内核进行修复直接使用命令即可,如果是对其他内核进行修复,需要制定模块路径。

[root@localhost ~]# depmod -a /lib/modules/2.6.32-573.el6.x86_64/

九、initrd或者ramfs的生成

内核组成部分中的initrd(linux5)或者initramfs(linux6)并不是通过光盘直接安装进去的,或者说并不是存在于镜像文件中的,而是在安装过程中通过mkinitrd命令生成的。

需要命令:1、mkinitrd (redhat5)

[root@37-test log]# file /sbin/mkinitrd 

/sbin/mkinitrd: Bourne-Again shell script text executable

    2、 dracut(redhat6)

[root@37-test log]# file /sbin/dracut 

/sbin/dracut: Bourne-Again shell script text executable

dracut </path/to/image_file <kernel version>

适用于/boot目录下的文件损坏的情况。

[root@37-test log]# dracut /root/kernel/initramfs-`uname -r`.img `uname -r`

[root@37-test log]# ll /root/kernel/

-rw------- 1 root root 20007799 1月  16 09:41 initramfs-2.6.32-642.11.1.el6.x86_64.img

 

最简单linux运行需要的内核:

vmlinuz、initramfs、init、bash、module。


手动制造linux系统的方法:

1、安装grub引导程序

2、安装linux内核、包括init、vmlinuz、/lib/modules、initrd、initramfs。

3、创建根目录、并创建常用的目录、/proc、/dev、/var、/lib、/usr等。

4、安装init及bash相关组件。

十、内核工作特性(深入理解/proc)

1、通过/proc/sys修改内核的工作特性,表现为文件,但他们是内核参数,文件的内容即是参数的值

2、凡具有写权限的文件,通过修改其内容来修改内核工作的特性。不能直接通过vim编辑可以采用以下方法编辑:

方法 一

echo new_value > /proc/sys/file

方法二

sysctl -w to.some_file=new_value #将反斜杠替换成点号。

例如:

[root@37-test log]# echo 1 > /proc/sys/net/ipv4/ip_forward

[root@37-test log]# sysctl -w net.ipv4.ip_forward=0

net.ipv4.ip_forward = 0

sysctl:配置和显示内核参数

-w:临时修改内核参数

-a:显示所有内核参数

[root@37-test log]# sysctl -a |wc -l

957

[root@37-test log]# sysctl -a

kernel.sched_child_runs_first = 0

kernel.sched_min_granularity_ns = 4000000

kernel.sched_latency_ns = 20000000

kernel.sched_wakeup_granularity_ns = 4000000

kernel.sched_tunable_scaling = 1

kernel.sched_features = 7279

kernel.sched_migration_cost = 500000

kernel.sched_nr_migrate = 32

kernel.sched_time_avg = 1000

kernel.sched_shares_window = 10000000


kernel.timer_migration = 1

…………...

以上编辑并不是永久有效,而是临时的。

要保证内核参数永久有效,可以通过/etc/sysctl.conf来设置。配置完成后使用sysctl -p来立即生效。

[root@37-test log]# more /etc/sysctl.conf 

# Kernel sysctl configuration file for Red Hat Linux

#

# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and

# sysctl.conf(5) for more details.


# Controls IP packet forwarding

net.ipv4.ip_forward = 0


# Controls source route verification

net.ipv4.conf.default.rp_filter = 1


# Do not accept source routing

net.ipv4.conf.default.accept_source_route = 0


# Controls the System Request debugging functionality of the kernel

kernel.sysrq = 0


# Controls whether core dumps will append the PID to the core filename.

# Useful for debugging multi-threaded applications.

kernel.core_uses_pid = 1


# Controls the use of TCP syncookies

net.ipv4.tcp_syncookies = 1


# Disable netfilter on bridges.

net.bridge.bridge-nf-call-ip6tables = 0

net.bridge.bridge-nf-call-iptables = 0

net.bridge.bridge-nf-call-arptables = 0


# Controls the maximum size of a message, in bytes

kernel.msgmnb = 65536


# Controls the default maxmimum size of a mesage queue

kernel.msgmax = 65536


# Controls the maximum shared segment size, in bytes

kernel.shmmax = 68719476736


# Controls the maximum number of shared memory segments, in pages

kernel.shmall = 4294967296


vm.overcommit_memory = 1


读取配置文件并立即生效:

[root@37-test log]# sysctl  -p

net.ipv4.ip_forward = 0

net.ipv4.conf.default.rp_filter = 1

net.ipv4.conf.default.accept_source_route = 0

kernel.sysrq = 0

kernel.core_uses_pid = 1

net.ipv4.tcp_syncookies = 1

error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key

error: "net.bridge.bridge-nf-call-iptables" is an unknown key

error: "net.bridge.bridge-nf-call-arptables" is an unknown key

kernel.msgmnb = 65536

kernel.msgmax = 65536

kernel.shmmax = 68719476736

kernel.shmall = 4294967296


vm.overcommit_memory = 1


当然内核的很多参数也可以通过配置各自的配置文件来完成。比如hostname用来设置主机名,通过hostname可以设置,通过/etc/hosts来完成。

cpuinfo:查看cpu信息

[root@37-test ~]# more /proc/cpuinfo 

processor : 0

vendor_id : GenuineIntel

cpu family : 6

model : 30

model name : Intel(R) Xeon(R) CPU           X3440  @ 2.53GHz

stepping : 5

microcode : 4

cpu MHz : 2526.898

cache size : 8192 KB

physical id : 0

siblings : 8

core id : 0

cpu cores : 4

apicid : 0

initial apicid : 0

fpu : yes

fpu_exception : yes

cpuid level : 11

wp : yes

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov 

pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm c

onstant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni 

dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt 

lahf_lm ida dtherm tpr_shadow vnmi flexpriority ept vpid

bogomips : 5053.79

clflush size : 64

cache_alignment : 64

address sizes : 36 bits physical, 48 bits virtual


power management:


meminfo:查看内存信息

[root@37-test ~]# more /proc/meminfo 

MemTotal:        8048108 kB

MemFree:         1382856 kB

Buffers:          411628 kB

Cached:          4750700 kB

SwapCached:            0 kB

Active:          3173928 kB

Inactive:        2589372 kB

Active(anon):     601196 kB

Inactive(anon):     3192 kB

Active(file):    2572732 kB

Inactive(file):  2586180 kB

Unevictable:           0 kB

Mlocked:               0 kB

SwapTotal:             0 kB

SwapFree:              0 kB

Dirty:                 0 kB

Writeback:             0 kB

AnonPages:        600988 kB

Mapped:            15512 kB

Shmem:              3420 kB

Slab:             810332 kB

SReclaimable:     760804 kB

SUnreclaim:        49528 kB

KernelStack:        6720 kB

PageTables:        14656 kB

NFS_Unstable:          0 kB

Bounce:                0 kB

WritebackTmp:          0 kB

CommitLimit:     4024052 kB

Committed_AS:    5742048 kB

VmallocTotal:   34359738367 kB

VmallocUsed:      291180 kB

VmallocChunk:   34359441928 kB

HardwareCorrupted:     0 kB

AnonHugePages:    526336 kB

HugePages_Total:       0

HugePages_Free:        0

HugePages_Rsvd:        0

HugePages_Surp:        0

Hugepagesize:       2048 kB

DirectMap4k:        6756 kB


DirectMap2M:     8372224 kB


lspci:查看pci控制器及相关设备信息

[root@37-test ~]# lspci 

00:00.0 Host bridge: Intel Corporation Core Processor DMI (rev 11)

00:03.0 PCI bridge: Intel Corporation Core Processor PCI Express Root Port 1 (rev 11)

00:05.0 PCI bridge: Intel Corporation Core Processor PCI Express Root Port 3 (rev 11)

00:08.0 System peripheral: Intel Corporation Core Processor System Management Registers (rev 11)

00:08.1 System peripheral: Intel Corporation Core Processor Semaphore and Scratchpad Registers (rev 11)

00:08.2 System peripheral: Intel Corporation Core Processor System Control and Status Registers (rev 11)

00:08.3 System peripheral: Intel Corporation Core Processor Miscellaneous Registers (rev 11)

00:10.0 System peripheral: Intel Corporation Core Processor QPI Link (rev 11)

00:10.1 System peripheral: Intel Corporation Core Processor QPI Routing and Protocol Registers (rev 11)

00:1a.0 USB controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)

00:1c.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 1 (rev 05)

00:1c.2 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 3 (rev 05)

00:1c.3 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 4 (rev 05)

00:1c.4 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 5 (rev 05)


00:1d.0 USB controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)


lsusb:查看usb相关信息

lscpu:查看cpu信息

[root@37-test ~]# lscpu

Architecture:          x86_64

CPU op-mode(s):        32-bit, 64-bit

Byte Order:            Little Endian

CPU(s):                8

On-line CPU(s) list:   0-7

Thread(s) per core:    2

Core(s) per socket:    4

Socket(s):             1

NUMA node(s):          1

Vendor ID:             GenuineIntel

CPU family:            6

Model:                 30

Model name:            Intel(R) Xeon(R) CPU           X3440  @ 2.53GHz

Stepping:              5

CPU MHz:               2526.898

BogoMIPS:              5053.79

Virtualization:        VT-x

L1d cache:             32K

L1i cache:             32K

L2 cache:              256K

L3 cache:              8192K


NUMA node0 CPU(s):     0-7


lsblk:查看块设备信息

[root@37-test ~]# lsblk

NAME                MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT

sda                   8:0    0 465.8G  0 disk  

├─sda1                8:1    0   200M  0 part  /boot

├─sda2                8:2    0   3.9G  0 part  

└─sda3                8:3    0 461.7G  0 part  /

sdd                   8:48   0 465.8G  0 disk  

└─sdd1                8:49   0 465.8G  0 part  /backup

sdc                   8:32   0 465.8G  0 disk  

├─sdc1                8:33   0 784.4M  0 part  

│ └─test (dm-0)     253:0    0 782.4M  0 crypt /opt

└─sdc2                8:34   0   465G  0 part  

  └─resource (dm-1) 253:1    0   465G  0 crypt /dtedu/ecampus

sdb                   8:16   0 465.8G  0 disk  

└─sdb1                8:17   0 465.8G  0 part  /data


sr0                  11:0    1  1024M  0 rom   


ls           lsblk        lscpu        lshal        lslogins     lspci

lsattr       lsb_release  lsdiff       lsinitrd     lsmod        



十一、linux硬件设备管理


1、查看系统硬件信息

1.1、dmesg

1.2、hal-device

1.3、x86info

1.4、dmidecode

2、创建设备文件-mknod

基本用法:

mknod /dev/dev-file 类型 major minor

传统系统内核(2.6.13之前)是通过预先创建可知的所有/dev/目录下的设备文件,并为以后使用做准备工作,而通过udev技术可以动态的加载硬件设备和热插拔技术,并缓存到ramfs中,减少了磁盘空间的占用。

动态热插拔设备放在/etc/udev/rules.d/目录下。

[root@37-test ~]# more /etc/udev/

makedev.d/ rules.d/   udev.conf  

[root@37-test ~]# more /etc/udev/rules.d/ //用来定义动态加载的硬件设备

60-fprint-autosuspend.rules  90-alsa.rules

60-raw.rules                 90-hal.rules

70-persistent-cd.rules       99-fuse.rules

70-persistent-net.rules      

[root@37-test ~]# more /etc/udev/rules.d/70-persistent-net.rules          //用于定义网卡名称


十二、内核编译


通常红帽同一系列的操作系统它的内核是相同的,但并不表示它不对内核进行更新,事实上红帽在更新内核的时候是将linux内核的新特性整合到现有内核版本中,并使用原有内核版本命名的。这里需要重申一下的事情就是红帽只是linux系统的软件封装商,而真正的linux内核开发并不是红帽,所以会存在内核官网和红帽官网所描述的内核版本不一致的情况。

常见内核版本:

mainline:主线版本,持续更新内核新特性,新功能。

stable:稳定版(EOL表示已经不再进行更新),红帽会在未来1-3年内继续对他进行更新。

longterm:同样是长期更新的内核版本。

www.kernel.org

1、内核编译的前提是要有开发工具的,依赖工具有哪些?

“development tools”

“server platforms development”

2、源代码解压后放在那里了?

内核源码解压后,通常存在/usr/src/linux中。

3、配置源代码工具有哪些?

make menuconfig:文本窗口

make gconfig:适合gnome环境

make kconfig:适合KDE环境

make randconfig 随机配置内核

make allyesconfig

make allnoconfig

make oldconfig 按照系统以前的配置编译内核源代码,只是内核是新版本的内核。但是在红帽系统中,此命令不可以使用,可以通过将/boot目录下的config复制到指定目录中,再编译内核,可以达到相同的目的。


[root@37-test src]# ls /boot

config-2.6.32-642.11.1.el6.x86_64 (红帽的内核配置文件)        symvers-2.6.32-642.11.1.el6.x86_64.gz

grub                                      System.map-2.6.32-642.11.1.el6.x86_64

initramfs-2.6.32-642.11.1.el6.x86_64.img  vmlinuz-2.6.32-642.11.1.el6.x86_64

lost+found

编译生成内核配置文件.config

安装内核

make

make modules_install

make install

B3F1D977533E47088A87025E56B4A9DB

安装内核实质上是通过脚本install.sh,将bzimage部署到grub、

内核功能选择:

*:编译进内核、即编译成内核的一部分

M:编译成模块,位于/lib/modules/2.6.32-573.el6.x86_64/

N:不启用(编译)此功能

如果重新编译,要求清理源码树,方法:

make clean只删除生成的文件,不删除配置文件.config

make mrproper删除编译生成的文件和配置文件.config

make distclean:重置源代码

实操:

1、安装依赖包

[root@localhost ~]# yum groupinstall "development tools" "Server Platform Development"

2、编辑.config文件。

[root@37-test src]# tar -xf linux-4.6.tar.xz -C /usr/src/linux  //解压缩下载的内核源码包

[root@37-test linux-4.6.1]# pwd

/usr/src/linux/linux-4.6.1

[root@37-test linux-4.6.1]# make menuconfig   //图形化编译内核配置文件。


 .config - Linux/x86 4.6.1 Kernel Configuration

 ──────────────────────────────────────────────────────────────────────────────

  ┌───────────────── Linux/x86 4.6.1 Kernel Configuration ──────────────────

    Arrow keys navigate the menu.  <Enter> selects submenus ---> (or empty │  

    submenus ----).  Highlighted letters are hotkeys.  Pressing <Y>        │  

    includes, <N> excludes, <M> modularizes features.  Press <Esc><Esc> to │  

    exit, <?> for Help, </> for Search.  Legend: [*] built-in  [ ]         │  

   ┌───────────────────────────────────────────────────────────────────── │  

   │    [*] 64-bit kernel                                                 │  

   │        General setup  --->                                           │  

   │    [*] Enable loadable module support  --->                          │  

   │    -*- Enable the block layer  --->                                  │  

   │        Processor type and features  --->                             │  

   │        Power management and ACPI options  --->                       │  

   │        Bus options (PCI etc.)  --->                                  │  

   │        Executable file formats / Emulations  --->                    │  

   │    < > Volume Management Device Driver (NEW)                         │  

   │    [*] Networking support  --->                                      │  

   └────v(+)─────────────────────────────────────────────────────────────┘ │  

  ├─────────────────────────────────────────────────────────────────────────  

          <Select>    < Exit >    < Help >    < Save >    < Load >           

  ─────────────────────────────────────────────────────────────────────────┘  

                                                                               


3、编译内核

[root@localhost linux-4.6]# make                                                  

4、编译内核模块并自动生成依赖关系(depmod)。

[root@localhost linux-4.6]# make modules_install

5、安装内核,make和makemodules_install两个命令会生成一个bzimage的文件,此文件实际为内核编译后的镜像文件,然后通过

[root@localhost linux-4.6]# make install                                          

内核安装参考:http://blog.csdn.net/xf_xjtu/article/details/8101258

内核选项说明:可以参考金步国的文档:http://www.jinbuguo.com/kernel/boot_parameters.html

如何实现内核的部分编译:

1、只编译某子目录下的相关代码



本文转自 blackstome 51CTO博客,原文链接:http://blog.51cto.com/137783/1916960,如需转载请自行联系原作者
相关文章
|
7天前
|
Ubuntu 安全 Linux
《Linux 简易速速上手小册》第1章: Linux 系统基础(2024 最新版)
《Linux 简易速速上手小册》第1章: Linux 系统基础(2024 最新版)
40 1
|
14天前
|
资源调度 JavaScript 搜索推荐
Linux系统之部署envlinks极简个人导航页
【4月更文挑战第11天】Linux系统之部署envlinks极简个人导航页
54 2
|
16天前
|
Linux C语言
Linux内核队列queue.h
Linux内核队列queue.h
|
17天前
|
缓存 Linux 测试技术
安装【银河麒麟V10】linux系统--并挂载镜像
安装【银河麒麟V10】linux系统--并挂载镜像
90 0
|
17天前
|
监控 Unix Linux
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
31 0
|
15天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
39 6
|
1天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
12 1
|
2天前
|
Linux 数据安全/隐私保护
Linux系统忘记密码的三种解决办法
这篇博客介绍了三种在Linux忘记密码时重置登录密码的方法:1) 使用恢复模式,通过控制台界面以管理员权限更改密码;2) 利用Linux Live CD/USB启动,挂载硬盘分区并使用终端更改密码;3) 进入单用户模式,自动以管理员身份登录后重置密码。每个方法都提供了详细步骤,提醒用户在操作前备份重要数据。
|
2天前
|
JSON Unix Linux
Linux系统之jq工具的基本使用
Linux系统之jq工具的基本使用
29 2
|
2天前
|
数据采集 监控 安全
linux系统被×××后处理经历
linux系统被×××后处理经历