Chinaunix首页 | 论坛 | 博客
  • 博客访问: 753091
  • 博文数量: 215
  • 博客积分: 291
  • 博客等级: 二等列兵
  • 技术积分: 1031
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-12 18:17
文章分类

全部博文(215)

文章存档

2016年(16)

2015年(16)

2014年(123)

2013年(60)

分类: 嵌入式

2013-10-28 15:08:29

Initrd

 Boot-up Operation
       When booting up with initrd, the system boots as follows:

       1. The boot loader loads the kernel program and /dev/initrd’s contents into memory.

       2. On kernel startup, the kernel uncompresses and copies the contents  of  the  device  /dev/initrd  onto
          device /dev/ram0 and then frees the memory used by /dev/initrd.  /* /dev/initrd 是一块内存 */

       3. The kernel then read-write mounts the device /dev/ram0 as the initial root file system.

       4. If  the  indicated normal root file system is also the initial root file-system (e.g.  /dev/ram0) then
          the kernel skips to the last step for the usual boot sequence.

       5. If the executable file /linuxrc is present in the initial root file-system, /linuxrc is executed  with
          UID  0.   (The file /linuxrc must have executable permission.  The file /linuxrc can be any valid exe-
          cutable, including a shell script.)

       6. If /linuxrc is not executed or when /linuxrc terminates, the normal root file system is mounted.   (If
          /linuxrc exits with any file-systems mounted on the initial root file-system, then the behavior of the
          kernel is UNSPECIFIED.  See the NOTES section for the current kernel behavior.)

       7. If the normal root file system has a directory /initrd, the device /dev/ram0 is moved from / to  /ini-
          trd.   Otherwise  if  the  directory /initrd does not exist, the device /dev/ram0 is unmounted.  (When
          moved from / to /initrd, /dev/ram0 is not unmounted and therefore processes can  remain  running  from
          /dev/ram0.   If  directory  /initrd  does  not  exist on the normal root file system and any processes
          remain running from /dev/ram0 when /linuxrc exits, the behavior of the kernel is UNSPECIFIED.  See the
          NOTES section for the current kernel behavior.)

       8. The  usual boot sequence (e.g., invocation of /sbin/init) is performed on the normal root file system.



===============================================================
名称
initrd -- 由启动加载器进行初始化的RAM DISK

描述
/dev/initrd这个特殊文件是一个只读的块设备文件。/dev/initrd设备文件是一个在内核被启动之前由启动加载器进行初始化的RAM disk。
随后,内核利用/dev/initrd设备文件的内容进行两个阶段的(系统)自举。
在(系统)自举的第一个阶段,内核进行初始化,根据/dev/initrd的内容挂载一个原始根文件系统。
在第二个阶段,一些附加的驱动或者其他模块从原始的根设备中被加载。在加载完附加模块后,一个新的根文件系统(也就是常规的根文件系统)从别的设备被挂载。

自举操作流程
使用initrd进行系统自举,系统初始化如下:

1.启动加载器把内核程序以及/dev/initrd的内容加载到内存

2.在内核初始化过程中,内核把/dev/initrd设备的内容解压缩并拷贝到/dev/ram0设备上,随之释放被/dev/initrd占用的内存空间

3.接着内核以可读写的方式把/dev/ram0设备挂载为原始的根文件系统

4.如果(不知道如何翻译indicated)常规根文件系统也是原始根文件系统(举例来说,/dev/ram0),那么内核跳至最后一步正常启动

5.如果可执行文件/linuxrc存在于原始根文件系统上,/linuxrc就以uid为0的帐户身份被执行。(/linuxrc文件必须具有可执行属性,它可以是包括shell脚本在内的任何有效的可执行文件)

6.如果/linuxrc没有被执行或者当/linuxrc(的运行)终止时,常规根文件系统被挂载。(如果/linuxrc退出时在原始根文件系统上挂载了任意文件系统,那么内核的行为则是不定的。阅读注意事项以确定当前的内核行为)

7.如果常规根文件系统存在/initrd目录,那么/dev/ram0将从/移动到/initrd。否则如果/initrd目录不存在, /dev/ram0将被卸载。(当从/移动到/initrd而/dev/ram0没有被卸载时,会导致进程仍能从/dev/ram0运行)。如果 /initrd目录不存在,并且当/linuxrc退出时任何进程仍能从/dev/ram0运行,内核的行为是不定的。阅读注意事项以确定当前内核的行 为。)

8.正常的启动过程(比如/sbin/init的调用)将在常规根文件系统上进行
...
注意事项
1.在当前内核下,当/dev/ram0从/被移动到/initrd时,任何已挂载的文件系统依然能被访问。然而,/proc/mounts条目不会被更新。
2.在当前内核下,如果/initrd不存在,如果/dev/ram0被其他进程使用中或者有任何文件系统被挂载其上,/dev/ram0将不会被完全卸载。如果/dev/ram0没有被完全卸载,那么/dev/ram0将驻留在内存

----------------------------------------------------------------------------------------------------------------------------------------------------------------
阅读(680) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~