qemu启动Busybox和内核

尝试用qemu启动busybox以及内核。方便学习内核的代码和内部的流程。

主机x86_64



linux-3.13.1.tar.gz

qemu-2.8.0.tar.xz

busybox-1.25.0.tar.bz2


1编译qemu

cd qemu-2.8.0

./configure

make -j4

sudo make install


2 编译linuxkernel

make defconfig

make

得到bzimage


3编译busybox

make menuconfig

选择静态编译

Busyboxsetting->build options->Build Busybox as a static binary

保存

make -j4


4 构建根文件系统

dd if=/dev/zero of=rootfs.img BS=1M count=10

mkdir tempmount

mkfs.ext4 -F -L linuxroot rootfs.img

sudo mount -o loop rootfs.img tempmount

进入Busybox的编译目录

sudo make install CONFIG_PREFIX=/path/to/tempmount

sudo umount tempmount



5启动整个busybox

qemu-system-x86_64  -kernel bzImage -hda rootfs.img -append "root=/dev/sda  rootfstype=ext4 init=/bin/ash"



为了能够在文件或者主机终端中看到qemu的输出。

1 qemu执行命令中需要添加 

-serial stdio 或者-serial file:/home/a.txt  将qemu串口输出到 本地终端或者文件。

2内核命令行中需要添加

console=tty console=ttyAMA0 console=ttyS0


qemu-system-x86_64  -kernel bzImage -hda rootfs.img  -serial stdio -append "root=/dev/sda console=tty console=ttyAMA0 console=ttyS0  rootfstype=ext4 init=/bin/ash"




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值