Linux Kernel command line 内核输入参数/proc

1130阅读 0评论2013-10-15 wfeng
分类:系统运维

内核参数,就是写在grub 的menu.lst内里 可能通过其他地方 ,是传给内核的参数。由种种 boot loader (grub ,lilo, pxeloader 等)认真 复制到内存指定职位 ,然后linux内核通过boot loader转达 过来的 一个指针(cmdline pointer)可以获取到。然后成立 起/proc/cmdline文件,操纵措施可以通过读取这个文件来得到参数。表明 见Linux内核自带的文档Documentation/x86/boot.txt 。

THE LINUX/x86 BOOT PROTOCOL
-----------------------------------------------------

0A0000 +------------------------+
        | Reserved for BIOS     |      Do not use. Reserved for BIOS EBDA.
09A000 +------------------------+
        | Command line          |   参数在这里
        | Stack/heap            |      For use by the kernel real-mode code.
098000 +------------------------+     
        | Kernel setup          |      The kernel real-mode code.
090200 +------------------------+
        | Kernel boot sector    |      The kernel legacy boot sector.
090000 +------------------------+
        | Protected-mode kernel |      The bulk of the kernel image.
010000 +------------------------+
        | Boot loader           |      <- Boot sector entry point 0000:7C00
001000 +------------------------+
        | Reserved for MBR/BIOS |
000800 +------------------------+
        | Typically used by MBR |
000600 +------------------------+
        | BIOS use only         |
000000 +------------------------+




654void __init setup_arch(char **cmdline_p)
655{
656#ifdef CONFIG_X86_32
657        memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
658        visws_early_detect();
659        pre_setup_arch_hook();
660#else
661        printk(KERN_INFO "Command line: %s\n", boot_command_line);
662#endif



529
530asmlinkage void __init start_kernel(void)
531{
532        char * command_line;
533        extern struct kernel_param __start___param[], __stop___param[];
534
535        smp_setup_processor_id();
536
537        /*
538         * Need to run as early as possible, to initialize the
539         * lockdep hash:
540         */
541        lockdep_init();
542        debug_objects_early_init();
543        cgroup_init_early();
544
545        local_irq_disable();
546        early_boot_irqs_off();
547        early_init_irq_lock_class();
548
549/*
550 * Interrupts are still disabled. Do necessary setups, then
551 * enable them
552 */
553        lock_kernel();
554        tick_init();
555        boot_cpu_init();
556        page_address_init();
557        printk(KERN_NOTICE);
558        printk(linux_banner);
559        setup_arch(&command_line);     **************初始化?******************
560        mm_init_owner(&init_mm, &init_task);
561        setup_command_line(command_line);
562        setup_per_cpu_areas();
563        setup_nr_cpu_ids();
564        smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
565
566        /*
567         * Set up the scheduler prior starting any interrupts (such as the
568         * timer interrupt). Full topology setup happens at smp_init()
569         * time - but meanwhile we still have a functioning scheduler.
570         */
571        sched_init();
572        /*
573         * Disable preemption - early bootup scheduling is extremely
574         * fragile until we cpu_idle() for the first time.
575         */
576        preempt_disable();
577        build_all_zonelists();
578        page_alloc_init();
579        printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line); 这里会打印出来
580        parse_early_param();

553        lock_kernel();
554        tick_init();
555        boot_cpu_init();
556        page_address_init();
557        printk(KERN_NOTICE);
558        printk(linux_banner);
559        setup_arch(&command_line);

     
上一篇:VMware View 介绍PowerShell的命令行界面(CLI)
下一篇:Nginx 防盗链配置