boot-image allows booting HermitOS as a common monolithic kernel and
is currently just a poof of concept.
On every platform, you essentially need four things:
- the Rust toolchain via
rustup - QEMU
- mtools to create the disk image
(
apt install mtoolson Debian/Ubuntu,brew install mtoolson macOS) - a POSIX-compatible shell as well as
makeandgit
The kernel is included as the Git submodule kernel, so clone the
repository with git clone --recurse-submodules or run
git submodule update --init afterwards.
The exact nightly version is pinned in
rust-toolchain.toml and is installed
automatically the first time cargo is invoked.
By default, make builds the image for x86_64. You can select
the architecture with the environment variable ARCH. Besides x86_64,
the values aarch64 and riscv64 are supported.
make ARCH=x86_64The user-space binaries are not embedded into the boot image. Instead,
make disk.img creates a 128 MiB FAT32 image with the content of
data/<ARCH>. The kernel mounts this image at /root, and the boot
image additionally mounts its directory bin at /bin. The first process is
started from /bin, see main in src/main.rs.
make rebuilds disk.img when the binaries in data/<ARCH> or the
architecture change. The size of the image can be changed with the variable
DISK_SIZE_MB.
Boot the kernel with ARCH=x86_64 make run or use the following command:
ARCH=x86_64 make runmake run creates the disk image if necessary and starts QEMU through
cargo run. The QEMU command lines are defined as runners in
.cargo/config.toml and, for aarch64, in
qemu-aarch64.sh. The disk image is attached as a
virtio block device.
For riscv64, the runner expects the OpenSBI firmware at
/usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.bin, as provided by the
Debian/Ubuntu package opensbi. On other systems, adjust the path to -bios.
To build the binaries in data, the repository hermit-rs is used with the pull request 970.
For instance, the fork example is built with the following command:
cargo build -Zbuild-std=std,panic_abort -Zbuild-std-features=compiler-builtins-mem --target x86_64-unknown-hermit --no-default-features --features hermit/common-os,hermit/loader -p fork --releaseFor the other architectures, replace the target with aarch64-unknown-hermit or riscv64gc-unknown-hermit.
Afterwards, copy the binary from target/<target>/release/ to data/<ARCH>/bin/.
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
The kernel is being developed on hermit-os/kernel. Create your own fork, send us a pull request, and chat with us on Zulip.