Let's start with something very simple and useful.
Whenever you build a kernel tree, you get a kernel binary (Duh!). But you can't boot that kernel without some elbow grease first.
Because ideally you need those three together:
- Kernel image: (
initramfsfile that contains the essential drivers (
- A root disk that contains the actual userspace programs like your init process, service manager, shell, text editors, etc.
initramfs are very similar constructs, one being fixed size and the other being expendable at runtime, etc. So when in doubt, just go with
I say ideally because, for testing purposes you can compile your kernel in a way that combines the
initramfs files and root disk files in the same disk image and embed it into your kernel. Thus, you can boot your kernel directly.
This completely hinders the "separation of concerns" and makes your kernel image bigger, inflexible and error prone. So do this only when you need fast feedback on your kernel build and have plently of memory available.
Whenever you create that
rootfs monster, it will most probably be a single file like "output/images/rootfs.cpio" or "output/images/rootfs.cpio.gz" if you're using Buildroot.
You will embed the image file into your kernel image by setting its path in
CONFIG_INITRAMFS_SOURCE kernel configuration paramater.
# `.config` file in your Kernel source directory ... CONFIG_INITRAMFS_SOURCE=/home/cengiz/buildroot/output/images/rootfs.cpio.gz ...
Build your kernel again and pass your kernel image (only your kernel image is sufficient) to QEMU:
$ qemu-system-x86_64 -kernel $HOME/kernel/arch/x86_64/boot/bzImage
(I know I rushed so many stuff and you might be confused about intermediate steps. Please bear with me while I fill them later in a following post)
Want to try it out? Check out Thomas Petazzoni's excellent presentation "Rootfs made easy with Buildroot".
I will be talking about proper
initramfs creation process, in great detail in a following post.
Thank you for reading this random memory dump.