手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

移植Linux 2.6.26到S3C2410(ARM9)

[日期:2009-10-11] 来源:eslxf.blog.51cto.com  作者:eslxf [字体:大 中 小]

6.2.8.      内核参数配置
清单46 内核启动参数配置
noinitrd root=/dev/nfs rw nfsroot=135.1.2.192:/arm-linux/rootfs/nfs-rootfs ip=dhcp console=ttySAC0,115200 init=/linuxrc
清单47 内核网络选项配置
Networking  --->   
   [*] Networking support                                        
           Networking options  ---> 
           [*]   IP: kernel level autoconfiguration                
                [*]     IP: DHCP support
             [*]     IP: BOOTP support 
                [*]     IP: RARP support
清单48 内核文件系统配置
File systems  --->
   [*] Network File Systems  --->
        --- Network File Systems
       <*>   NFS file system support
            [*]     Provide NFSv3 client support
            [ ]       Provide client support for the NFSv3 ACL protocol exten
            [ ]     Provide NFSv4 client support (EXPERIMENTAL)  
       < >   NFS server support                                       
       [*]   Root file system on NFS
 
6.2.9.      NFS测试
把NFS文件/arm-linux/rootfs/nfs-rootfs做为根文件系统启动内核,查看运行信息。测试结果如清单49所示,测试表明NFS根文件系统制作成功。
清单49 NFS根文件系统的启动结果
...
Sending DHCP requests ., OK
IP-Config: Got DHCP answer from 0.0.0.0, my address is 135.1.2.150
IP-Config: Complete:
     device=eth0, addr=135.1.2.150, mask=255.255.255.0, gw=255.255.255.255,
     host=135.1.2.150, domain=, nis-domain=(none),
     bootserver=0.0.0.0, rootserver=135.1.2.192, rootpath=/arm-linux/rootfs/nfs-rootfs
Looking up port of RPC 100003/2 on 135.1.2.192
Looking up port of RPC 100005/1 on 135.1.2.192
VFS: Mounted root (nfs filesystem).
Freeing init memory: 144K
init started: BusyBox v1.9.0 (2008-09-17 11:51:15 CST)
starting pid 810, tty '': '/etc/init.d/rcS'
Processing /etc/init.d/rcS......
mount all
Starting mdev......
YF2410 Rootfs(nfs)
Enjoy Linux......
starting pid 814, tty '': '/bin/login'
135.1.2.150 login: root
Password: <12345678>
login[814]: root login  on `console'
Processing /etc/profile......
Set search library path in /etc/profile
Set user path in /etc/profile
Set PS1 in /etc/profile
Done
[root@/root]#cd /
[root@/]#ls
bin      dev      home     linuxrc  proc     sbin     tmp      var
boot     etc      lib      mnt      root     sys      usr
[root@/]#cd /home
[root@/home]#ls
[root@/home]#vi testfile
[root@/home]#ls
testfile
[root@/home]#cat testfile
This a test file!
 
把/etc/inittab文件中的::respawn:-/bin/login 语句修改为::respawn:-/bin/sh语句可以不用登录即可直接进入shell,测试结果如清单50。
清单50 不用登录即可直接进入shell

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

…
VFS: Mounted root (nfs filesystem).
Freeing init memory: 144K
init started: BusyBox v1.9.0 (2008-09-17 11:51:15 CST)
starting pid 810, tty '': '/etc/init.d/rcS'
Processing /etc/init.d/rcS......
mount all
Starting mdev......
YF2410 Rootfs(nfs)
Enjoy Linux......
starting pid 814, tty '': '/bin/sh'
Processing /etc/profile......
Set search library path in /etc/profile
Set user path in /etc/profile
Set PS1 in /etc/profile
Done
[root@/]#ls
bin      dev      home     linuxrc  proc     sbin     tmp      var
boot     etc      lib      mnt      root     sys      usr

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

 
提示:挂载根文件时,提示“Warning: unable to open an initial console. ”启动信息问题的解决,以NFS为例。
清单51 问题现象

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

…
VFS: Mounted root (nfs filesystem).
Freeing init memory: 144K
Warning: unable to open an initial console.<启动停到此处>

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

根据提示信息定位错误
查找错误原因: 根据错误提示信息:”Warning: unable to open an initial console.”查看内核源代码。可定位错误提示在内核文件linux-2.6.26.2/init/main.c文件中。
清单52 分析main.c的调用关系

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

asmlinkage void __init start_kernel(void)
{
…
rest_init();
}
 
static void noinline __init_refok rest_init(void)
    __releases(kernel_lock)
{
…
kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
…
}
 
static int __init kernel_init(void * unused)
{
…
init_post();
    return 0;
}
 
static int noinline init_post(void)
{
…
if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
        printk(KERN_WARNING "Warning: unable to open an initial console.\n");
…
run_init_process("/sbin/init");
…
}

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

通过分析知道内核启动时需要成功打开/dev/console设备,否则给出"Warning: unable to open an initial console."的错误提示。
检查nfs根文件系统的/dev目录<在Host上的nfs文件/arm-linux/rootfs/nfs-rootfs /dev中>是否包含console设备文件。具体修改参见清单53。
清单53 修改NFS设备文件
[root@lxf dev]# pwd
/arm-linux/rootfs/nfs-rootfs/dev
[root@lxf dev]# ls
//无console设备文件节点,参考主机配置给NFS添加console设备文件节点
[root@lxf dev]# ls -l /dev|grep console
crw-------  1 root root   5,   1 09-05 08:06 console
//为目标机配置console设备文件节点
[root@lxf dev]# mknod console c 5 1
[root@lxf dev]# mknod null c 1 3
//查看配置结果
[root@lxf dev]# ls -l
总计 0
crw------- 1 root root 5, 1 09-17 11:38 console
crw-rw-rw- 1 root root 1, 3 09-17 11:38 null
NFS根文件系统的启动结果表明修改正确。
清单54 NFS测试结果

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

...
VFS: Mounted root (nfs filesystem).
Freeing init memory: 144K
init started: BusyBox v1.9.0 (2008-09-17 11:51:15 CST)
starting pid 810, tty '': '/etc/init.d/rcS'
Processing /etc/init.d/rcS......
mount all
Starting mdev......
YF2410 Rootfs(nfs)
Enjoy Linux......
starting pid 814, tty '': '/bin/sh'
Processing /etc/profile......
Set search library path in /etc/profile
Set user path in /etc/profile
Set PS1 in /etc/profile
Done
[root@/]#ls
bin      dev      home     linuxrc  proc     sbin     tmp      var
boot     etc      lib      mnt      root     sys      usr

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款