This guide provides detailed instructions for installing Zinit on various platforms.
Zinit has minimal system requirements:
- Linux-based operating system
- Root access (for running as init system)
If pre-built binaries are available for your system, you can install them directly:
# Download the binary (replace with actual URL)
wget https://github.com/threefoldtech/zinit/releases/download/vX.Y.Z/zinit-x86_64-unknown-linux-musl
# Make it executable
chmod +x zinit-x86_64-unknown-linux-musl
# Move to a location in your PATH
sudo mv zinit-x86_64-unknown-linux-musl /usr/local/bin/zinit
To build Zinit from source, you'll need:
- Rust toolchain (1.46.0 or later recommended)
- musl and musl-tools packages
- GNU Make
If you don't have Rust installed, use rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
On Debian/Ubuntu:
sudo apt update
sudo apt install musl musl-tools
On Fedora:
sudo dnf install musl musl-devel
On Alpine Linux (musl is already the default libc):
apk add build-base
- Clone the repository:
git clone https://github.com/threefoldtech/zinit.git
cd zinit
- Build using make:
make
This will create a statically linked binary at target/x86_64-unknown-linux-musl/release/zinit
.
- Install the binary:
sudo cp target/x86_64-unknown-linux-musl/release/zinit /usr/local/bin/
For development or debugging:
make dev
Zinit includes a test Docker image:
# Build the Docker image
make docker
# Run the container
docker run -dt --device=/dev/kmsg:/dev/kmsg:rw zinit
To create your own Dockerfile with Zinit:
FROM alpine:latest
# Install dependencies if needed
RUN apk add --no-cache bash curl
# Copy the zinit binary
COPY zinit /usr/local/bin/zinit
RUN chmod +x /usr/local/bin/zinit
# Create configuration directory
RUN mkdir -p /etc/zinit
# Add your service configurations
COPY services/*.yaml /etc/zinit/
# Set zinit as the entrypoint
ENTRYPOINT ["/usr/local/bin/zinit", "init", "--container"]
To use Zinit as the init system (PID 1) on a Linux system:
- Install Zinit as described above
- Create your service configurations in
/etc/zinit/
- Configure your bootloader to use zinit as init
For GRUB, add init=/usr/local/bin/zinit
to the kernel command line:
# Edit GRUB configuration
sudo nano /etc/default/grub
# Add init parameter to GRUB_CMDLINE_LINUX
# Example:
# GRUB_CMDLINE_LINUX="init=/usr/local/bin/zinit"
# Update GRUB
sudo update-grub
For containers, simply set Zinit as the entrypoint:
docker run -dt --device=/dev/kmsg:/dev/kmsg:rw \
--entrypoint /usr/local/bin/zinit \
your-image init --container
After installation, you'll need to create a basic configuration:
- Create the configuration directory:
sudo mkdir -p /etc/zinit
- Create a simple service configuration:
cat << EOF | sudo tee /etc/zinit/hello.yaml
exec: "echo 'Hello from Zinit!'"
oneshot: true
EOF
- Test Zinit without running as init:
# For testing only - doesn't replace system init
sudo zinit init
If all is working correctly, you should see Zinit start and run your service.
To upgrade an existing Zinit installation:
- Stop any running Zinit instances (if not running as init)
- Download or build the new version
- Replace the existing binary:
sudo cp new-zinit /usr/local/bin/zinit
- Restart Zinit or reboot the system
If you get "permission denied" errors:
sudo chmod +x /usr/local/bin/zinit
If you encounter missing library errors when running the binary, ensure you built with musl for a statically linked binary:
# Rebuild with musl
make
If you can't connect to the Zinit socket:
# Verify the socket exists
ls -la /var/run/zinit.sock
# Check permissions
sudo chmod 755 /var/run/zinit.sock
Once installed, refer to the Quickstart Guide to begin using Zinit.