Rust-based init process for omnect-os initramfs.
Replaces 14 bash-based initramfs scripts (~1500 LOC) with a single Rust binary
acting as /init in the initramfs. Runs as PID 1 before switch_root.
Implemented functionality:
- Bootloader abstraction: Unified
Bootloadertrait for GRUB (grub-editenv) and U-Boot (fw_printenv/fw_setenv); fsck output persisted across reboots as gzip+base64 in the bootloader env (encoded via busyboxgzip/base64— no crate dependencies) - Configuration: Parses
/proc/cmdline; build-time constants from Yocto environment viabuild.rs - Partition management: Root device detection, partition layout (GPT/DOS),
/dev/omnect/*symlinks - Filesystem operations: fsck, mount manager (RAII), overlayfs for
/etcand/home, bind mounts - Logging: Kernel ring buffer (
/dev/kmsg) with log level prefixes - ODS integration: Runtime files for
omnect-device-service - fs-links: Symlink creation from
etc/omnect/fs-link.jsonandetc/omnect/fs-link.d/ - switch_root: MS_MOVE + chroot + exec systemd (
pivot_root(2)is not used; ramfs does not support it)
Not yet implemented (planned):
- Factory reset (backup, wipe, restore)
- Flash modes (disk clone, network, HTTP/HTTPS)
- Data partition auto-resize
# Debug build (bootloader type must be specified)
cargo build --features grub # x86-64 EFI targets
cargo build --features uboot # ARM targets
# Release build (optimized for size)
cargo build --release --features grub
cargo build --release --features uboot
# With additional optional features
cargo build --release --features "grub,persistent-var-log"| Feature | Description | Status |
|---|---|---|
core |
Core boot sequence (default) | Implemented |
grub |
GRUB bootloader support — x86-64 EFI targets | Implemented |
uboot |
U-Boot bootloader support — ARM targets | Implemented |
gpt |
GPT partition table layout | Implemented |
dos |
DOS/MBR partition table layout | Implemented |
persistent-var-log |
Bind-mount /var/log to data partition |
Implemented |
release-image |
Release error handling (loop on fatal error) | Implemented |
factory-reset |
Factory reset support | Planned |
flash-mode-1 |
Disk cloning | Planned |
flash-mode-2 |
Network flashing | Planned |
flash-mode-3 |
HTTP/HTTPS flashing | Planned |
resize-data |
Data partition auto-resize | Planned |
Note:
grubandubootare mutually exclusive. Exactly one must be set at build time. The Yocto recipe selects the correct feature viaCARGO_FEATURESbased onMACHINE_FEATURES.
# All four valid feature combinations (bootloader × partition table)
cargo test --features grub,gpt # x86-64 targets, GPT
cargo test --features grub,dos # x86-64 targets, DOS/MBR
cargo test --features uboot,gpt # ARM targets, GPT
cargo test --features uboot,dos # ARM targets, DOS/MBR
# Verbose output
cargo test --features grub,gpt -- --nocaptureMIT OR Apache-2.0