linux-内核编译、安装grub、安装initrd及内核,组装Linux

用户空间用于访问、监控内核的目录
/proc, /sys

通过修改/proc,/sys中的文件控制内核参数(伪文件系统)

/proc/sys: 此目录中的文件很多是可读写的,可修改其中内容(重定向的方式修改)
/sys/: 某些文件可写

[[email protected] ~]# ll /proc/sys
total 0
dr-xr-xr-x 0 root root 0 Mar  4 22:48 abi
dr-xr-xr-x 0 root root 0 Mar  4 22:47 crypto
dr-xr-xr-x 0 root root 0 Mar  4 22:48 debug
dr-xr-xr-x 0 root root 0 Mar  4 22:48 dev
dr-xr-xr-x 0 root root 0 Mar  4 22:47 fs
dr-xr-xr-x 0 root root 0 Mar  4 22:47 kernel
dr-xr-xr-x 0 root root 0 Mar  4 22:47 net
dr-xr-xr-x 0 root root 0 Mar  4 22:48 vm
[[email protected] ~]# ll /proc/sys/vm/
total 0
-rw-r--r-- 1 root root 0 Mar  4 22:48 block_dump
--w------- 1 root root 0 Mar  4 22:48 compact_memory
-rw-r--r-- 1 root root 0 Mar  4 22:48 dirty_background_bytes
-rw-r--r-- 1 root root 0 Mar  4 22:48 dirty_background_ratio
-rw-r--r-- 1 root root 0 Mar  4 22:48 dirty_bytes
-rw-r--r-- 1 root root 0 Mar  4 22:48 dirty_expire_centisecs
-rw-r--r-- 1 root root 0 Mar  4 22:48 dirty_ratio
-rw-r--r-- 1 root root 0 Mar  4 22:48 dirty_writeback_centisecs
-rw-r--r-- 1 root root 0 Mar  4 22:48 drop_caches
-rw-r--r-- 1 root root 0 Mar  4 22:48 extfrag_threshold
-rw-r--r-- 1 root root 0 Mar  4 22:48 extra_free_kbytes
-rw-r--r-- 1 root root 0 Mar  4 22:48 hugepages_treat_as_movable
-rw-r--r-- 1 root root 0 Mar  4 22:48 hugetlb_shm_group
-rw-r--r-- 1 root root 0 Mar  4 22:48 laptop_mode
-rw-r--r-- 1 root root 0 Mar  4 22:48 legacy_va_layout
-rw-r--r-- 1 root root 0 Mar  4 22:48 lowmem_reserve_ratio
-rw-r--r-- 1 root root 0 Mar  4 22:48 max_map_count
-rw-r--r-- 1 root root 0 Mar  4 22:48 meminfo_legacy_layout
-rw-r--r-- 1 root root 0 Mar  4 22:48 memory_failure_early_kill
-rw-r--r-- 1 root root 0 Mar  4 22:48 memory_failure_recovery
-rw-r--r-- 1 root root 0 Mar  4 22:48 min_free_kbytes
-rw-r--r-- 1 root root 0 Mar  4 22:48 min_slab_ratio
-rw-r--r-- 1 root root 0 Mar  4 22:48 min_unmapped_ratio
-rw-r--r-- 1 root root 0 Mar  4 22:48 mmap_min_addr
-rw-r--r-- 1 root root 0 Mar  4 22:48 nr_hugepages
-rw-r--r-- 1 root root 0 Mar  4 22:48 nr_hugepages_mempolicy
-rw-r--r-- 1 root root 0 Mar  4 22:48 nr_overcommit_hugepages
-r--r--r-- 1 root root 0 Mar  4 22:48 nr_pdflush_threads
-rw-r--r-- 1 root root 0 Mar  4 22:48 numa_zonelist_order
-rw-r--r-- 1 root root 0 Mar  4 22:48 oom_dump_tasks
-rw-r--r-- 1 root root 0 Mar  4 22:48 oom_kill_allocating_task
-rw-r--r-- 1 root root 0 Mar  4 22:48 overcommit_kbytes
-rw-r--r-- 1 root root 0 Mar  4 22:48 overcommit_memory
-rw-r--r-- 1 root root 0 Mar  4 22:48 overcommit_ratio
-rw-r--r-- 1 root root 0 Mar  4 22:48 page-cluster
-rw-r--r-- 1 root root 0 Mar  4 22:48 panic_on_oom
-rw-r--r-- 1 root root 0 Mar  4 22:48 percpu_pagelist_fraction
-rw-r--r-- 1 root root 0 Mar  4 22:48 scan_unevictable_pages
-rw-r--r-- 1 root root 0 Mar  4 22:48 stat_interval
-rw-r--r-- 1 root root 0 Mar  4 22:48 swappiness
-rw-r--r-- 1 root root 0 Mar  4 22:48 unmap_area_factor
-rw-r--r-- 1 root root 0 Mar  4 22:48 vfs_cache_pressure
-rw-r--r-- 1 root root 0 Mar  4 22:48 would_have_oomkilled
-rw-r--r-- 1 root root 0 Mar  4 22:48 zone_reclaim_mode
[[email protected] ~]#

设定内核参数值的方法(能立即生效,但无法永久有效):
1、重定向:echo VALUE > /proc/sys/TO/SOMEFILE
2、sysctl -w kernel.hostname=  (sysctl专用于设定内核参数)

[[email protected] ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1861        329       1532          1         31        111
-/+ buffers/cache:        185       1676
Swap:         2047          0       2047
[[email protected] ~]# echo 1 > /proc/sys/vm/drop_caches
[[email protected] ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1861        217       1644          1          0         32
-/+ buffers/cache:        184       1677
Swap:         2047          0       2047
[[email protected] ~]#

[[email protected] ~]# cat /proc/sys/kernel/hostname
localhost
[[email protected] ~]# echo cxiong > /proc/sys/kernel/hostname
[[email protected] ~]# hostname
cxiong
[[email protected] ~]#

[[email protected] ~]# sysctl -w kernel.hostname="localhost"
kernel.hostname = localhost
[[email protected] ~]# hostname
localhost
[[email protected] ~]#

设定内核参数值的方法(永久有效,但无法立即生效)

修改配置文件:/etc/sysctl.conf

修改文件完成之后,执行如下命令可立即生效:
sysctl -p 
sysctl -a: 显示所有内核参数及其值

[[email protected] ~]# vim /etc/sysctl.conf
[[email protected] ~]# cat /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 = 1  (修改参数为1)

# 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 default maxmimum size of a mesage queue
kernel.msgmnb = 65536

# Controls the maximum size of a message, in bytes
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
[[email protected] ~]# cat /proc/sys/net/ipv4/ip_forward
0

[[email protected] ~]# sysctl -p
net.ipv4.ip_forward = 1
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
[[email protected] ~]#



内核模块管理(内核模块必须与内核版本完全一致):
lsmod: 查看

modprobe MOD_NAME:装载某模块
modprobe -r MOD_NAME: 卸载某模块

modinfo MOD_NAME: 查看模块的具体信息

insmod /PATH/TO/MODULE_FILE: 根据路径,载模块 
rmmod MOD_NAME

depmod /PATH/TO/MODILES_DIR

[[email protected] ~]# lsmod
Module                  Size  Used by
8021q                  25527  0
garp                    7152  1 8021q
stp                     2218  1 garp
llc                     5578  2 garp,stp
ipt_REJECT              2351  2
nf_conntrack_ipv4       9506  2
nf_defrag_ipv4          1483  1 nf_conntrack_ipv4
iptable_filter          2793  1
ip_tables              17831  1 iptable_filter
ip6t_REJECT             4628  2
nf_conntrack_ipv6       8337  3
nf_defrag_ipv6         27236  1 nf_conntrack_ipv6
xt_state                1492  5
nf_conntrack           80390  3 nf_conntrack_ipv4,nf_conntrack_ipv6,xt_state
ip6table_filter         2889  1
ip6_tables             18732  1 ip6table_filter
ipv6                  334932  275 ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6
ext3                  240580  1
jbd                    80950  1 ext3
uinput                  8120  0
microcode             112653  0
vmware_balloon          7199  0
raid0                  12417  0
snd_ens1371            21587  2
snd_rawmidi            23017  1 snd_ens1371
snd_ac97_codec        124967  1 snd_ens1371
ac97_bus                1452  1 snd_ac97_codec
snd_seq                55727  0
snd_seq_device          6500  2 snd_rawmidi,snd_seq
snd_pcm                87790  2 snd_ens1371,snd_ac97_codec
snd_timer              22443  2 snd_seq,snd_pcm
snd                    70953  11 snd_ens1371,snd_rawmidi,snd_ac97_codec,snd_seq,snd_seq_device,snd_pcm,snd_timer
soundcore               7958  1 snd
snd_page_alloc          8856  1 snd_pcm
e1000                 160643  0
sg                     29318  0
i2c_piix4              11776  0
i2c_core               29964  1 i2c_piix4
shpchp                 29130  0
ext4                  378476  2
jbd2                   93427  1 ext4
mbcache                 8193  2 ext3,ext4
sr_mod                 15049  0
cdrom                  39085  1 sr_mod
sd_mod                 36998  9
crc_t10dif              1305  1 sd_mod
ahci                   41208  0
mptspi                 16411  7
mptscsih               36636  1 mptspi
mptbase                93615  2 mptspi,mptscsih
scsi_transport_spi     25447  1 mptspi
pata_acpi               3701  0
ata_generic             3837  0
ata_piix               24409  0
dm_mirror              14384  0
dm_region_hash         12085  1 dm_mirror
dm_log                  9930  2 dm_mirror,dm_region_hash
dm_mod                 95622  5 dm_mirror,dm_log

[[email protected] ~]# modprobe -r sg
[[email protected] ~]# lsmod | grep sg
[[email protected] ~]# modprobe sg
[[email protected] ~]# lsmod | grep sg
sg                     29318  0
[[email protected] ~]#

[[email protected] ~]# modinfo sg
filename:       /lib/modules/2.6.32-504.el6.x86_64/kernel/drivers/scsi/sg.ko
alias:          char-major-21-*
version:        3.5.34
license:        GPL
description:    SCSI generic (sg) driver
author:         Douglas Gilbert
srcversion:     DAF3F1D4974BB261E473A85
depends:        (包依赖关系)
vermagic:       2.6.32-504.el6.x86_64 SMP mod_unload modversions
parm:           scatter_elem_sz:scatter gather element size (default: max(SG_SCATTER_SZ, PAGE_SIZE)) (int)
parm:           def_reserved_size:size of buffer reserved for each fd (int)
parm:           allow_dio:allow direct I/O (default: 0 (disallow)) (int)
[[email protected] ~]#

[[email protected] ~]# modprobe -r mii
[[email protected] ~]# insmod /lib/modules/2.6.32-504.el6.x86_64/kernel/drivers/net/mii.ko
[[email protected] ~]# lsmod | grep mii
mii                     5376  0
[[email protected] ~]#

大多数内核中的功能除了核心功能之外,在编译时,大多功能都有三种选择:
1、不使用此功能;
2、编译成内核模块;
3、编译进内核;

如何手动编译内核:(develop tool/develop library)

内核的编译与rpm包不同,因为内核的参数多;
make gconfig: Gnome桌面环境使用,需要安装图形开发库组:GNOME Software Development
make kconfig: KDE桌面环境使用,需要安装图形开发库

make menuconfig:

make
make modules_install
make install

[[email protected] ~]# uname -r
2.6.32-504.el6.x86_64  (rhel6上的主流内核版本号一直为2.6.32;rhel5的主流内核版本号为2.6.18)

任务:收集rhel内核源码包

https://www.kernel.org/pub/linux/kernel/v2.6/




通过make menuconfig编译内核

[[email protected] ~]# ll /usr/src/
total 12
drwxr-xr-x.  2 root root 4096 Jun 28  2011 debug
drwxr-xr-x.  3 root root 4096 Jun 21  2015 kernels
drwxr-xr-x. 22 root root 4096 Mar  4 23:53 linux-2.6.28.10
[[email protected] linux]# ll
total 380
drwxr-xr-x. 24 root root   4096 Mar  4 23:53 arch(平台架构)
drwxr-xr-x.  2 root root   4096 Mar  4 23:53 block
-rw-r--r--.  1 root root  18693 Mar  4 23:53 COPYING
-rw-r--r--.  1 root root  93212 Mar  4 23:53 CREDITS
drwxr-xr-x.  3 root root   4096 Mar  4 23:53 crypto(加密解密)
drwxr-xr-x. 82 root root   4096 Mar  4 23:53 Documentation
drwxr-xr-x. 83 root root   4096 Mar  4 23:53 drivers(驱动)
drwxr-xr-x. 18 root root   4096 Mar  4 23:53 firmware
drwxr-xr-x. 62 root root   4096 Mar  4 23:53 fs  (文件系统)
drwxr-xr-x. 27 root root   4096 Mar  4 23:53 include
drwxr-xr-x.  2 root root   4096 Mar  4 23:53 init
drwxr-xr-x.  2 root root   4096 Mar  4 23:53 ipc(进程间通信)
-rw-r--r--.  1 root root   2430 Mar  4 23:53 Kbuild
drwxr-xr-x.  6 root root   4096 Mar  4 23:53 kernel
drwxr-xr-x.  6 root root   4096 Mar  4 23:53 lib
-rw-r--r--.  1 root root 106036 Mar  4 23:53 MAINTAINERS
-rw-r--r--.  1 root root  57314 Mar  4 23:53 Makefile
drwxr-xr-x.  2 root root   4096 Mar  4 23:53 mm(内存管理)
drwxr-xr-x. 45 root root   4096 Mar  4 23:53 net(网络)
-rw-r--r--.  1 root root  16930 Mar  4 23:53 README
-rw-r--r--.  1 root root   3172 Mar  4 23:53 REPORTING-BUGS
drwxr-xr-x.  7 root root   4096 Mar  4 23:53 samples
drwxr-xr-x. 10 root root   4096 Mar  4 23:53 scripts
drwxr-xr-x.  5 root root   4096 Mar  4 23:53 security
drwxr-xr-x. 20 root root   4096 Mar  4 23:53 sound
drwxr-xr-x.  2 root root   4096 Mar  4 23:53 usr
drwxr-xr-x.  3 root root   4096 Mar  4 23:53 virt(虚拟化)
[[email protected] linux]#

如何手动编译内核(内核参数非常多):
make gconfig: Gnome桌面环境使用,需要安装图形开发库组:GNOME Software Development
make kconfig: KDE桌面环境使用,需要安装图形开发库

make menuconfig(经常使用):

lftp [email protected]:/pub> get ncurses-devel-5.5-24.20060715.x86_64.rpm (make menuconfig依赖包)
1791882 bytes transferred                                             
lftp [email protected]:/pub> bye
[[email protected] linux]#
[[email protected] linux]# ls
arch   COPYING  crypto         drivers   fs       init  Kbuild  lib          Makefile  ncurses-devel-5.5-24.20060715.x86_64.rpm  README          samples  security  usr
block  CREDITS  Documentation  firmware  include  ipc   kernel  MAINTAINERS  mm        net                                       REPORTING-BUGS  scripts  sound     virt
[[email protected] linux]# rpm -ivh ncurses-devel-5.5-24.20060715.x86_64.rpm
warning: ncurses-devel-5.5-24.20060715.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:ncurses-devel          ########################################### [100%]
[[email protected] linux]# make menuconfig  (make menuconfig修改内核参数)
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/kxgettext.o
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/mconf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/lex.zconf.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/mconf
scripts/kconfig/mconf arch/x86/Kconfig
#
# using defaults found in /boot/config-2.6.18-308.el5
#
/boot/config-2.6.18-308.el5:1365:warning: symbol value ‘m‘ invalid for FIXED_PHY
/boot/config-2.6.18-308.el5:1671:warning: symbol value ‘m‘ invalid for ISDN
/boot/config-2.6.18-308.el5:2789:warning: symbol value ‘m‘ invalid for RTC_INTF_SYSFS
/boot/config-2.6.18-308.el5:2790:warning: symbol value ‘m‘ invalid for RTC_INTF_PROC
/boot/config-2.6.18-308.el5:2791:warning: symbol value ‘m‘ invalid for RTC_INTF_DEV
/boot/config-2.6.18-308.el5:2813:warning: symbol value ‘m‘ invalid for DMA_ENGINE
#
# configuration written to .config
#

*** End of Linux kernel configuration.
*** Execute ‘make‘ to build the kernel or try ‘make help‘.

[[email protected] linux]# pwd
/usr/src/linux
[[email protected] linux]# ls -a   (编译完成后会生成.config文件)
.     block    CREDITS        drivers   .gitignore  ipc     lib          Makefile                                  net             samples   sound
..    .config  crypto         firmware  include     Kbuild  .mailmap     mm                                        README          scripts   usr
arch  COPYING  Documentation  fs        init        kernel  MAINTAINERS  ncurses-devel-5.5-24.20060715.x86_64.rpm  REPORTING-BUGS  security  virt
[[email protected] linux]# make  (编译时间实际30分钟)
[[email protected] linux]#

[[email protected] linux]# ls /boot/    (当前系统的.config文件)
config-2.6.18-308.el5  grub  initrd-2.6.18-308.el5.img  lost+found  symvers-2.6.18-308.el5.gz  System.map-2.6.18-308.el5  vmlinuz-2.6.18-308.el5
[[email protected] linux]#

[[email protected] linux]# ls /boot/config-2.6.18-308.el5  grub  initrd-2.6.18-308.el5.img  lost+found  symvers-2.6.18-308.el5.gz  System.map-2.6.18-308.el5  vmlinuz-2.6.18-308.el5
[[email protected] linux]# cp /boot/config-2.6.18-308.el5 .config   (将当前系统.config文件作为编译新内核的.config文件)
cp: overwrite `.config‘?
[[email protected] linux]# make menuconfig
scripts/kconfig/mconf arch/x86/Kconfig
#
# configuration written to .config
#

*** End of Linux kernel configuration.
*** Execute ‘make‘ to build the kernel or try ‘make help‘.

[[email protected] linux]# make  (编译)

[[email protected] linux]# make modules_install

[[email protected] linux]# make install

编译完成后,重启操作系统,在grub中会生成新title,选择新内核即可;


二次编译时清理,清理前,如果有需要,请备份配置文件.config:
make clean
make mrproper

screen命令:
screen -ls: 显示已经建立的屏幕
screen: 直接打开一个新的屏幕
 Ctrl+a, d: 拆除屏幕
screen -r ID: 还原回某屏幕
exit: 退出

[[email protected] screen-4.0.3]# find / -name screen
‘/usr/share/terminfo/s/screen
/usr/src/kernels/2.6.18-308.el5-x86_64/include/config/input/mousedev/screen
/usr/local/share/screen
/usr/local/bin/screen
/root/screen-4.0.3/screen
/root/screen-4.0.3/share/screen
/root/screen-4.0.3/bin/screen
[[email protected] screen-4.0.3]# cd
[[email protected] ~]# screen
[detached]
[[email protected] ~]# screen -l
[detached]
[[email protected] ~]# screen -ls
There are screens on:
 27474.pts-1.localhost (Detached)
 27492.pts-1.localhost (Detached)
2 Sockets in /tmp/screens/S-root.

[[email protected] ~]# screen -r 27474
[detached]
[[email protected] ~]#




在宿主机上创建新系统,分区情况

/mnt/boot

/mnt/sysroot/bin,sbin,etc,var,tmp,proc,sys,dev,lib,usr,home

[[email protected] ~]# fdisk -l

Disk /dev/hda: 21.4 GB, 21474836480 bytes
15 heads, 63 sectors/track, 44384 cylinders
Units = cylinders of 945 * 512 = 483840 bytes

Disk /dev/hda doesn‘t contain a valid partition table

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          38      305203+  83  Linux
/dev/sda2              39        2484    19647495   83  Linux
/dev/sda3            2485        2610     1012095   82  Linux swap / Solaris
[[email protected] ~]# fdisk /dev/hda  (指定新boot及新root分区)
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won‘t be recoverable.

The number of cylinders for this disk is set to 44384.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-44384, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-44384, default 44384): +20M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (43-44384, default 43):
Using default value 43
Last cylinder or +size or +sizeM or +sizeK (43-44384, default 44384): +512M

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[[email protected] ~]# fdisk -l

Disk /dev/hda: 21.4 GB, 21474836480 bytes
15 heads, 63 sectors/track, 44384 cylinders
Units = cylinders of 945 * 512 = 483840 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1          42       19813+  83  Linux  (boot分区)
/dev/hda2              43        1101      500377+  83  Linux  (root分区)

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          38      305203+  83  Linux
/dev/sda2              39        2484    19647495   83  Linux
/dev/sda3            2485        2610     1012095   82  Linux swap / Solaris
[[email protected] ~]# mke2fs -j /dev/hda1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
4968 inodes, 19812 blocks
990 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=20447232
3 block groups
8192 blocks per group, 8192 fragments per group
1656 inodes per group
Superblock backups stored on blocks:
 8193

Writing inode tables: done                           
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[[email protected] ~]# mke2fs -j /dev/hda2
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
125488 inodes, 500376 blocks
25018 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
62 block groups
8192 blocks per group, 8192 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done                           
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[[email protected] ~]# mkdir /mnt/{boot,sysroot}
[[email protected] ~]# mount /dev/hda1 /mnt/boot/
[[email protected] ~]# mount /dev/hda2 /mnt/sysroot/
[[email protected] ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hda1 on /mnt/boot type ext3 (rw)
/dev/hda2 on /mnt/sysroot type ext3 (rw)

[[email protected] ~]# grub-install --root-directory=/mnt /dev/hda  (在新boot分区中安装grub相关1、1.5、2阶段)
Probing devices to guess BIOS drives. This may take a long time.
Installation finished. No error reported.
This is the contents of the device map /mnt/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install‘.

(fd0) /dev/fd0
(hd0) /dev/hda
(hd1) /dev/sda
[[email protected] ~]# ls /mnt/boot/  
grub  lost+found
[[email protected] ~]# cp /boot/vmlinuz-2.6.18-308.el5 /mnt/boot/vmlinuz  (新系统内核)
[[email protected] ~]# mkinitrd /boot/initrd-`uname -r`.img `uname-r`  (此命令用于在当前系统中创建initrd,不适合为其他硬盘创建initrd)
[[email protected] ~]# uname -r
2.6.18-308.el5
[[email protected] ~]# mount
/dev/sda2 on / type ext3 (rw)  (当前系统rootfs所在目录)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hda1 on /mnt/boot type ext3 (rw)
/dev/hda2 on /mnt/sysroot type ext3 (rw)

[[email protected] ~]# file /boot/initrd-`uname -r`  (查看initrd文件类型,通过展开现有initrd文件、编辑、再压缩的方法创建initrd文件)
/boot/initrd-2.6.18-308.el5: ERROR: cannot open `/boot/initrd-2.6.18-308.el5‘ (No such file or directory)
[[email protected] ~]# file /boot/initrd-`uname -r`.img   
/boot/initrd-2.6.18-308.el5.img: gzip compressed data, from Unix, last modified: Mon Mar 13 10:35:32 2017, max compression
[[email protected] ~]# cp /boot/initrd-`uname -r`.img /root
[[email protected] ~]# ls
initrd-2.6.18-308.el5.img  screen-4.0.3  screen-4.0.3.tar.gz  linux-2.6.28.10.tar.gz  Desktop  anaconda-ks.cfg install.log  install.log.syslog
[[email protected] ~]# mv initrd-2.6.18-308.el5.img initrd-2.6.18-308.el5.img.gz  (解压initrd文件)
[[email protected] ~]# gzip -d initrd-2.6.18-308.el5.img.gz 
[[email protected] ~]# file initrd-2.6.18-308.el5.img
initrd-2.6.18-308.el5.img: ASCII cpio archive (SVR4 with no CRC)  (cpio文件)
[[email protected] ~]# mkdir test
[[email protected] ~]# cd test/
[[email protected] test]# cd
[[email protected] ~]# cd test/
[[email protected] test]# cd
[[email protected] ~]# ls
test  initrd-2.6.18-308.el5.img  screen-4.0.3  screen-4.0.3.tar.gz  linux-2.6.28.10.tar.gz  Desktop  anaconda-ks.cfg  install.log  install.log.syslog
[[email protected] ~]# cd
[[email protected] ~]# cd test/
[[email protected] test]# cpio -id < ../   (解压cpio文件)
anaconda-ks.cfg            .config/                   .gconf/                    .gstreamer-0.10/           install.log.syslog         .nautilus/                 test/
.bash_history              .cshrc                     .gconfd/                   .gtkrc-1.2-gnome2          .lftp/                     .redhat/                   .Trash/
.bash_logout               Desktop/                   .gnome/                    .ICEauthority              linux-2.6.28.10.tar.gz     screen-4.0.3/              .xsession-errors
.bash_profile              .dmrc                      .gnome2/                   initrd-2.6.18-308.el5.img  .metacity/                 screen-4.0.3.tar.gz       
.bashrc                    .eggcups/                  .gnome2_private/           install.log                .mozilla/                  .tcshrc                   
[[email protected] test]# cpio -id < ../initrd-2.6.18-308.el5.img
14779 blocks
[[email protected] test]# ls  (initrd也是一个Linux)
bin  dev  etc  init  lib  proc sbin  sys  sysroot

[[email protected] test]#
[[email protected] test]#
[[email protected] test]# cd
[[email protected] ~]# mkdir iso
[[email protected] ~]# cd iso/
[[email protected] iso]# zcat /boot/initrd-2.6.18-308.el5.img | cpio -id  (另外一种解压initrd文件方法,较简单,但只能展开在当前文件)
14779 blocks
[[email protected] iso]# ls 
bin  dev  etc  init  lib  proc sbin  sys  sysroot
[[email protected] iso]#

[[email protected] iso]# cat init (修改init文件,init为一个nash的脚本)
#!/bin/nash

mount -t proc /proc /proc
setquiet
echo Mounting proc filesystem
echo Mounting sysfs filesystem
mount -t sysfs /sys /sys
echo Creating /dev
mount -o mode=0755 -t tmpfs /dev /dev
mkdir /dev/pts
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
mkdir /dev/shm
mkdir /dev/mapper
echo Creating initial device nodes
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/urandom c 1 9
mknod /dev/systty c 4 0
mknod /dev/tty c 5 0
mknod /dev/console c 5 1
mknod /dev/ptmx c 5 2
mknod /dev/rtc c 10 135
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mknod /dev/tty5 c 4 5
mknod /dev/tty6 c 4 6
mknod /dev/tty7 c 4 7
mknod /dev/tty8 c 4 8
mknod /dev/tty9 c 4 9
mknod /dev/tty10 c 4 10
mknod /dev/tty11 c 4 11
mknod /dev/tty12 c 4 12
mknod /dev/ttyS0 c 4 64
mknod /dev/ttyS1 c 4 65
mknod /dev/ttyS2 c 4 66
mknod /dev/ttyS3 c 4 67
echo Setting up hotplug.
hotplug
echo Creating block device nodes.
mkblkdevs
echo "Loading ehci-hcd.ko module"
insmod /lib/ehci-hcd.ko
echo "Loading ohci-hcd.ko module"
insmod /lib/ohci-hcd.ko
echo "Loading uhci-hcd.ko module"
insmod /lib/uhci-hcd.ko
mount -t usbfs /proc/bus/usb /proc/bus/usb
echo "Loading jbd.ko module"
insmod /lib/jbd.ko
echo "Loading ext3.ko module"
insmod /lib/ext3.ko
echo "Loading scsi_mod.ko module"
insmod /lib/scsi_mod.ko
echo "Loading sd_mod.ko module"
insmod /lib/sd_mod.ko
echo "Loading scsi_transport_spi.ko module"
insmod /lib/scsi_transport_spi.ko
echo "Loading mptbase.ko module"
insmod /lib/mptbase.ko
echo "Loading mptscsih.ko module"
insmod /lib/mptscsih.ko
echo "Loading mptspi.ko module"
insmod /lib/mptspi.ko
echo "Loading libata.ko module"
insmod /lib/libata.ko
echo "Loading ata_piix.ko module"
insmod /lib/ata_piix.ko
echo "Loading ahci.ko module"
insmod /lib/ahci.ko
echo "Loading dm-mem-cache.ko module"
insmod /lib/dm-mem-cache.ko
echo "Loading dm-mod.ko module"
insmod /lib/dm-mod.ko
echo "Loading dm-log.ko module"
insmod /lib/dm-log.ko
echo "Loading dm-region_hash.ko module"
insmod /lib/dm-region_hash.ko
echo "Loading dm-message.ko module"
insmod /lib/dm-message.ko
echo "Loading dm-raid45.ko module"
insmod /lib/dm-raid45.ko
echo "Loading vmxnet3.ko module"
insmod /lib/vmxnet3.ko
echo "Loading pvscsi.ko module"
insmod /lib/pvscsi.ko
echo "Loading vmxnet.ko module"
insmod /lib/vmxnet.ko
echo Waiting for driver initialization.
stabilized --hash --interval 1000 /proc/scsi/scsi
mkblkdevs
echo Scanning and configuring dmraid supported devices
#resume LABEL=SWAP-sda3  (没有swap,可以省略)
echo Creating root device.
mkrootdev -t ext3 -o defaults,ro /dev/hda2  (修改为新的根设备/dev/hda2)
echo Mounting root filesystem.
mount /sysroot
echo Setting up other filesystems.
setuproot
echo Switching to new root and running init.
switchroot
[[email protected] iso]#

[[email protected] iso]# find . | cpio -H newc --quiet -o | gzip -9 > /mnt/boot/initrd.gz  (当前目录下,使用此命令进行cpio归档,完成创建initrd文件;)

[[email protected] iso]# cd /mnt/boot/
[[email protected] boot]# ls   (initrd文件创建成功)
initrd.gz  vmlinuz  grub  lost+found
[[email protected] boot]# ll
total 4875
drwxr-xr-x 2 root root    1024 Mar 13 14:52 grub
-rw-r--r-- 1 root root 2835771 Mar 13 15:05 initrd.gz
drwx------ 2 root root   12288 Mar 13 14:50 lost+found
-rw-r--r-- 1 root root 2115644 Mar 13 14:53 vmlinuz
[[email protected] boot]# ll -h
total 4.8M
drwxr-xr-x 2 root root 1.0K Mar 13 14:52 grub
-rw-r--r-- 1 root root 2.8M Mar 13 15:05 initrd.gz   (initrd只有2.8M)
drwx------ 2 root root  12K Mar 13 14:50 lost+found
-rw-r--r-- 1 root root 2.1M Mar 13 14:53 vmlinuz  (内核vmlinux只有2.1M)
[[email protected] boot]# pwd
/mnt/boot
[[email protected] boot]# vi /mnt/boot/grub/grub.conf  (vmlinuz、initrd已完成,还需为新系统创建grub.conf文件)

[[email protected] ~]# cat /mnt/boot/grub/grub.conf
default=0
timeout=5
title mylinux(cxiong)
 root (hd0,0)
 kernel /vmlinuz
 initrd /initrd.gz

[[email protected] ~]#

[[email protected] sysroot]# mkdir proc sys dev etc/rc.d lib bin sbin boot home var/log usr/{bin,sbin} root tmp -pv  (为根文件系统创建目录结构)
mkdir: created directory `proc‘
mkdir: created directory `sys‘
mkdir: created directory `dev‘
mkdir: created directory `etc‘
mkdir: created directory `etc/rc.d‘
mkdir: created directory `lib‘
mkdir: created directory `bin‘
mkdir: created directory `sbin‘
mkdir: created directory `boot‘
mkdir: created directory `home‘
mkdir: created directory `var‘
mkdir: created directory `var/log‘
mkdir: created directory `usr‘
mkdir: created directory `usr/bin‘
mkdir: created directory `usr/sbin‘
mkdir: created directory `root‘
mkdir: created directory `tmp‘
[[email protected] sysroot]# tree
.
|-- bin
|-- boot
|-- dev
|-- etc
|   `-- rc.d
|-- home
|-- lib
|-- lost+found
|-- proc
|-- root
|-- sbin
|-- sys
|-- tmp
|-- usr
|   |-- bin
|   `-- sbin
`-- var
    `-- log

18 directories, 0 files
[[email protected] sysroot]# cp /sbin/init /mnt/sysroot/sbin/  (init为系统第一进程)
[[email protected] sysroot]# cp /bin/bash /mnt/sysroot/bin/   (bash进程)
[[email protected]calhost sysroot]# ldd /sbin/init                                  (复制文件依赖库)
 linux-vdso.so.1 =>  (0x00007fff1b9fd000)
 libsepol.so.1 => /lib64/libsepol.so.1 (0x00000031e6400000)
 libselinux.so.1 => /lib64/libselinux.so.1 (0x00000031e6000000)
 libc.so.6 => /lib64/libc.so.6 (0x00000031e4800000)
 libdl.so.2 => /lib64/libdl.so.2 (0x00000031e4c00000)
 /lib64/ld-linux-x86-64.so.2 (0x00000031e4400000)

[[email protected] ~]# chroot /mnt/sysroot/  (chroot测试)
bash-3.2# ls
bash: ls: command not found
bash-3.2# exit
exit
[[email protected] ~]# sync
[[email protected] ~]# cd /mnt/sysroot/
[[email protected] sysroot]# vi etc/inittab
[[email protected] sysroot]#

[[email protected] ~]# cd /mnt/sysroot/
[[email protected] sysroot]# vi etc/inittab
[[email protected] sysroot]# ls
etc  root  lib64  lib  libsepol.so.1  bin  sbin  boot  dev  home  proc sys  tmp  usr  var  lost+found
[[email protected] sysroot]# vi etc/inittab

[[email protected] sysroot]# cat etc/inittab    (编辑inittab文件)

id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit

[[email protected] sysroot]#
[[email protected] sysroot]# chmod +x etc/rc.d/rc.sysinit
[[email protected] sysroot]# sync
[[email protected] sysroot]# sync

[[email protected] sysroot]# vi etc/rc.d/sysinit
[[email protected] sysroot]# cat etc/rc.d/sysinit  (开启sysinit服务)
#!/bin/bash
echo -e "\tWelcome to \033[31mCXIONG \033[0m linux."
/bin/bash

[[email protected] sysroot]# sync
[[email protected] sysroot]# sync
[[email protected] sysroot]# sync
[[email protected] sysroot]# sync
[[email protected] sysroot]# sync

文件错乱导致kernel panic解决办法:

打包/mnt/sysroot,并格式化后,再重新解压

find . | cpio -H newc --quiet -o | gzip -9 > /root/sysroot.gz

umount /dev/hda2

fuser -km /dev/hda2

umount /dev/hda2

mke2fs -j /dev/hda2

mount /dev/hda2 /mnt/sysroot

cd /mnt/sysroot

zcat /root/sysroot.gz | cpio -id

sync

sync

硬盘检查

umount /dev/hda2

fuser -km /dev/hda2

umount /dev/hda2

e2fsck -f /dev/hda2

mount /dev/hda2 /mnt/sysroot

sync

sync



${parameter#*word}
${parameter##*word}
              The word is expanded to produce a pattern just as in pathname expansion.  If the pattern matches the beginning of the value of
              parameter, then the result of the expansion is the expanded value of parameter with the shortest matching pattern  (the  ?..?.
              case)  or  the  longest  matching pattern (the ?..#?..case) deleted.  If parameter is @ or *, the pattern removal operation is
              applied to each positional parameter in turn, and the expansion is the resultant list.  If parameter is an array variable sub-
              scripted  with  @ or *, the pattern removal operation is applied to each member of the array in turn, and the expansion is the
              resultant list.

[[email protected] ~]# file=/usr/local/src
[[email protected] ~]# echo ${file#*/}   (从左往右,第一次匹配到/,到最右边)
usr/local/src
[[email protected] ~]# echo ${file##*/}  (从左往右,最后一次匹配到/,到最右边

src  (文件名)
[[email protected] ~]#

[[email protected] ~]# file=hello/usr/local/src
[[email protected] ~]# echo ${file%%/*}   (从右往左,第一次匹配到/,到最左边)
hello
[[email protected] ~]# echo ${file%/*}(从右往左,最后一次匹配到/,到最左边)

hello/usr/local  (父目录)
[[email protected] ~]#

${parameter%word*}
${parameter%%word*}
              The word is expanded to produce a pattern just as in pathname expansion.  If the pattern matches a  trailing  portion  of  the
              expanded  value  of  parameter, then the result of the expansion is the expanded value of parameter with the shortest matching
              pattern (the ?..?..case) or the longest matching pattern (the ?..%?..case) deleted.  If parameter  is  @  or  *,  the  pattern
              removal  operation  is applied to each positional parameter in turn, and the expansion is the resultant list.  If parameter is
              an array variable subscripted with @ or *, the pattern removal operation is applied to each member of the array in  turn,  and
              the expansion is the resultant list.

复制二进制程序及其依赖的库文件的脚本:
#!/bin/bash
#
DEST=/mnt/sysroot
libcp() {
  LIBPATH=${1%/*}
  [ ! -d $DEST$LIBPATH ] && mkdir -p $DEST$LIBPATH
  [ ! -e $DEST${1} ] && cp $1 $DEST$LIBPATH && echo "copy lib $1 finished."
}

bincp() {
  CMDPATH=${1%/*}
  [ ! -d $DEST$CMDPATH ] && mkdir -p $DEST$CMDPATH
  [ ! -e $DEST${1} ] && cp $1 $DEST$CMDPATH

for LIB in  `ldd $1 | grep -o "/.*lib\(64\)\{0,1\}/[^[:space:]]\{1,\}"`; do
    libcp $LIB
  done
}

read -p "Your command: " CMD
until [ $CMD == ‘q‘ ]; do
   ! which $CMD &> /dev/null && echo "Wrong command" && read -p "Input again:" CMD && continue
  COMMAND=` which $CMD | grep -v "^alias" | grep -o "[^[:space:]]\{1,\}"`
  bincp $COMMAND
  echo "copy $COMMAND finished."
  read -p "Continue: " CMD
done

[[email protected] ~]# modinfo mii   (开机装载网卡模块)
filename:       /lib/modules/2.6.18-308.el5/kernel/drivers/net/mii.ko
license:        GPL
description:    MII hardware support library
author:         Jeff Garzik <[email protected]>
srcversion:     16DCEDEE4B5629C222C352D
depends:       
vermagic:       2.6.18-308.el5 SMP mod_unload gcc-4.1
module_sig: 883f3504f2324392d3142b3e704051112f4a809e30a7bade78b53fff21bc7ae7769423ed110f60a08aea9a8d3ad29725a95298edc5562ea33aedcc
[[email protected] ~]# modinfo pcnet32
filename:       /lib/modules/2.6.18-308.el5/kernel/drivers/net/pcnet32.ko
license:        GPL
description:    Driver for PCnet32 and PCnetPCI based ethercards
author:         Thomas Bogendoerfer
srcversion:     F8144355

时间: 2024-08-11 09:56:31

linux-内核编译、安装grub、安装initrd及内核,组装Linux的相关文章

linux下编译源码安装软件

Reference:http://itlab.idcquan.com/linux/set/39862.html 基本上就是三步: 以编译安装codeblocks为例: 首先解压源码包,假设解压到/tmp下 1. 终端运行./configure 之后系统会自动检查编译环境,如果缺少部件会提示并且STOP.按照提示安装缺少的包就好了. 例如 No package 'gtk+-2.0' found,提示缺少gtk2.0(可是我已经安装gtk2.8了啊喂) 没办法,只好apt-get install l

Boost下载安装编译配置使用指南(含Windows和Linux

理论上,本文适用于boost的各个版本,尤其是最新版本1.45.0:适用于各种C++编译器,如VC6.0(部分库不支持),VS2003,VS2005,VS2008,gcc,C++ Builder等.先总结一下Windows系统.一.下载首先从boost官方主页附链接下载最新版boost安装包(目前最新版是boost_1_45_0.7z).二.安装将boost安装包解压至本地目录,如:E:\SDK\boost_1_45_0.因为boost一部分类是需要编译成库才能使用的,所以我们还需要准备好boo

《鸟哥的Linux私房菜》读书笔记:Linux内核编译和管理

1.内核简介与获取内核源代码 1.1 什么是内核 kernel:内核(kernel)是整个操作系统的最底层,他负责了整个硬件的驱动,以及提供各种系统所需的内核功能,包含防火墙机制.是否支持LVM或Quota等文件系统.若你的内核不能识别某个最新的硬件,那该硬件也就无法被驱动,你当然也就无法使用该硬件.其实内核就是系统上面的一个档案而已, 这个档案包含了驱动主机各项硬件的侦测程序和驱动模块.内核档案一般放在/boot/vmlinuz目录下 内核模块(Kernel module)的用途:将一些不常用

Linux内核编译测试

内核编译: Step 1:配置内核编译选项. make menuconfig Optional Step :排除编译结果文件(.o)等之间的依赖性. make mrproper Optional Step:清除历史编译结果. make clean Step 2:编译内核. make bzImage #编译内核 make modules #编译各内核模块,如驱动等. make modules_install #将编译好的模块安装至 /lib/modules/x.xx.x 目录下. Step 3:生

Linux内核编译和替换小结

Linux内核编译和替换小结 一 准备工作 1 当前Linux 环境 系统版本为 3.8.13.13-cdos 2 下载内核源码 在网站 www.kernel.org ,选择合适的版本下载. 本次下载版本为官方最新开发版本 linux-3.17.tar.xz ? 二 内核编译 1 解压源码 当前系统的源码位置为 /usr/src/linux-headers-3.8.13.13-cdos 新的源码解压到 /opt/linux-3.17,使用命令 #tar xvf linux-3.17.tar.xz

Linux内核编译步骤

编译之前,一定要查看,内核源码中,Documentation/Changes文件,查看内核编译时,需要的运行环境,如果不适合编译和有可能失败. 由于2.4和2.6内核的编译方法不是完全一样,所以我们分开两种情况讨论 编译2.4内核:                                                         编译2.6内核 第一步:make mrproper -清理内核源代码树(清理垃圾信息)             make mrproper 第二步:mak

GRUB安装配置及应用

GRUB配置及应用 一.什么是GRUB? GRUB是GRand Unified Bootloader的缩写,它是一个多重操作系统启动管理器,安装在MBR中. 二.GRUB运行流程 Stage1:启动位于MBR中boot loader的主程序. Stage1_5:让boot loader能够是识别位于MBR之后扇区Stage2所在分区上的文件系统. Stage2:加载所有配置档与相关的环境参数文件 (包括文件系统定义与主要配置档 menu.lst), 一般来说,配置档都在 /boot/grub.

Linux内核编译和参数配置

内核 内核,是一个操作系统的核心.它负责管理系统的进程.内存.设备驱动程序.文件和网络系统,决定着系统的性能和稳定性.Linux作为一个自由软件,在广大爱好者的支持下,内核版本不断更新.新的内核修订了旧内核的bug,并增加了许多新的特性.如果用户想要使用这些新特性,或想根据自己的系统度身定制一个更高效,更稳定的内核,就需要重新编译内核.本文将以RedHat Linux 6.0(kernel 2.2.5)为操作系统平台,介绍在Linux上进行内核编译的方法. 一. 下载新内核的源代码 内核,是一个

Linux内核编译完整过程

Linux内核编译完整过程 通过网上的资料我自己的实际内核编译,我把对Linux内核编译的过程写在这里,也许对其他的Linux爱好者的编译学习有些帮助,其中很大部分是网上的资料,另外就是我在实际编译过程中的一些实际经验. 内核简介 内核,是一个操作系统的核心.它负责管理系统的进程.内存.设备驱动程序.文件和网络系统,决定着系统的性能和稳定性. Linux的一个重要的特点就是其源代码的公开性,所有的内核源程序都可以在/usr/src/linux下找到,大部分应用软件也都是遵循GPL而设计的,你都可

linux下编译qt5.6.0静态库——configure配置

 随笔 - 116  文章 - 4  评论 - 7 linux下编译qt5.6.0静态库--configure配置 linux下编译qt5.6.0静态库 linux下编译qt5.6.0静态库 configure生成makefile 安装选项 Configure选项 第三方库: 附加选项: QNX/Blackberry选项: Android 选项: 生成makefile 遇到链接检查失败的情况 生成makefile后进行编译 编译时的错误 多重定义'QT_MODBUS()'和'QT_MODBU