GitXplorerGitXplorer
m

minimal-linux

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
70366e66d33c1ea3e582bb7e0efe72a2eb9b76e3

Add README.

mmsiedlarek committed 2 years ago
Unverified
6f429861332fd46833fe4085c239a52295f71996

Add a LICENSE, just in case.

mmsiedlarek committed 2 years ago
Unverified
d572d130b2183bc89a4375ac81e73f37f8ebdfca

Working x86_64 and aarch64 build.

mmsiedlarek committed 2 years ago
Unverified
7db1d9bd4d0f3302a89ab7e8f09d2a044a584db5

Add Alpine-based sysroots for cross-compilation.

mmsiedlarek committed 2 years ago
Unverified
8d107a608b196064beaccaca1928decc904dc177

Merge commit '5d87f67c2f12ebcc6558ef70b51a86eac83025f1' as 'src/busybox'

mmsiedlarek committed 2 years ago
Unverified
5d87f67c2f12ebcc6558ef70b51a86eac83025f1

Squashed 'src/busybox/' content from commit 382e1634972f

mmsiedlarek committed 2 years ago

README

The README file for this repository.

Minimal Linux

This is a proof-of-concept of an extremely minimalistic Linux distribution, built directly from upstream source. The distribution consists only of:

  • Linux kernel
  • musl libc
  • busybox init and userland utilities
  • LLVM compiler infrastructure, including clang, libc++ and binutils

In theory, this is just enough to have a working shell, a text editor and a compiler. You can write everything else you need yourself. :)

The distribution is cross-compiled by default and currently x86_64 and ARM64 targets are supported. Everything is statically linked for simplicity. All sources are copied into this repository from upstream, without any modifications or patches.

Building

There is no real build and packaging system. The entire build process is wrapped in a very simple, linear shell script. It is intended to be easy to understand and strip the entire process of any magic. You could theoretically just copy and paste each commands into your shell.

Dependencies

  • A C/C++ compiler toolchain (GCC or Clang)
  • ccache to make recompilation faster for huge Linux and LLVM codebases
  • QEMU and libguestfs tools to run the built distribution in a virtual machine

Toolchain

First, we build the cross-compilation toolchain based on LLVM:

./toolchain.sh

This installs the toolchain in ./toolchain, including clang, binutils and libc++ statically linked against musl. This toolchain is capable of producing binaries for all supported platforms (x86_64 and ARM64) and the host system.

Target

Next, we use the toolchain to build the actual target system. This is done with a simple script, taking the target architecture as its only argument.

./target.sh x86_64
./target.sh arm64

After the build, the complete target sysroot can be found in ./target/<architecture>. It can be used directly as a chroot environment, or serve as an actuall root filesystem booted into by a real machine.

Testing

Included script allows you to build a disk from the previously built systroot and run it using QEMU.

./run.sh x86_64
./run.sh arm64

Related projects and inspiration