linux编译之后怎么测试,Linux内核编译测试方法

Step 1:配置内核编译选项。

make menuconfig

Optional Step :排除编译结果文件(.o)等之间的依赖性。

make mrproper

Optional Step:清除历史编译结果。

make clean

Step 2:编译内核。

make bzImage #编译内核

make modules #编译各内核模块,如驱动等。

make modules_install #将编译好的模块安装至 /lib/modules/x.xx.x 目录下。

Step 3:生成初始盘镜像 initrd.img。

cd linux-source-x.xx.x/.config #复制配置文件至/boot目录

sudo cp .config /boot/config-x.xx.x

#x.xx.x 对应 /lib/modules/x.xx.x 目录。

# -o 指示了镜像的输出目录。

sudo mkinitramfs -o /boot/initrd.img-x.xx.x x.xx.x

Step 4:修改Grub配置。

在/boot/grub/grub.cfg中复制一段已有的启动项条目,将其中的内核相关文件地址修改至新内核相关文件所在位置。

如:

复制下段:

menuentry'Ubuntu,Linux 3.2.0-36-generic-pae' --class ubuntu --class gnu-linux --class gnu --class os {

recordfail

gfxmode $linux_gfx_mode

insmod gzio

insmod part_msdos

insmod ext2

set root='(hd0,msdos1)'

search --no-floppy --fs-uuid --set=root 7b4e922c-d943-4b84-9c75-4fdc57cf1a3f

linux /boot/vmlinuz-3.2.0-36-generic-pae root=UUID=7b4e922c-d943-4b84-9c75-4fdc57cf1a3f ro quiet splash $vt_handoff

initrd /boot/initrd.img-3.2.0-36-generic-pae

}

修改为:

menuentry 'Test,Linux 3.7.4' --class ubuntu --class gnu-linux --class gnu --class os {

recordfail

gfxmode $linux_gfx_mode

insmod gzio

insmod part_msdos

insmod ext2

set root='(hd0,msdos1)'

search --no-floppy --fs-uuid --set=root 7b4e922c-d943-4b84-9c75-4fdc57cf1a3f

linux /boot/core/vmlinuz-3.7.4root=UUID=7b4e922c-d943-4b84-9c75-4fdc57cf1a3f ro quiet splash $vt_handoff

initrd /boot/core/initrd.img-3.7.4

}

Step 5:测试

在虚拟机启动时按Esc,强制进入Grub启动菜单。

在菜单中选择’Test,Linux 3.7.4,使用刚编译的内核初始化系统,查看启动过程,看是否存在异常,如一切正常,则表明内核编译正确,反之则需要继续修改编译选项。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值