Ubuntu14.04 Linux x86_64 Kernel Compiler

来源:互联网 发布:水果软件虚拟键盘 编辑:程序博客网 时间:2024/06/05 07:29

0x01 Kernel 3.9.9 Compiler

git tag 详细版本

git checkout 版本号

git branch -a 在哪一个分支上

make menuconfig 在kernel hacking中选中compile the kernel with debug info

make bzImage 编译内核

0x02 QEMU debug Kernel

qemu-system-x86_64 -s -S -kernel bzImage -nographic 会出现内核pannic

[ 3.711331] VFS: Cannot open root device “(null)” or unknown-block(0,0): error -6 [ 3.730405] Please append a correct “root=” boot option; here are the available partitions:
原因:缺少根设备

下载busy

make O=../obj/busybox/ menuconfig
然后最重要的是静态连接:
Busybox Setting:
>Build Option
>>Build Busybox as a static bina
make
make install

创建根文件夹,将_install复制到ramdisk中

mkdir ramdisk
cd ramdisk
cp -av /obusybox/_install/ .

初程化进程

ln -s bin/busybox init

设置开机程序

mkdir -pv {bin,sbin,etc,proc,sys,usr/{bin,sbin},dev}

vim etc/inittab

::sysinit:/etc/init.d/rcS::askfirst:-/bin/sh::restart:/sbin/init::ctrlaltdel:/sbin/reboot::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a

编写系统初始化命令

mkdir etc/init.d/rcS
vim rcS
#!/bin/shmount procmount -o remount,rw /mount -aclear                               echo "opoi Start :D ......"
chmod +x rcS

设置自动挂载的文件

cd ramdisk/etc/
vim fstab
# /etc/fstabproc            /proc        proc    defaults          0       0sysfs           /sys         sysfs   defaults          0       0devtmpfs        /dev         devtmpfs  defaults          0       0

压缩镜像

cd ramdisk
find . -print0 | cpio –null -ov –format=newc | gzip -9 > my-linux/obj/initramfs.cpio.gz

运行

cd obj/
qemu-system-x86_64 -kernel bzImage -initrd initramfs.cpio.gz
无形界面
qemu-system-x86_64 -kernel bzImage -initrd initramfs.cpio.gz -append “console=ttyS0” -nographic
原创粉丝点击