Linux kernel内核编译
一、安装所需前置软件
sudo apt-get install fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison
二、设置CPU架构
export ARCH=x86_64
export CROSS_COMPILE=x86_64-linux-gnu-
三、设置系统选项
make x86_64_defconfig
make menuconfig
配置选项是为了支持ramdisk根文件系统
Initial RAM filesystem and RAM disk (initramfs/initrd) support
启用EFI Stub
“Processor type and features”,并勾选"EFI stub support"(按"Y"键)
四、编译
make -j 4
编译完成后在arch/x86/boot/下生成了bzImage文件
Linux kernel编译完成
五、SATA控制器驱动
内核make menuconfig提供了SATA控制器驱动以模块形式加载
Device Drivers --->
<M>Serial ATA and Parallel ATA drivers(libata)--->
<M>Intel ESB,ICH,PIIX3,PIIX4 PATA/SATA support
<M>AHCI SAT support
[*]Enable loadable modules support --->
六、Squashfs和Overlayfs
默认 Linux 内核配置下 squahfs 是通过加载内核驱动模块实现对其支持
→ File systems
<*> Overlay filesystem support
→ File systems → Miscellaneous filesystems
<*> SquashFS 4.0 - Squashed file system support
七、编译内核模块
make modules
模块安装到自定义位置
make modules_install INSTALL_MOD_PATH=./modules
模块安装后在modules文件夹下有kernel版本对应的文件夹,将其拷贝到rootfs根目录
cp -r modules/* rootfs/
八 、编译virtio模块
Get Linux kernel with virtio drivers for the guest
Get Kernel >= 2.6.25 and activate (modules should also work, but take care of initramdisk)
CONFIG_VIRTIO_PCI=y (Virtualization -> PCI driver for virtio devices)
CONFIG_VIRTIO_BALLOON=y (Virtualization -> Virtio balloon driver)
CONFIG_VIRTIO_BLK=y (Device Drivers -> Block -> Virtio block driver)
CONFIG_VIRTIO_NET=y (Device Drivers -> Network device support -> Virtio network driver)
CONFIG_VIRTIO=y (automatically selected)
CONFIG_VIRTIO_RING=y (automatically selected)
you can safely disable SATA/SCSI and also all other nic drivers if you only use VIRTIO (disk/nic)
参考链接:
https://blog.csdn.net/zhaojia92/article/details/100717580
https://blog.51cto.com/hiyang/1767266
https://blog.csdn.net/itas109/article/details/107737843
https://blog.csdn.net/weixin_34472954/article/details/111901674
https://www.cnblogs.com/pied/articles/5775282.html
https://blog.csdn.net/qingkongyeyue/article/details/73043870?utm_source=blogxgwz6
https://www.cnblogs.com/mc-r/articles/12238345.html
https://www.cnblogs.com/klb561/p/9192630.html
https://blog.csdn.net/zengxi0302/article/details/38565349
https://blog.csdn.net/u012247418/article/details/106021793
http://blog.chinaunix.net/uid-31446765-id-5781962.html
http://www.linux-kvm.org/page/Virtio