A comprehensive POSIX userspace, including a C compiler, in a single tiny (<1MB) executable.
-
Bootstrappable: bootsh contains a variety of builtin commands (including
grep,diff,sed,xzcat,sha1sum,ninjaand many more) providing a solid POSIX base to bootstrap a full GNU/Linux distribution from source. -
Self-hosting: bootsh can compile itself from source, thanks to its builtin
cccommand which implements a full C99 compiler. -
Tiny: bootsh can be compiled into a single ~700KB binary executable in under 10 seconds. With UPX it can be reduced to half that size.
Just run ./configure && ninja. The configure script will prompt you for any missing build dependencies. If you don't have ninja, you can run make to bootstrap with the builtin copy of samurai.
A Docker image is provided to demonstrate how bootsh can be used in a self-contained environment.
docker run --rm -it davidar/bootshThis image contains four files:
-
/bin/sh: the bootsh executable -
/bin/init: a small shell script for constructing the root filesystem and bootstrapping musl libc from source -
/bin/configure-musl.sh: sets up an alternative ninja-based build system for musl -
/bin/awk: a C script (note the#!/bin/cc -runinterpreter line) which is JIT compiled as needed
Upon running the Docker image, it will bootstrap itself by constructing a minimal root filesystem on top of this.
Alternatively, you can build a minimal Linux distribution by running
scripts/build-docker.sh --kernelThis will produce a compressed kernel in build/bzImage and a compressed root filesystem in build/initramfs.cpio.xz (whose contents are the same as the Docker image).
Together they occupy less than 2MB. To boot the kernel in QEMU, run
scripts/run-qemu.shbootsh implements all of the mandatory POSIX commands (and a number of optional commands) except for the following:
- system administration:
at,batch,crontab,df,logger,lp,man,newgrp,ps - text/locale processing:
csplit,gencat,iconv,locale,localedef,pr,split - interactive tools:
ed,mailx,mesg,unexpand,write - terminal control:
stty,tabs,tput - miscellaneous:
bc,join,m4,pathchk,pax,tsort
bootsh is based on several MIT/BSD licensed projects:
- The Debian Almquist shell
- Command line utilities from toybox
- The MIT-relicensed parts of the Tiny C Compiler
- Version 8.0 of compiler-rt (before it was relicensed from MIT to Apache 2.0)
arfrom the Cosmopolitan project- wak, the one-file implementation of
awk - samurai, a reimplementation of Ninja
- musl libc