Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nuta/kerla
A new operating system kernel with Linux binary compatibility written in Rust.
https://github.com/nuta/kerla
operating-system operating-system-kernel rust
Last synced: 30 days ago
JSON representation
A new operating system kernel with Linux binary compatibility written in Rust.
- Host: GitHub
- URL: https://github.com/nuta/kerla
- Owner: nuta
- License: other
- Created: 2021-05-18T12:32:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-28T11:10:43.000Z (about 2 months ago)
- Last Synced: 2024-10-01T17:43:25.508Z (about 1 month ago)
- Topics: operating-system, operating-system-kernel, rust
- Language: Rust
- Homepage:
- Size: 2.5 MB
- Stars: 3,338
- Watchers: 40
- Forks: 89
- Open Issues: 29
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Kerla
[![CI](https://github.com/nuta/kerla/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/nuta/kerla/actions/workflows/ci.yml)
[![Discord Chat](https://img.shields.io/discord/904705655095582752?logo=discord&style=social)](https://discord.gg/6Pu4ujpp6h)![screenshot](screenshot.png)
Kerla is a monolithic operating system kernel written from scratch in Rust which aims to be
compatible with the Linux ABI, that is, it runs Linux binaries without any modifications.- Implements *NIX process concepts: context switching, signals, `fork(2)`, `execve(2)`, `wait4(2)`, etc.
- Supports commonly used system calls like `write(2)`, `stat(2)`, `mmap(2)`, `pipe(2)`, `poll(2)`, ...
- No disk support for now: initramfs is mounted as the root file system.
- Pseudo file systems: tmpfs and devfs.
- [smoltcp](https://github.com/smoltcp-rs/smoltcp)-based TCP/IP support.
- Implements tty and pseudo terminal (pty).
- Supports QEMU and Firecracker (with virtio-net device driver).
- Supports x86_64.
- Docker-based initramfs build system.***Check out [my blog post](https://seiya.me/writing-linux-clone-in-rust) for motivation and my thoughts on writing an OS kernel in Rust.***
## Demo: SSH into Kerla!
You can play with Kerla over ssh. Your login is not visible from others (except
me): we automatically launch a dedicated microVM on Firecracker for each TCP
connection.```
$ ssh [email protected]
```If you found bugs or missing features, let me know on GitHub issues :)
## Running a Docker Image (experimental)
You can run a Docker image as a root file system (not as a container!) on Kerla Kernel instead of our initramfs built from `initramfs` directory.
For example, to run [nuta/helloworld](https://hub.docker.com/r/nuta/helloworld) image ([Dockerfile](https://gist.github.com/nuta/4c9ecd0d1a401dc5be88095bea5a991a)), try the following command:
```
$ make IMAGE=nuta/helloworld run
...
[ 0.029] syscall: execve(439398, 4393b8, 4393c8, 8, 2f2f2f2f2f2f2f2f, 8080808080808080)
[ 0.030] syscall: arch_prctl(1002, 4055d8, 0, 20000, 0, ff)
[ 0.031] syscall: set_tid_address(4057f0, 4055d8, 0, 20000, 0, ff)
[ 0.033] syscall: ioctl(1, 5413, 9ffffeed0, 1, 405040, 9ffffeef7)_ _ _ _ _ _
| |__ ___| | | ___ __ _____ _ __| | __| | |
| '_ \ / _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | |
| | | | __/ | | (_) | \ V V / (_) | | | | (_| |_|
|_| |_|\___|_|_|\___/ \_/\_/ \___/|_| |_|\__,_(_)
```This feature is in a very early stage and I guess **almost all images out there won't work** because:
- They tend to be too large to be embedded into the kernel image.
- They might use unimplemented features (e.g. position-independent executables used in Alpine Linux).## Building and Running the OS
See [Quickstart](https://kerla.dev/docs/quickstart.html) for instructions on building from source, running on emulators, etc.
## Current Roadmap
[Roadmap - Run a Node.js Web Application on Kerla on Firecracker on AWS](https://github.com/nuta/kerla/projects/1)## Compatibility
See [here](https://github.com/nuta/kerla/blob/main/Documentation/compatibility.md) for the current status.
## Contributing
Send me bug reports, feature requests, and patches on [GitHub](https://github.com/nuta/kerla) for example:
- **Implementing missing features:** majority of existing Linux applications won't work due to the lack of features.
- **Writing documentation:** I think Kerla could be good material to learn how an operating system kernel works.
- **Trying to experiment with Rust-y ideas:** for example currently I'm interested in [GhostCell](http://plv.mpi-sws.org/rustbelt/ghostcell/).## License
See [LICENSE.md](https://github.com/nuta/kerla/blob/main/LICENSE.md).
## Related Work
Emulating Linux ABI is not a novel work. Some UNIX-like kernels like [FreeBSD](https://docs.freebsd.org/en_US.ISO8859-1/articles/linux-emulation/article.html) and [NetBSD](https://www.netbsd.org/docs/guide/en/chap-linux.html) already have their own Linux emulation layers. Windows has a well-known feature called [Windows Subsystem for Linux (WSL)](https://github.com/microsoft/WSL) which enables running Linux binaries seamlessly. WSL 1 implements the feature by ABI emulation. WSL 2 runs the real Linux kernel using the hardware-accelerated virtualization (Hyper-V).
Aside from general-purpose operating systems, there're some attractive projects related to the Linux ABI emualtion. [OSv](https://github.com/cloudius-systems/osv/wiki/OSv-Linux-ABI-Compatibility) is a unikernel which runs unmodified Linux binaries. [rCore](https://github.com/rcore-os/rCore) is a teaching operating system which implements the Linux ABI in Rust. [Noah](https://dl.acm.org/doi/10.1145/3381052.3381327) suggests an intriguing approach to run unmodified Linux binaries on macOS.