sLinux系统启动流程

PC: OS(Linux)

POST-->BIOS(Boot Sequence)-->MBR(bootloader,446)-->Kernel-->initrd-->(ROOTFS)/sbin/init(/etc/inittab)

启动的服务不同:

 运行级别:0-6
  0:halt
  1: single user mode, 直接以管理员身份切入, s,S,single
  2:multi user mode, no NFS
  3: multi user mode, text mode
  4:reserved
  5: multi user mode, graphic mode
  6: reboot

 bootloader(MBR):只有446字节,太小

  LILO: LInux LOader
  GRUB: GRand Unified Bootloader  (可以扩展更大内存空间)
   Stage1: MBR
   Stage1_5:  (识别不同文件系统)
   Stage2: /boot/grub/
[root@localhost ~]# ll -h /boot/grub/
total 276K
-rw-r--r--. 1 root root   63 Jun 21  2015 device.map
-rw-r--r--. 1 root root  14K Jun 21  2015 e2fs_stage1_5
-rw-r--r--. 1 root root  13K Jun 21  2015 fat_stage1_5
-rw-r--r--. 1 root root  12K Jun 21  2015 ffs_stage1_5
-rw-------. 1 root root  784 Jun 21  2015 grub.conf
-rw-------. 1 root root  789 Jun 21  2015 grub.conf.bak
-rw-r--r--. 1 root root  12K Jun 21  2015 iso9660_stage1_5
-rw-r--r--. 1 root root  13K Jun 21  2015 jfs_stage1_5
lrwxrwxrwx. 1 root root   11 Jun 21  2015 menu.lst -> ./grub.conf
-rw-r--r--. 1 root root  12K Jun 21  2015 minix_stage1_5
-rw-r--r--. 1 root root  15K Jun 21  2015 reiserfs_stage1_5
-rw-r--r--. 1 root root 1.4K May  6  2010 splash.xpm.gz  #登陆背景图
-rw-r--r--. 1 root root  512 Jun 21  2015 stage1
-rw-r--r--. 1 root root 124K Jun 21  2015 stage2   #大小远远大于446字节
-rw-r--r--. 1 root root  12K Jun 21  2015 ufs2_stage1_5
-rw-r--r--. 1 root root  12K Jun 21  2015 vstafs_stage1_5
-rw-r--r--. 1 root root  14K Jun 21  2015 xfs_stage1_5
[root@localhost ~]#
[root@localhost ~]# rpm -q grub  #(查询grub版本)
grub-0.97-93.el6.x86_64
[root@localhost ~]#
[root@localhost ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0 #(默认启动第一个内核,从0开始)
timeout=5 #(等待用户选择的超时时间,单位为s)
splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz  #(指定grub背景图片)
hiddenmenu  #(隐藏选择菜单)
password --md5 $1$EHRqC/$Aj8KS9Zc67Plwh77p437r0  #(设置grub密码)
title Red Hat Enterprise Linux 6 (2.6.32-504.el6.x86_64)  #(区别不同内核版本,名称;内核标题,或操作系统名称,字符串,可自由修改)
 root (hd0,0)   #(内核文件所在的设备;对grub而言,所有类型硬盘一律hd,格式为(hd#,N);hd#, #表示第几个磁盘;最后的N表示对应磁盘的分区)
 kernel /vmlinuz-2.6.32-504.el6.x86_64 ro root=UUID=57d85756-7680-4c7c-9125-6ad67dae2c45 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16   crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM quiet    #(内核文件路径,及传递给内核的参数)
 initrd /initramfs-2.6.32-504.el6.x86_64.img   #(ramdisk文件路径)
[root@localhost ~]#


RedHat5: ramdisk-->initrd
RedHat6: ramfs-->initramfs


下载gimp,遇到在Linux中编译文件时出现:Your intltool is too old. You need intltool 0.35.0 or later                         

#wget http://ftp.gnome.org/pub/gnome/sources/intltool/0.40/intltool-0.40.6.tar.gz  (下载地址) 

#tar -zxvf intltool-0.40.6.tar.gz
 #cd intltool-0.40.6
 #./configure #这儿也可以指定安装目录,和man目录
 #make && make install

无法安装gimp,登陆界面无法修改


grub-md5-crypt成md5加密密码

[root@localhost ~]# grub-md5-crypt 
Password: 
Retype password: 
$1$EHRqC/$Aj8KS9Zc67Plwh77p437r0
[root@localhost ~]#


wKioL1jBYZXiKvU6AAA4JJmiuMU092.png-wh_50



grub损坏后,如何修复?(重新安装grub即可)


1、方式一

[root@localhost ~]# dd if=/dev/zero of=/dev/sda count=1 bs=400^C
[root@localhost ~]# grub
Probing devices to guess BIOS drives. This may take a long time.


    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.]
grub> root (hd0,0)   
root (hd0,0) 
 Filesystem type is ext2fs, partition type 0x83
grub> root (hd1,0)
root (hd1,0)
 Filesystem type unknown, partition type 0x83
grub> root (hd2,0)
root (hd2,0)

Error 21: Selected disk does not exist
grub> root (hd0,0)  (指定root)
root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83
grub>         
grub> setup (hd0)   (安装grub,指定硬盘)
setup (hd0)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd0)"...  27 sectors are embedded.
succeeded
 Running "install /grub/stage1 (hd0) (hd0)1+27 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded
Done.
grub> quit
quit
[root@localhost ~]# vim /boot/grub/grub.conf  #  (重装grub后,grub.conf配置正常)
[root@localhost ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=10
splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
password --md5 $1$jpSqC/$mamglM2INvMYRYlxJV4WO/
title hello,cxiong
 root (hd0,0)
 kernel /vmlinuz-2.6.32-504.el6.x86_64 ro root=UUID=57d85756-7680-4c7c-9125-6ad67dae2c45 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM quiet
 initrd /initramfs-2.6.32-504.el6.x86_64.img
[root@localhost ~]#

2、方式二

# grub-install --root-directory=/path/to/boot's_parent_dir  /PATH/TO/DEVICE  (root-directory是指grub所在根,并非/)
[root@localhost ~]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)  
/dev/mapper/myvg-mylv on /mydir type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
[root@localhost ~]#
#grub配置文件丢失(出现grub提示符后中止),解决办法
grub> find (hd0,0)/  #(tab键补全,是否可以找到vmlinuz,initrd文件)
grub> root (hd#,N)
grub> kernel /PATH/TO/KERNEL_FILE  root=/dev/hda2 quiet #(指定root目录)
grub> initrd /PATH/TO/INITRD_FILE
grub> setup(hd0)  #(安装grub)
grub> boot






如何为新硬盘指定grub

[root@localhost ~]# fdisk /dev/sda  
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x4c318e76.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1): +20M 
Last cylinder, +cylinders or +size{K,M,G} (3-2610, default 2610): q
Last cylinder, +cylinders or +size{K,M,G} (3-2610, default 2610): ^C
[root@localhost ~]# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x516e4b73.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +20M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p  
Partition number (1-4): 2
First cylinder (5-2610, default 5): 
Using default value 5
Last cylinder, +cylinders or +size{K,M,G} (5-2610, default 2610): +512M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (71-2610, default 71): 
Using default value 71
Last cylinder, +cylinders or +size{K,M,G} (71-2610, default 2610): +128M

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 82
Changed system type of partition 3 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x516e4b73

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1           4       32098+  83  Linux
/dev/sda2               5          70      530145   83  Linux
/dev/sda3              71          87      136552+  82  Linux swap / Solaris

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# mke2fs /dev/sda1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
8032 inodes, 32096 blocks
1604 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33030144
4 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks: 
 8193, 24577

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost ~]# mke2fs /dev/sda2
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
33200 inodes, 132536 blocks
6626 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=138412032
5 block groups
32768 blocks per group, 32768 fragments per group
6640 inodes per group
Superblock backups stored on blocks: 
 32768, 98304

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost ~]# mkswap /dev/sda3
Setting up swapspace version 1, size = 136548 KiB
no label, UUID=c92a2ee3-9697-4a99-b120-f8fde047c58b
[root@localhost ~]# 
[root@localhost ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x516e4b73

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1           4       32098+  83  Linux
/dev/sda2               5          70      530145   83  Linux
/dev/sda3              71          87      136552+  82  Linux swap / Solaris

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004cc30

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          39      307200   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sdb2              39        2350    18566144   83  Linux
/dev/sdb3            2350        2611     2097152   82  Linux swap / Solaris

Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x31e2db75

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         262     2104483+  83  Linux
/dev/sdc4             263        2610    18860310    5  Extended
/dev/sdc5             263         524     2104483+  83  Linux
/dev/sdc6             525        1178     5253223+  8e  Linux LVM
/dev/sdc7            1179        1310     1060258+  8e  Linux LVM
/dev/sdc8            1311        1442     1060258+  8e  Linux LVM
/dev/sdc9            1443        1574     1060258+  fd  Linux raid autodetect
/dev/sdc10           1575        1706     1060258+  fd  Linux raid autodetect
/dev/sdc11           1707        1968     2104483+  fd  Linux raid autodetect
/dev/sdc12           1969        2230     2104483+  fd  Linux raid autodetect
/dev/sdc13           2231        2492     2104483+  fd  Linux raid autodetect

Disk /dev/md127: 2168 MB, 2168455168 bytes
2 heads, 4 sectors/track, 529408 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 524288 bytes / 1048576 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/myvg-mylv: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# mkdir /mnt/boot
[root@localhost ~]# mount /dev/sda1 /mnt/boot
[root@localhost ~]# grub-install --root-directory=/mnt /dev/sda    #(安装grub)
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/sda
(hd1) /dev/sdb
(hd2) /dev/sdc
[root@localhost ~]# cd /mnt/boot/
[root@localhost boot]# ls
grub  lost+found
[root@localhost boot]# ls grub/
device.map     fat_stage1_5  iso9660_stage1_5  minix_stage1_5     stage1  ufs2_stage1_5    xfs_stage1_5
e2fs_stage1_5  ffs_stage1_5  jfs_stage1_5      reiserfs_stage1_5  stage2  vstafs_stage1_5
[root@localhost boot]# 
[root@localhost boot]# 
[root@localhost boot]# vim /mnt/boot/grub/grub.conf
[root@localhost boot]# cat /mnt/boot/grub/grub.conf
default=0
timeout=5
title fake linux
 root (hd0,0)
 kernel /vmlinuz
 initrd /initrd.img
[root@localhost boot]# umount /mnt/boot/
umount: /mnt/boot: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@localhost boot]# sync
[root@localhost boot]# sync
[root@localhost boot]# cd
[root@localhost ~]# umount /mnt/boot/
[root@localhost ~]#

新建虚拟机,挂载IDE硬盘


wKioL1jBX4OjlopaAAAkobMCBZQ014.png-wh_50






查看当前运行级别runlevel和who -r

[root@localhost ~]# runlevel
N 5  #(N:上一次级别,5:当前级别)
[root@localhost ~]#
[root@localhost ~]# who -r
         run-level 5  2017-03-03 22:54
[root@localhost ~]#





内核设计风格:


RedHat, SUSE
核心:动态加载 内核模块
内核:/lib/modules/“内核版本号命令的目录”/
vmlinuz-2.6.32
/lib/modules/2.6.32/

[root@localhost 2.6.32-504.el6.x86_64]# du -sh /boot/vmlinuz-2.6.32-504.el6.x86_64 
4.0M /boot/vmlinuz-2.6.32-504.el6.x86_64  #(内核大小为4M)
[root@localhost 2.6.32-504.el6.x86_64]# du -sh /lib/modules/
107M /lib/modules/        #(模块大小为107M,大大减少内核所在内存)
[root@localhost ~]# ll /lib/modules/  # (模块所在目录)
total 4
drwxr-xr-x. 7 root root 4096 Jun 21  2015 2.6.32-504.el6.x86_64
[root@localhost ~]#
[root@localhost 2.6.32-504.el6.x86_64]# ll
total 3608
lrwxrwxrwx.  1 root root     46 Jun 21  2015 build -> ../../../usr/src/kernels/2.6.32-504.el6.x86_64
drwxr-xr-x.  2 root root   4096 Sep 15  2014 extra
drwxr-xr-x. 11 root root   4096 Jun 21  2015 kernel
-rw-r--r--.  1 root root 604652 Jun 21  2015 modules.alias
-rw-r--r--.  1 root root 579321 Jun 21  2015 modules.alias.bin
-rw-r--r--.  1 root root   1413 Sep 15  2014 modules.block
-rw-r--r--.  1 root root     69 Jun 21  2015 modules.ccwmap
-rw-r--r--.  1 root root 204307 Jun 21  2015 modules.dep   #(模块之间映射关系)
-rw-r--r--.  1 root root 296406 Jun 21  2015 modules.dep.bin
-rw-r--r--.  1 root root     68 Sep 15  2014 modules.drm
-rw-r--r--.  1 root root    665 Jun 21  2015 modules.ieee1394map
-rw-r--r--.  1 root root    141 Jun 21  2015 modules.inputmap
-rw-r--r--.  1 root root   1313 Jun 21  2015 modules.isapnpmap
-rw-r--r--.  1 root root     29 Sep 15  2014 modules.modesetting
-rw-r--r--.  1 root root   1974 Sep 15  2014 modules.networking
-rw-r--r--.  1 root root     74 Jun 21  2015 modules.ofmap
-rw-r--r--.  1 root root  76447 Sep 15  2014 modules.order
-rw-r--r--.  1 root root 452824 Jun 21  2015 modules.pcimap
-rw-r--r--.  1 root root   6259 Jun 21  2015 modules.seriomap
-rw-r--r--.  1 root root    165 Jun 21  2015 modules.softdep
-rw-r--r--.  1 root root 239283 Jun 21  2015 modules.symbols
-rw-r--r--.  1 root root 301921 Jun 21  2015 modules.symbols.bin
-rw-r--r--.  1 root root 852337 Jun 21  2015 modules.usbmap
lrwxrwxrwx.  1 root root      5 Jun 21  2015 source -> build
drwxr-xr-x.  2 root root   4096 Sep 15  2014 updates
drwxr-xr-x.  2 root root   4096 Jun 21  2015 vdso
drwxr-xr-x.  2 root root   4096 Sep 15  2014 weak-updates
[root@localhost 2.6.32-504.el6.x86_64]# cd kernel/
[root@localhost kernel]# ll
total 36
drwxr-xr-x.  3 root root 4096 Jun 21  2015 arch  #(平台)
drwxr-xr-x.  3 root root 4096 Jun 21  2015 crypto # 加密
drwxr-xr-x. 63 root root 4096 Jun 21  2015 drivers  #驱动
drwxr-xr-x. 30 root root 4096 Jun 21  2015 fs  #文件系统
drwxr-xr-x.  3 root root 4096 Jun 21  2015 kernel # 内核
drwxr-xr-x.  6 root root 4096 Jun 21  2015 lib  #库
drwxr-xr-x.  2 root root 4096 Jun 21  2015 mm  #内存管理
drwxr-xr-x. 28 root root 4096 Jun 21  2015 net  #网络
drwxr-xr-x.  9 root root 4096 Jun 21  2015 sound # 声卡
[root@localhost kernel]#
[root@localhost kernel]# ls drivers/net/  #(所有类型网卡驱动,按需加载)
3c59x.ko     bnx2.ko     e1000         igb         mlx5           ppp_async.ko    r8169.ko     sundance.ko    via-rhine.ko
8139cp.ko    bnx2x       e1000e        igbvf       myri10ge       ppp_deflate.ko  s2io.ko      sungem.ko      via-velocity.ko
8139too.ko   bonding     e100.ko       ipg.ko      natsemi.ko     ppp_generic.ko  sc92031.ko   sungem_phy.ko  virtio_net.ko
8390.ko      can         enic          ixgb        ne2k-pci.ko    ppp_mppe.ko     sfc          sunhme.ko      vmxnet3
acenic.ko    cassini.ko  epic100.ko    ixgbe       netconsole.ko  pppoe.ko        sis190.ko    tehuti.ko      vxge
amd8111e.ko  chelsio     ethoc.ko      ixgbevf     netxen         pppol2tp.ko     sis900.ko    tg3.ko         vxlan.ko
atl1c        cnic.ko     fealnx.ko     jme.ko      niu.ko         pppox.ko        skge.ko      tlan.ko        wan
atl1e        cxgb3       forcedeth.ko  macvlan.ko  ns83820.ko     ppp_synctty.ko  sky2.ko      tulip          wimax
atlx         cxgb4       hyperv        macvtap.ko  pch_gbe        qla3xxx.ko      slhc.ko      tun.ko         wireless
b44.ko       dl2k.ko     i40e          mdio.ko     pcmcia         qlcnic          slip.ko      typhoon.ko     xen-netfront.ko
benet        dnet.ko     i40evf        mii.ko      pcnet32.ko     qlge            smsc9420.ko  usb
bna          dummy.ko    ifb.ko        mlx4        phy            r6040.ko        starfire.ko  veth.ko
[root@localhost kernel]#





模拟根切换

chroot: chroot /PATH/TO/TEMPROOT [COMMAND...]
 chroot /test/virrrot  /bin/bash

[root@localhost ~]# ldd /test/myroot/bin/bash # (显示二进制文件所依赖的共享库)
 linux-vdso.so.1 =>  (0x00007fff557dd000)
 libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000003ca3600000)
 libdl.so.2 => /lib64/libdl.so.2 (0x0000003c98a00000)
 libc.so.6 => /lib64/libc.so.6 (0x0000003c98e00000)
 /lib64/ld-linux-x86-64.so.2 (0x0000003c98600000)
[root@localhost ~]# mkdir -p /test/myroot/lib64  #(64位,创建/lib64)
[root@localhost ~]# cp /lib64/libtinfo.so.5 /test/myroot/lib64
[root@localhost ~]# cp /lib64/libdl.so.2 /test/myroot/lib64
[root@localhost ~]# cp /lib64/libc.so.6 /test/myroot/lib64
[root@localhost ~]# cp /lib64/ld-linux-x86-64.so.2 /test/myroot/lib64
[root@localhost ~]# ll /test/myroot/lib64
total 2200
-rwxr-xr-x. 1 root root  156936 Mar  1 19:55 ld-linux-x86-64.so.2
-rwxr-xr-x. 1 root root 1926760 Mar  1 19:55 libc.so.6
-rwxr-xr-x. 1 root root   22536 Mar  1 19:54 libdl.so.2
-rwxr-xr-x. 1 root root  138280 Mar  1 19:54 libtinfo.so.5
[root@localhost ~]# ll /test/myroot/bin/
total 920
-rwxr-xr-x. 1 root root 940416 Mar  1 19:44 bash
[root@localhost ~]# ll /test/myroot/
total 12
drwxr-xr-x. 2 root root 4096 Mar  1 19:44 bin
drwxr-xr-x. 2 root root 4096 Mar  1 19:46 lib
drwxr-xr-x. 2 root root 4096 Mar  1 19:55 lib64
[root@localhost ~]# chroot /test/myroot/
bash-4.1# ll
bash: ll: command not found
bash-4.1# cd /bin/
bash-4.1# ls
bash: ls: command not found
bash-4.1#






 单内核:Linux (LWP)
  核心:ko(kernel object)
 so()
  
 微内核:Windows, Solaris (线程)

chroot: chroot /PATH/TO/TEMPROOT [COMMAND...]
 chroot /test/virrrot  /bin/bash

 
ldd /PATH/TO/BINARY_FILE:显示二进制文件所依赖的共享库 (查看应用程序的动态链接库)