Skip to content

Commit

Permalink
feat: create user guide section
Browse files Browse the repository at this point in the history
* new User Guide section
* compile-kernel page
* build-initramfs page

Signed-off-by: RedbeanGit <dubois.julien.mail@gmail.com>
  • Loading branch information
RedbeanGit committed Oct 24, 2023
1 parent 5c68e25 commit 097daff
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@ianvs/prettier-plugin-sort-imports": "4.1.0",
"@next/eslint-plugin-next": "13.5.4",
"@types/node": "18.11.10",
"@types/react": "^18.2.31",
"@typescript-eslint/eslint-plugin": "6.7.4",
"@typescript-eslint/parser": "6.7.4",
"autoprefixer": "^10.4.16",
Expand Down
8 changes: 3 additions & 5 deletions pages/docs/_meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"-- Getting Started --": {
"type": "separator",
"title": "Getting Started"
},
"index": "Introduction"
"index": "Introduction",
"getting-started": "Getting Started",
"user-guide": "User Guide"
}
1 change: 1 addition & 0 deletions pages/docs/getting-started/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions pages/docs/user-guide/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"compile-kernel": "Compiling the Kernel",
"build-initramfs": "Build initramfs"
}
115 changes: 115 additions & 0 deletions pages/docs/user-guide/build-initramfs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import Image from 'next/image';
import Link from 'next/link';
import InitramfsComponentsImage from '../../../public/images/schemas/initramfs-components.png';

# Building initramfs

Requirements:

- [Rust toolchain](https://www.rust-lang.org/fr/learn/get-started)

## Introduction

Lambdo uses custom initramfs builded from Docker images. You can build it by
yourself or use prebuilt one.

## Lambdo initramfs structure

Lambdo initramfs contains at least 3 components:

- **init** - init process which starts all other processes.
- **agent** - agent process which is responsible for communication with Lambdo
API.
- **config.yaml** - configuration file which contains all necessary
configuration for Lambdo agent (see
[Configuration documentation](/docs/reference/configuration)).

<div className="col-span-2 flex items-center justify-center py-2">
<Image
src={InitramfsComponentsImage}
alt="Initramfs components"
width={500}
height={500}
/>
</div>

## Preparation

Create an empty directory for initramfs:

```bash copy
mkdir initramfs
```

Clone `lambdo` repository:

```bash copy
git clone https://github.com/faast-rt/lambdo.git
```

## Build Lambdo agent

Build Lambdo agent and move it to initramfs directory:

```bash copy
cd lambdo/agent
cargo build --release
cd ../..
mv lambdo/target/release/agent initramfs
```

## Write init script

You can write your own script or use example one (must be named `init`):

```bash copy filename="initramfs/init"
#! /bin/sh
mount -t devtmpfs dev /dev
mount -t proc proc /proc
mount -t sysfs sysfs /sys
ip link set up dev lo

exec /agent --config /config.yaml

exit
poweroff -f
```

> **Note 1:** Your init script must be executable.
> **Note 2:** Your init script must start agent process.
## Write configuration file

You can write your own configuration file or use example one (must be named
`config.yaml`):

```yaml copy filename="initramfs/config.yaml"
apiVersion: lambdo.io/v1alpha1
kind: AgentConfig
serial:
path: /dev/pts/6
baudRate: 9600
```
## Build initramfs by yourself
Build initramfs tool and move it to initramfs directory:
```bash copy
cd lambdo/initramfs
cargo build --release
cd ../..
mv lambdo/target/release/initramfs initramfs
```

Run initramfs tool (replace `node:20-alpine` with the image of the language you
want):

```bash copy
cd initramfs
./initramfs --image node:20-alpine
```

**The image built here is stored at
`initramfs/initramfs-library-node-20-alpine.img`.**
49 changes: 49 additions & 0 deletions pages/docs/user-guide/compile-kernel.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Compiling Linux kernel

Lambdo uses a Linux kernel compiled from source. This is a guide to compile the
kernel.

## Install dependencies

#### Debian/Ubuntu

```bash copy filename="bash"
sudo apt update
sudo apt install git build-essential bc flex bison
```

#### Fedora/RHEL/CentOS

```bash copy filename="bash"
sudo dnf install git gcc make xz bc flex bison diffutils
```

#### Arch Linux

```bash copy filename="bash"
sudo pacman -Syu
sudo pacman -S git gcc make xz bc flex bison diffutils
```

## Build the kernel

Clone the Linux kernel official repository:

```bash copy filename="bash"
git clone https://github.com/torvalds/linux.git
```

Generate the default configuration:

```bash copy filename="bash"
cd linux
sudo make tinyconfig
```

Compile the kernel:

```bash copy filename="bash"
KCFLAGS="-Wa,-mx86-used-note=no" sudo make bzImage -j `nproc`
```

**The image is located at `arch/x86/boot/compressed/vmlinux.bin`**
13 changes: 6 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/images/schemas/initramfs-components.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 097daff

Please sign in to comment.