控制Linux kernel启动console的打印级别
2015-12-11 17:24
746 查看
注:代码来自内核版本2.6.36
在Build kernel时,在CONFIG_CMDLINE宏中设定级别:CONFIG_CMDLINE="debug|quiet|loglevel=5",这个宏会在kernel启动时作为默认配置参数。
debug表示loglevel=10
quiet表示loglevel=4
loglevel=5表示loglevel=5
处理log级别的代码如下(见内核代码init/main.c)
235 /* 236 * This should be approx 2 Bo*oMips to start (note initial shift), and will 237 * still work even if initially too large, it will just take slightly longer 238 */ 239 unsigned long loops_per_jiffy = (1<<12); 240 241 EXPORT_SYMBOL(loops_per_jiffy); 242 243 static int __init debug_kernel(char *str) 244 { 245 console_loglevel = 10; 246 return 0; 247 } 248 249 static int __init quiet_kernel(char *str) 250 { 251 console_loglevel = 4; 252 return 0; 253 } 254 255 early_param("debug", debug_kernel); 256 early_param("quiet", quiet_kernel); 257 258 static int __init loglevel(char *str) 259 { 260 get_option(&str, &console_loglevel); 261 return 0; 262 } 263 264 early_param("loglevel", loglevel);
注意:在系统启动时,可以从bootloader中将CONFIG_CMDLINE参数传递给kernel。
相关文章推荐
- Deepin linux 安装JDK的方法
- BeautifulSoup win+linux 安装配置
- Linux下搭建Swift开发环境
- linux ffplay 生成
- linux下使用bower时提示bower ESUDO Cannot be run with sudo解决办法
- Greenplum 在Linux下的安装(centOS,RedHat)
- linux命令-zip
- linux服务器常用操作和命令
- linux命令-tar
- Linux下查看文件常用命令-cat,more,less,head,tail
- Linux每日学习(一)
- Linux I2C设备驱动编写(三)-实例分析AM3359
- Linux I2C设备驱动编写(二)
- Linux I2C设备驱动编写(一)
- linux下遍历目录
- java在linux系统下开机启动无法使用sudo命令的原因
- linux设备驱动之ioctl控制
- Linux 定时备份数据库
- Linux命令中的 vi 操作
- CentOS 64位 安装openfire 3_10_3