2.1.3 Kernel command line: ro root=/dev/hda1
来源:互联网 发布:mysql增删改查 面试 编辑:程序博客网 时间:2024/05/01 11:01
from 精通Linux设备驱动程序开发
2.1.3 Kernel command line: ro root=/dev/hda1
Linux的引导装入程序通常会给内核传递一个命令行。命令行中的参数类似于传递给C程序中main()函数的argv[]列表,唯一的不同在于它们是传递给内核的。可以在引导装入程序的配置文件中增加命令行参数,当然,也可以在运行过程中通过引导装入程序修改Linux的命令行 。如果使用的是GRUB这个引导装入程序,由于发行版本的不同,其配置文件可能是/boot/grub/grub.conf或者是/boot/grub/menu.lst。如果使用的是LILO,配置文件为/etc/lilo.conf。下面给出了一个grub.conf文件的例子(增加了一些注释),看了紧接着title kernel 2.6.23的那行代码之后,你会明白前述打印信息的由来。
- default 0 #Boot the 2.6.23 kernel by default
- timeout 5 #5 second to alter boot order or parameters
- title kernel 2.6.23 #Boot Option 1
- #The boot image resides in the first partition of the first disk
- #under the /boot/ directory and is named vmlinuz-2.6.23. 'ro'
- #indicates that the root partition should be mounted read-only.
- kernel (hd0,0)/boot/vmlinuz-2.6.23 ro root=/dev/hda1
- #Look under section "Freeing initrd memory:387k freed"
- initrd (hd0,0)/boot/initrd
- #...
命令行参数将影响启动过程中的代码执行路径。举一个例子,假设某命令行参数为bootmode,如果该参数被设置为1,意味着你希望在启动过程中打印一些调试信息并在启动结束时切换到runlevel的第3级(初始化进程的启动信息打印后就会了解runlevel的含义);如果bootmode参数被设置为0,意味着你希望启动过程相对简洁,并且设置runlevel为2。既然已经熟悉了init/main.c文件,下面就在该文件中增加如下修改:
- static unsigned int bootmode = 1;
- static int __init
- is_bootmode_setup(char *str)
- {
- get_option(&str, &bootmode);
- return 1;
- }
- /* Handle parameter "bootmode=" */
- __setup("bootmode=", is_bootmode_setup);
- if (bootmode) {
- /* Print verbose output */
- /* ... */
- }
- /* ... */
- /* If bootmode is 1, choose an init runlevel of 3, else
- switch to a run level of 2 */
- if (bootmode) {
- argv_init[++args] = "3";
- } else {
- argv_init[++args] = "2";
- }
- /* ... */
请重新编译内核并尝试运行新的修改。另外,本书18.5节也将对内核命令行参数进行更详细的讲解。
- 2.1.3 Kernel command line: ro root=/dev/hda1
- kernel command line 参数详解
- kernel command line 参数详解
- IOS Dev Intro - Reboot by Command line
- Linux kernel command line 参数详解
- kernel parameter 与 kernel command line 的关系
- Command Line -- Lesson 3
- Linux Kernel command line 内核输入参数/proc/cmdline
- grub 内核启动参数(kernel command-line parameters)
- command line
- command line
- command line
- Command-line
- Command Line
- kernel command
- Error mounting /dev/sda1 at /media/XXXX: Command-line `mount -t "ntfs" -o
- Error mounting /dev/sda1 at /media/XXXX: Command-line `mount -t "ntfs" -o
- Error mounting /dev/sda1 at /media/XXXX: Command-line `mount -t "ntfs" -o
- 备忘-tomcat-maven-plugin的使用
- firefox+plugin+jre
- VS2005的安装与部署(WEB应用程序
- oracle数据文件丢失处理方法一(测试)
- 多个字段的in 和 not in 及其替代写法(exists,not exists)
- 2.1.3 Kernel command line: ro root=/dev/hda1
- .net应用程序如何批上XP的外衣?
- 人生的34个好习惯,共勉
- 希尔排序 实现
- Win7 下 VS2008 SP1 KB945140 安装失败 解决方法
- 将现有的Access数据库升级为SQL数据库
- 内核命令处理
- Fedora12 Linux启动过程
- UNIX环境高级编程学习之第十二章线程控制-可重入(线程安全)的getenv方法