nuta / kerla

A new operating system kernel with Linux binary compatibility written in Rust.
Other
3.35k stars 87 forks source link
operating-system operating-system-kernel rust

Kerla

CI Discord Chat

screenshot

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.

Check out my blog post 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 root@demo.kerla.dev

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 image (Dockerfile), 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:

Building and Running the OS

See Quickstart 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

Compatibility

See here for the current status.

Contributing

Send me bug reports, feature requests, and patches on GitHub for example:

License

See LICENSE.md.

Related Work

Emulating Linux ABI is not a novel work. Some UNIX-like kernels like FreeBSD and NetBSD already have their own Linux emulation layers. Windows has a well-known feature called Windows Subsystem for Linux (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 is a unikernel which runs unmodified Linux binaries. rCore is a teaching operating system which implements the Linux ABI in Rust. Noah suggests an intriguing approach to run unmodified Linux binaries on macOS.