init.c replaces Bedrock Linux's shell-based init (/bedrock/strata/bedrock/sbin/init) with a minimal C + x86_64 ASM static binary. It does the same job: pivot into the chosen stratum, enable all strata, hand off to the real init, but it's ~10%* faster than Bedrock Linux's init.
Bedrock Linux's init is a shell script. At every boot it:
- Forks subprocesses for
grep,awk,sed,realpath,mount - Enables strata sequentially — one at a time, each taking several seconds
- Pipes data through chains of shell utilities
init.c replaces all of that with direct syscalls and parallel stratum enablement. The result: the slowest single stratum sets the wall clock, not the sum of all of them.
main()
├── check_pid1() → if not PID 1, exec backup immediately
├── ensure_essential_env() → mount /proc, /sys, /dev, /run
├── setup_term() → configure TTY, kill plymouth
├── print_logo() → Bedrock ASCII art
├── parse_bedrock_conf() → read [init] section from bedrock.conf
├── scan_strata() → list /bedrock/strata/*
├── run_menu() → interactive stratum/init selection
├── mount_fstab() → dmsetup, lvm, mount -a (direct syscalls)
├── pivot_root_to() → bind-mount stratum + pivot_root
├── preenable_mounts() → rbind /proc, /dev, /sys, /run
├── enable_strata_parallel() → fork ALL strata at once
│ ├── brl-repair bedrock (foreground)
│ ├── brl-repair <init> (foreground)
│ └── brl-enable <N>… (parallel — one child per stratum)
├── brl-apply → apply configuration (forked)
└── execv(<real init>) → PID 1 hands off, never returns
- Statically linked — no libc.so dependency; safe to run before ld.so is set up
- Direct syscalls —
mount(2),pivot_root(2),open(2)/read(2)for everything; nosystem(), nopopen() - Parallel enable — all strata except bedrock and the init stratum are
brl-enable'd simultaneously viafork()+waitpid(-1) - x86_64 ASM helpers —
asm_memzero,asm_strcmp,asm_write_strfor hot paths and async-signal-safe panic output - No runtime downloads — the Makefile never fetches files during install;
make install-fallbackis a separate manual step
| Tool | Purpose |
|---|---|
| gcc | C compilation |
| nasm | Assembly |
| ld | Linking (binutils) |
| static attr | Handles fs objects |
All must target x86_64 Linux. The binary is statically linked and has no runtime library dependencies.
- Bedrock Linux system with
/bedrock/strata/*strata directories /bedrock/libexec/brl-repair,/bedrock/libexec/brl-enable,/bedrock/libexec/brl-apply- Kernel with
pivot_root(2)support
makeProduces build/init (stripped, ~850KB ELF64).
sudo make installThis will:
- Back up the existing init at
/bedrock/strata/bedrock/sbin/init→.sh.bak(shell script) or.bin.bak(binary) - Copy the backup to
/sbin/initas a recovery fallback - Place the init.c binary at
/bedrock/strata/bedrock/sbin/init
If there was no existing init to back up, or you want a fresh copy of the official Bedrock init:
sudo make install-fallbackDownloads the official Bedrock Linux shell init and saves it as both the .sh.bak backup and /sbin/init.
make debugProduces build/init.debug with -g3 and AddressSanitizer (unstripped).
make checkValidates ELF type, static linking, forbidden symbols, and ASM symbol presence.
On next reboot:
- init.c starts as PID 1
- Mounts essential filesystems (/proc, /sys, /dev, /run)
- Reads
/bedrock/etc/bedrock.conffor init selection - Presents an interactive menu of available stratum/init combinations (with configurable timeout)
- Pivots root into the chosen stratum
- Enables all
show_bootstrata in parallel - Handles control to the stratum's real init via
execv()
bedrock_init=stratum:/sbin/initSkips the menu entirely.
Contributions are welcome via pull request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-change) - Make your changes
- Build and verify (
make clean && make && make check) - Commit with a descriptive message
- Open a pull request
- C11 with GNU extensions (
-std=c11 -D_GNU_SOURCE) - No
system(),popen(), or dynamic library calls - Direct
write(2)for output in signal-safe paths - Static helper functions where possible
- Follow the existing style (Allman brace style, descriptive variable names)
GPL-v3.
init.c was built and tested the most on ENux 5.3.3. If you want to use this init on other systems, be cautious as they haven't been tested yet.
All of the benchmarks, like timing, strata boot speeds and more, have been tested on a 7 strata ENux system.
- i5 12400f (12 processing units)
- 32 GB DDR5 6000 MHz CL30
- Gen 4 NVME (with read/write speeds of around 5000/3500 MBs)