©2018 by Centennial Software Solutions LLC. Proudly created with Wix.com

Build the Linux Kernel and Busybox and run them on QEMU



This post is a condensed version of Mitchel Humphery's excellent post @ link. Like Mitchel's post, this post gives step-by-step instructions for building a minimal custom Linux kernel, creating a busybox based userland and booting it on an emulator (QEMU). This post just builds the allnoconfig + custom config; the smallest config.


Environment

  • T460

  • Oracle VM VirtualBox Version 5.1.30 r118389 (Qt5.6.2) running on Windows 7 SP1

  • VM's configured with 4 GB of RAM and a 64 GB disk running Ubuntu 16.04.2.

If you need help setting up this environment click here (just install 16.04.02 instead of 16.04.01).



Steps


1. Open a terminal


2. Get the required packages:

You'll see something like:


3. Create a workspace:


4. Download and extract the Linux kernel and BusyBox

You'll see something like:


5. Create a minimal userland with Busybox

You'll see something like:


6. Enable static linking in Busybox

6.1. Press enter on Busybox Settings --->


6.2. Press the down arrow 26 times until you hit [ ] Build BusyBox as a static binary (no shared libs)


6.3 Press Y


You should see:


6.4 Select Exit twice and hit Enter while the cursor is on <Yes> to save



7. Build Busybox

You should see something like:



8. Build the directory structure of the initramfs

You should see something like:



9. Create init and make it executable


9.1 Type:

9.2 Paste this in (press i)

9.3 Type :w to save, then :q to quit



10. Make init executable:


11. Create the initramfs:


12. Config the Linux kernel with the minimal config

You'll see something like:


13. Turn options on for QEMU:


14. Turn these options on:

This writes .config to $TOP/obj/linux-x86-allnoconfig


Use ls -a $TOP/obj/linux-x86-allnoconfig to check


.config is also at [link]



15. Make the kernel:

You should see something like:



16. Launch the Linux kernel binary & initrd in QEMU:

You should see something like:



17. Type Control-a x to quit QEMU

1,708 views