Crates.io | buildfs |
lib.rs | buildfs |
version | |
source | src |
created_at | 2024-08-21 08:20:43.179108 |
updated_at | 2024-12-09 18:16:33.684387 |
description | A CI-compatible CLI utility that can create root filesystem images (for use in virtual machines) from reproducible and readable TOML build scripts |
homepage | |
repository | https://github.com/kanpov/buildfs |
max_upload_size | |
id | 1346281 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
buildfs
is an easy-to-use CLI tool meant for both manual and automated (CI) use to create raw filesystem (rootfs) images that can be used to boot virtual machines.
It has 4 subcommands: pack
and unpack
to manage packages, dry-run
to test the correctness of a package and run
to actually fully execute the package. A package can be a single TOML build script, a directory with the build script and references to other resources, or such a directory compressed in either a .tar
or a .tar.gz
.
MSRV: Rust 1.80.0.
cargo install buildfs
.mkfs
and mount/umount
), so ensure you can run sudo
on the target machine and that it is running a Linux distribution./tmp/build_script.toml
. This is a simple configuration that will make a minified bootable Debian root filesystem from the docker.io/library/debian:bookworm-slim
image:[filesystem]
type = "Ext4"
size_mib = 250
[container]
engine = "Docker"
rootful = true
wait_timeout_s = 1
image = { name = "docker.io/library/debian", tag = "bookworm-slim" }
[[commands]]
script_inline = """
#!/bin/bash
apt update
apt install -y udev systemd-sysv iputils-ping curl
rm -f /etc/systemd/system/multi-user.target.wants/systemd-resolved.service
rm -f /etc/systemd/system/dbus-org.freedesktop.resolve1.service
rm -f /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service
systemctl disable e2scrub_reap.service
rm -vf /etc/systemd/system/timers.target.wants/*
for console in ttyS0; do
mkdir "/etc/systemd/system/serial-getty@$console.service.d/"
cat <<'EOF' > "/etc/systemd/system/serial-getty@$console.service.d/override.conf"
[Service]
# systemd requires this empty ExecStart line to override
ExecStart=
ExecStart=-/sbin/agetty --autologin root -o '-p -- \\u' --keep-baud 115200,38400,9600 %I dumb
EOF
done
passwd -d root
rm -rf /usr/share/{doc,man,info,locale}
cat >> /etc/sysctl.conf <<EOF
# This avoids a SPECTRE vuln
kernel.unprivileged_bpf_disabled=1
EOF
"""
[[overlays]]
source_inline = """
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 1.1.1.1
"""
destination = "/etc/resolv.conf"
[export.directories]
include = [ "/bin", "/etc", "/home", "/lib", "/lib64", "/root", "/sbin", "/usr" ]
create = [ "/var/lib/dpkg", "/dev", "/proc", "/sys", "/run", "/tmp", "/var/lib/systemd" ]
~/.cargo/bin
is on your PATH so that buildfs
is accessible and ensure Docker is installed (Podman is also supported, just change the value of engine
in the build script and ensure a Podman Unix socket is bound).sudo buildfs run -o debian.ext4 /tmp/build_script.toml
and wait until it produces you a ready-to-use debian.ext4
root filesystem!