• 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,使用刚编译的内核初始化系统。查看启动过程,看是否存在异常。如一切正常,则表明内核编译正确,反之则须要继续改动编译选项。

  • 相关阅读:
    js实现弹窗后选择信息填入text标签中以及需要注意的问题
    JDBC链接mysql之后出现read-only
    面试题之心理测试题及答案
    互联网经济思维故事
    模板
    工具包、类
    开源项目
    项目开发工具
    Java API 常用 详解
    spring文章
  • 原文地址:https://www.cnblogs.com/blfbuaa/p/7072745.html
Copyright © 2020-2023  润新知