Lecture 02: Monday, 3 June 2024

  1. Today we begin to demonstrate how to build a minimal Linux Distribution

  2. To start, we will get the kernel to boot and run a stub userspace init program

  3. The minimum you need to get this to work is as follows:

    1. Set up the QEMU emulator

    2. Compile the Linux kernel for your architecture

  4. Currently the example architecture is ARM64, later in the course we are going to discuss another architectures

  5. We discuss how to set up the configuration file (.config) for kernel compilation

  6. We write a minimal program P ("call exit") in ARM64 assembly for the kernel to invoke as the init process

  7. In order to give the kernel access to program P to use as an init process, we package P in a CPIO archive.

    1. The contents of this archive will be used as the initial filesystem for the kernel
  8. We tell the QEMU to boot the kernel and pass our cpio archive as the inital RAM disk, confusingly though the initrd option

    1. The kernel panics immediately since the init process dies which is illegal

    2. To exit our init program with correct protocol for the kernel, we use the reboot(2) syscall

    3. When we invoke QEMU using a new initramfs containing the rebooting program, the kernel exits successfully

  9. Finally, we have a basic stub of a kernel and root filesystem we can build on to create a minimal Linux distribution


msg = (silence)
whoami = None
singularity v0.4 (staging) https://github.com/underground-software/singularity