Chinaunix首页 | 论坛 | 博客
  • 博客访问: 560717
  • 博文数量: 107
  • 博客积分: 3079
  • 博客等级: 少校
  • 技术积分: 1306
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-08 00:03
个人简介

emmoblin.github.com

文章分类

全部博文(107)

文章存档

2012年(8)

2011年(15)

2010年(49)

2009年(9)

2008年(26)

分类:

2011-03-23 00:26:44

如何使用qemu模拟器加载built-in进initramfs文件系统的2.6.30.4内核
linux cpio initrd操作
浅析如何在android上生成我们自己的ramdisk.img启动系统文件
find . | cpio -o -H newc | gzip > ../ramdisk.cpio.gz可直接生成
luther@gliethttp:/luther/linux-2.6.30.4$ ./scripts/gen_initramfs_list.sh -o initramfs.gz -u 0 -g 0 /vobs/crosscomplie_tootls/busybox-1.14.3/_install/
1.安装qemu虚拟器
luther@gliethttp:~$ sudo apt-get install qemu
2.编译busybox
luther@gliethttp:/vobs/crosscomplie_tootls/busybox-1.14.3$ make menuconfig
选择静态编译
luther@gliethttp:/vobs/crosscomplie_tootls/busybox-1.14.3$ make;make install
将examples/bootfloppy/etc/目录拷贝到_install目录下.
最后配置如下:
luther@gliethttp:/vobs/crosscomplie_tootls/busybox-1.14.3/_install$ rm etc/profile
luther@gliethttp:/vobs/crosscomplie_tootls/busybox-1.14.3/_install$ ln -s bin/busybox init   对于initramfs来说,kernel将initramfs内容释放到rootfs,然后执行initramfs中的init启动程序,所以这里建立一个软链接,以使initramfs能够正常工作.
luther@gliethttp:/vobs/crosscomplie_tootls/busybox-1.14.3/_install$ ls
bin  dev  etc  init  proc  sbin  sys
luther@gliethttp:/vobs/crosscomplie_tootls/busybox-1.14.3/_install$ tree dev etc proc sys
dev
`-- console
etc
|-- fstab
|-- init.d
|   `-- rcS
`-- inittab
proc
sys

1 directory, 4 files

luther@gliethttp:/vobs/crosscomplie_tootls/busybox-1.14.3/_install$ vim etc/fstab
proc        /proc    proc    defaults    0    0

luther@gliethttp:/vobs/crosscomplie_tootls/busybox-1.14.3/_install$ vim etc/inittab
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
# tty2::askfirst:-/bin/sh
# ::ctrlaltdel:/bin/umount -a -r

luther@gliethttp:/vobs/crosscomplie_tootls/busybox-1.14.3/_install$ vim etc/init.d/rcS
#! /bin/sh
/bin/mount -a
/bin/mount -t sysfs sysfs /sys
/bin/mount -t tmpfs tmpfs /dev
/bin/mkdir /dev/pts
/bin/mount -t devpts devpts /dev/pts
/sbin/mdev -s # 自动动态创建开发板对应的/dev下设备
/bin/rm /init
3.编译内核
luther@gliethttp:/luther/works/linux-2.6.30.4$ make menuconfig
"General setup" ==>
  [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support  
  (/vobs/crosscomplie_tootls/busybox-1.14.3/_install) Initramfs source file(s)
luther@gliethttp:/luther/works/linux-2.6.30.4$ make
4.使用qemu虚拟器运行内核
luther@gliethttp:/luther/works/linux-2.6.30.4$ qemu-img create -f qcow pc.img 1k
luther@gliethttp:/luther/works/linux-2.6.30.4$ qemu -kernel arch/x86/boot/bzImage pc.img
也可以不用创建pc.img
luther@gliethttp:/luther/works/linux-2.6.30.4$ qemu -kernel arch/x86/boot/bzImage /dev/zero
或者
luther@gliethttp:/luther/works/linux-2.6.30.4$ qemu -kernel arch/x86/boot/bzImage /dev/null
效果图如下:

阅读(2257) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~