Chinaunix首页 | 论坛 | 博客
  • 博客访问: 640224
  • 博文数量: 90
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 2018
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-03 13:09
文章分类

全部博文(90)

文章存档

2010年(7)

2009年(23)

2008年(60)

我的朋友

分类: LINUX

2008-12-07 19:35:26

http://linuxdevices.com/articles/AT4017834659.html

nitrd vs initramfs

The change in underlying infrastructure was a reason for the kernel developers to create a new implementation, but while they were at it they cleaned up a lot of bad behavior and assumptions.

Initrd was designed as front-end to the old "root=" root device detection code, not a replacement for it. It ran a program called "/linuxrc" which was intended to perform setup functions (like logging on to the network, determining which of several devices contained the root partition, or associating a loopback device with a file), tell the kernel which block device contained the real root device (by writing the de_t number to /proc/sys/kernel/real-root-dev), and then return to the kernel so the kernel could mount the real root device and execute the real init program.

This assumed that the "real root device" was a block device rather than a network share, and also assumed that initrd wasn't itself going to be the real root filesystem. The kernel didn't even execute "/linuxrc" as the special process ID 1, because that process ID (and its special properties like being the only process that can not be killed with "kill -9") was reserved for init, which the kernel was waiting to run after it mounted the real root filesystem.

With initramfs, the kernel developers removed all these assumptions. Once the kernel launches "/init" out of initramfs, the kernel is done making decisions and can go back to following orders. With initramfs, the kernel doesn't care where the real root filesystem is (it's initramfs until further notice), and the "/init" program from initramfs is run as a real init, with PID 1. (If initramfs's init needs to hand that special Process ID off to another program, it can use the exec() syscall just like everybody else.)
阅读(1640) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~