-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* new User Guide section * compile-kernel page * build-initramfs page Signed-off-by: RedbeanGit <dubois.julien.mail@gmail.com>
- Loading branch information
1 parent
eff12b4
commit 89481d6
Showing
8 changed files
with
196 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ node_modules/ | |
.next/ | ||
package.json | ||
package-lock.json | ||
pnpm-lock.yaml | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"compiling-linux-kernel": "Compiling Linux Kernel", | ||
"building-initramfs": "Building initramfs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
--- | ||
title: Building initramfs | ||
description: A guide on how to build initramfs for Lambdo. | ||
--- | ||
|
||
import Image from 'next/image'; | ||
import Link from 'next/link'; | ||
import { Callout } from 'nextra/components'; | ||
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 built 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 | ||
``` | ||
|
||
<Callout type="warning"> | ||
Your init script **must** have execution rights. | ||
</Callout> | ||
|
||
<Callout type="warning"> | ||
Your init script **must** start agent process to work with Lambdo. | ||
</Callout> | ||
|
||
## 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 | ||
# Leave empty if you want to use default Lambdo API. | ||
grpc: | ||
remote_port: 50051 | ||
remote_host: 127.0.0.1 | ||
local_port: 0 | ||
local_host: 0.0.0.0 | ||
``` | ||
## 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`.** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
title: Compiling Linux kernel | ||
description: A guide to compile the Linux kernel. | ||
--- | ||
|
||
# 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 curl tar | ||
``` | ||
|
||
### Fedora / RHEL / CentOS | ||
|
||
```bash copy filename="bash" | ||
sudo dnf install git gcc make xz bc flex bison diffutils curl tar | ||
``` | ||
|
||
### Arch Linux | ||
|
||
```bash copy filename="bash" | ||
sudo pacman -Syu git gcc make xz bc flex bison diffutils curl tar | ||
``` | ||
|
||
## Build the kernel | ||
|
||
Download and extract the kernel source: | ||
|
||
```bash copy filename="bash" | ||
curl -L https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.5.9.tar.xz --output linux.tar.xz | ||
tar xf linux.tar.xz | ||
``` | ||
|
||
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`** |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.