linux-2.6.36内核

start       arch/arm/boot/compressed/head.S

arch/arm/kernel/head.S

start_kernel()    init/main.c

linux通用内核启动代码在init/main.c中:

汇编执行完后跳转到start_kernel()开始C 执行。

...

setup_arch(&command_line);      //把.config中配置的CONFIG_CMDLINE赋予command_line输出

...

setup_command_line(command_line);     //boot_command_line =>save_command_line;

//command_line =>static_command_line;

...

printk(KERN_NOTICE ''kernel command line:%s\n", boot_command_line);

...

console_init();

...

rest_init();    //创建两线程kernel_init /kthreadd

|----------->kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);

|----------->kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);            //kernel/kthread.c

pid_t kernel_thread(int (*fn)(void *), void *args, unsigned long  flags);  //arch/arm/kernel/process.c

----------------------------------------------------------------------------------------------------------------------------------------

kernel_init()                    //init/main.c

|---------->do_basic_setup()   //解压了相关文件系统

sys_open("/dev/console", O_RDWR, 0) <0

printk(KERN_WARNING "Warning: unable to open an initial console.\n");

if(! ramdisk_execute_command)

ramdisk_execute_command = "/init";             //initramfs 默认启动进程衔接

if(sys_access(ramdisk_execute_command, 0) != 0){

ramdisk_execute_command = NULL;

prepare_namespace();  //处理除ramdisk和initramfs外的其他文件系统。

}

|---------->init_post();

// ramdisk_execute_command <= "rdinit="

// execute_command <= "init="   //bootargs传递

-----------------------------------------------------------------------------------------------------------------

kernel_init()-->do_basic_setup()

mm/CPU已运行,没有设备被创建。

786 /*
787  * Ok, the machine is now initialized. None of the devices
788  * have been touched yet, but the CPU subsystem is up and
789  * running, and memory and process management works.
790  *
791  * Now we can finally start doing some real work..
792  */
793 static void __init do_basic_setup(void)
794 {
795     cpuset_init_smp();
796     usermodehelper_init();
797     init_tmpfs();
798     driver_init();
799     init_irq_proc();
800     do_ctors();
801     do_initcalls();
802 }

773 extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end    [];
774
775 static void __init do_initcalls(void)
776 {
777     initcall_t *fn;
778
779     for (fn = __early_initcall_end; fn < __initcall_end; fn++)
780         do_one_initcall(*fn);
781
782     /* Make sure there is no pending stuff from the initcall sequence */
783     flush_scheduled_work();
784 }
kernel_init()  -> do_basic_setup() -> do_initcalls() ->rootfs_initcall(populate_rootfs) -> populate_rootfs()

ramdisk或initramfs的处理都是通过populate_rootfs()实现,位于init/initramfs.c中。

-----------------------------------------------------------------------------------------------------------------

init_post()      // init/main.c

if (ramdisk_execute_command) {
835         run_init_process(ramdisk_execute_command);
836         printk(KERN_WARNING "Failed to execute %s\n",
837                 ramdisk_execute_command);
838     }
839
840     /*
841      * We try each of these until one succeeds.
842      *
843      * The Bourne shell can be used instead of init if we are
844      * trying to recover a really broken machine.
845      */
846     if (execute_command) {
847         run_init_process(execute_command);
848         printk(KERN_WARNING "Failed to execute %s.  Attempting "
849                     "defaults...\n", execute_command);
850     }
851     run_init_process("/sbin/init");
852     run_init_process("/etc/init");
853     run_init_process("/bin/init");
854     run_init_process("/bin/sh");
855
856     panic("No init found.  Try passing init= option to kernel. "
857           "See Linux Documentation/init.txt for guidance.");

linux系统启动完成后,任务都交给init进程完成。
---------------------------------------------------------------------------------------------------------

ramdisk和initramfs都是通过populate_rootfs()实现;

jffs,yaffs等通过prepare_namespace()实现,在do_mounts.c中。

linux挂载根文件系统过程的更多相关文章

  1. 根文件系统制作、NFS配置与安装及利用NFS挂载根文件系统

    最近打算从头开始制作根文件系统,下面是开发过程. 一.根文件系统的制作 0.FHS(Filesystem Hierarchy Standard)标准介绍 该标准规定了根目录下各个子目录的名称及其存放的 ...

  2. 用Qemu模拟vexpress-a9 (四) --- u-boot引导kernel,用nfs挂载根文件系统

    环境介绍 Win7 64 + Vmware 11 + ubuntu14.04 32 u-boot 版本:u-boot-2015-04 Linux kernel版本:linux-3.16.y busyb ...

  3. 目标板通过nfs挂载根文件系统

    目标板挂载根文件系统的方法有两种(这里所说的服务端就是ubuntu,Ubuntu已经成功安装了nfs服务,并且保证服务端与目标板ping 通) 第一种:等待开发板启动之后去挂载,此时文件系统从Flas ...

  4. 嵌入式Linux内核+根文件系统构建工具-Buildroot 快速入手指导【转】

    本文转载自:https://my.oschina.net/freeblues/blog/596448 嵌入式Linux内核+根文件系统构建工具-Buildroot 快速入手指导 buildroot 是 ...

  5. 【原创】-- nfs安装配置及使用,挂载根文件系统

    环境:ubuntu14.04(非虚拟机),OK6410 环境搭建: (1) #sudo apt-get install nfs-kernel-server 如果已经是最新版本了,无需安装 (2) 建立 ...

  6. Linux制作根文件系统笔记

    测试平台 宿主机平台:Ubuntu 12.04.4 LTS 目标机:Easy-ARM IMX283 目标机内核:Linux 2.6.35.3 交叉编译器:arm-linux-gcc 4.4.4 Bus ...

  7. Linux之根文件系统的构建20160611

    说一下LINUX根文件系统的构建: 制作文件系统 1. 交叉编译busybox 安装:make install CONFIG_PREFIX=/work/nfs_root/fs_mini_mdev_ne ...

  8. 使用ubifs格式的根文件系统---过程记录

    配置内核,使其支持ubifs文件系统 1)Device Drivers  --->Memory Technology Device (MTD) support  --->UBI - Uns ...

  9. linux内核挂载根文件系统时报错”VFS: Cannot open root device "ram0" or unknown-block(0,0): error -6“如何处理?

    1. 通过error -6得到: #define ENXIO            6      /* No such device or address */ 2. 解决办法 使能CONFIG_BL ...

随机推荐

  1. 简述Android触摸屏手势识别

    很多时候,利用触摸屏的Fling.Scroll等Gesture(手势)操作来操作会使得应用程序的用户体验大大提升,比如用Scroll手势在 浏览器中滚屏,用Fling在阅读器中翻页等.在Android ...

  2. 【jQuery】清空表单内容

    function resertForm(){ $(':input','#formId') .not(':button, :submit, :reset, :hidden') .val('') .rem ...

  3. Eureka常见问题总结

    在Spring-cloud做微服务架构时,会碰到各种坑.下面总结一下Eureka的常见问题. 一.Eureka的自我保护模式   如果在Eureka Server的首页看到以下这段提示,则说明Eure ...

  4. python学习笔记011——内置函数__module__、__name__

    1 __module__描述 __module__ : 如果当前模块为顶层模块执行 则打印__main__ 如果当前模块为被调用模块的时候 打印当前模块的名称 2 __module__示例 def f ...

  5. CodeForces 550A Two Substrings(模拟)

    [题目链接]click here~~  [题目大意]:  You are given string s. Your task is to determine if the given string s ...

  6. mysql 数据表的引擎 MyISAM 和 InnoDB

    需要使用锁和事务时,必须使用InnoDB模式 可以通过以下语句查看表的类型 SHOW TABLE STATUS FROM [DATABASE_NAME] 修改数据表的引擎类型: navicat: 设计 ...

  7. python map 详解

    python中的map函数应用于每一个可迭代的项,返回的是一个结果list.如果有其他的可迭代参数传进来,map函数则会把每一个参数都以相应的处理函数进行迭代处理.map()函数接收两个参数,一个是函 ...

  8. servlet中 getRealPath deprecated(被废弃)

    servlet中, HttpRequestServlent req;  req.getRealPath 被废弃,使用this.getServletContext().getRealPath()替代:

  9. TensorFlow运作方式入门

    TensorFlow运作方式入门 代码:tensorflow/g3doc/tutorials/mnist/ 本篇教程的目的,是向大家展示如何利用TensorFlow使用(经典)MNIST数据集训练并评 ...

  10. 如何学好FPGA

    http://bbs.elecfans.com/jishu_278578_1_1.html 掌握FPGA可以找到一份很好的工作,对于有经验的工作人员,使用FPGA可以让设计变得非常有灵活性.掌握了FP ...