Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/superfly/init-snapshot
Fly
https://github.com/superfly/init-snapshot
Last synced: 19 days ago
JSON representation
Fly
- Host: GitHub
- URL: https://github.com/superfly/init-snapshot
- Owner: superfly
- License: mit
- Created: 2021-02-17T20:32:06.000Z (almost 4 years ago)
- Default Branch: public
- Last Pushed: 2024-04-11T15:09:50.000Z (8 months ago)
- Last Synced: 2024-11-17T08:45:05.780Z (27 days ago)
- Language: Rust
- Size: 33.2 KB
- Stars: 270
- Watchers: 11
- Forks: 25
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Fly Init
This is a public snapshot of Fly's init code. It powers every Firecracker microvm we run for our users.
It is Rust-based and we thought making it public (even in this very limited fashion) could help as a reference for people making Rust-based init programs.
## Usage
Please note that our init is tailored for firecracker microvms. These instructions might not quite work and differ from what we do in production.
- Build with `cargo build --release`
- Create a device for the init
```bash
fallocate -l 64M tmpinit
mkfs.ext2 tmpinit
mkdir initmount
mount -o loop,noatime tmpinit initmount
mkdir initmount/fly
cp target/x86_64-unknown-linux-musl/release/init initmount/fly/init
cp run.json initmount/fly/run.json # more on this later
umount initmount
```
- Attach this device as /dev/vda
- Attach your rootfs as /dev/vdb
- Attach a vsock virtio device### initrd
This init should also work packaged as an initrd. However, we're not running it as such at the time of this writing.
```bash
mkdir -p tmpcpio/fly
cp target/x86_64-unknown-linux-musl/release/init tmpcpio/fly/init
cp run.json tmpcpio/fly/run.json
cd tmpcpio
ls | cpio --null --create -V --format=newc -O ../initrd.cpio
```You can then use initrd.cpio as your initrd parameter.
## `/fly/run.json`
To configure out init, we're injecting a JSON file into the root device.
You should be able to figure out the format by looking at [`lib.rs`](src/lib.rs)