Comments (5)
A few crates or tools that are probably useful for initramfs.
mkinitramfs command
- Man page: https://manpages.ubuntu.com/manpages/bionic/en/man8/mkinitramfs.8.html
- Source code: https://github.com/venomlinux/mkinitramfs
- Inner working
- Uses
bsdcpio
andgzip
commands to generate compressed initramfs images
- Uses
cpio-rs crate
- Reads from/writes to cpio archives
- https://github.com/jcreekmore/cpio-rs
- Pros
- No unsafe
- No 3rd-party dependencies
- Cons
- Depends on std
miniz_oxide crate
- DEFLATE/zlib encoder/decoder
- https://crates.io/crates/miniz_oxide
- Pros
- Supports no_std
- Features no unsafe
- Cons
- Don't know if this crate supports Lempel-Ziv coding (LZ77), which is used by
gzip
. - The
libflate
crate is based onminiz_oxide
and documented to support LZ77. But libflate crate is not no_std.
- Don't know if this crate supports Lempel-Ziv coding (LZ77), which is used by
from asterinas.
The Linux kernel will create a tmpfs file system, extract the contents of the archive on it, and then launch the init script located in the root of the tmpfs file system. This script then mounts the real root file system.
Here is a simple initramfs example:
#!/bin/sh
cat > hello.c << EOF
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
printf("Hello world!\n");
sleep(999999999);
}
EOF
gcc -static hello.c -o init
echo init | cpio -o -H newc | gzip > test.cpio.gz
# Testing external initramfs using the initrd loading mechanism.
qemu -kernel /boot/vmlinuz -initrd test.cpio.gz /dev/zero
The mkintramfs script:
#!/bin/sh
# Copyright 2006 Rob Landley <[email protected]> and TimeSys Corporation.
# Licensed under GPL version 2
if [ $# -ne 2 ]
then
echo "usage: mkinitramfs directory imagename.cpio.gz"
exit 1
fi
if [ -d "$1" ]
then
echo "creating $2 from $1"
(cd "$1"; find . | cpio -o -H newc | gzip) > "$2"
else
echo "First argument must be a directory"
exit 1
fi
As we can see, the format of cpio file is in newc
format." newc
is short for New portable format and CRC format.
Each file has a 110-byte header, a variable length NULL-terminated filename, and variable length file data.
A header for the filename "TRAILER!!!" indicates the end of the archive.
from asterinas.
- Implement a no_std crate to decode the newc format cpio archive.
- Use the decoded information from cpio to prepare fs in ramfs.
- investigate how to load the initramfs-image file from the
-initrd
parameter. - implement a no_std crate to unzip the gzip(.gz) file.
from asterinas.
- investigate how to load the initramfs image file from the
-initrd
parameter.
Usually, it is the bootloader's capability to load the initramfs image into memory, then pass the address and length to the kernel.
The Rust bootloader implemented the ramdisk support
in January(rust-osdev/bootloader#308), it can load the ramdisk image. So we have to upgrade the bootloader to use this feature.
from asterinas.
Done
from asterinas.
Related Issues (20)
- `make build` causes `ERROR 403: rate limit exceeded.` HOT 4
- something wrong with make run command HOT 2
- [Performance] Frequent usage of `mutex` significantly slows down performance. HOT 3
- Polling ifaces may not ensure packets be transmitted
- [RFC] Device IO dispatcher design HOT 1
- [RFC] Refactor virtual memory module
- make run fails: no suitable video mode found HOT 2
- Revisit the memory order used in the `WaitQueue`/`Waker`/`Waiter` HOT 3
- [Performance] The functions `core::ptr::copy` and `core::ptr::copy_nonoverlapping` for copying memory are slow HOT 38
- [Performance] The slowness of `trapframe` leads to a slowdown in handling syscalls.
- Missing `f_mode` in FileLike Interface Affects Multiple System Calls
- Support `#[ktest(before_all)]` for ktest framework HOT 3
- CI occationally fails when running regression test HOT 2
- CI on regression encounters an error HOT 1
- iperf3 get heap allocation error because of big backlog
- Epoll syscall tests crash occasionally
- [ERROR]: Uncaught panic! panicked at coeff.rs HOT 2
- "[ERROR]: Uncaught panic!" when running the 100-line kernel example in the asterinas book. HOT 5
- Tracking issue for publishing OSDK HOT 1
- [RFC] The basic API documentation style guideline
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asterinas.