Building a ZoiOS Distro
A guide on how to bootstrap and build a ZoiOS distribution (like Parlex Linux) from scratch using Zoi.
Zoi provides a powerful set of tools to act as a "Universal Distro Engine." This allows you to construct an entire, bootable, declarative operating system (ZoiOS) from a standard Linux environment using the zoi system distro build command.
This guide walks you through bootstrapping a ZoiOS system (e.g. Parlex Linux) onto a new disk, assuming the required base packages are available in your configured Zoi registry.
Prerequisites
- A Host Linux System: You need a running Linux environment (like an Ubuntu Live USB or a Fedora host) to perform the initial installation.
- Zoi CLI Installed: The host system must have the Zoi CLI installed.
- Root Privileges: Formatting disks and installing bootloaders requires
sudo. - A Configured Registry: Your Zoi instance must be configured to sync with a registry that provides the essential ZoiOS packages (e.g.
@core/linux,@core/glibc,@core/systemd).
Step 1: Prepare the system.lua Configuration
The entire state of a ZoiOS machine is defined in a system.lua file. This file acts as the blueprint for your new distribution.
Create a file named target-system.lua:
-- target-system.lua
system({
hostname = "my-zoios-machine",
timezone = "UTC",
locale = "en_US.UTF-8",
-- Optional kernel parameters
kernel_params = "quiet splash rw",
})
-- Essential base packages required for a bootable system
packages({
"@core/linux",
"@core/glibc",
"@core/systemd",
"@core/bash",
"@core/coreutils",
"@core/filesystem",
"@core/dracut",
"@core/grub2",
"@core/btrfs-progs",
"@main/NetworkManager",
})
services({
NetworkManager = { enable = true },
sshd = { enable = true },
})
filesystems({
{
device = "LABEL=zoios_root",
mount = "/",
type = "btrfs",
options = "subvol=@root,compress=zstd:3,ssd",
},
{
device = "LABEL=zoios_boot",
mount = "/boot",
type = "ext4",
options = "defaults",
}
})Step 2: Partition the Target Disk
Before Zoi can orchestrate the installation, you must partition your target disk. ZoiOS strongly recommends Btrfs for the root filesystem to support snapshots and advanced rollback features.
Disclaimer: Replace /dev/sdX with your actual target device. Be extremely careful not to format your host machine's drive!
Use a tool like parted or fdisk to create:
- Boot Partition (e.g.
/dev/sdX1, 512MB - 1GB) - Root Partition (e.g.
/dev/sdX2, remainder of disk)
Note: You do not need to format them manually; zoi system distro build will handle formatting based on your system.lua.
Step 3: Run the Universal Distro Builder
Now, simply run the builder. This is the "One-Command" step that replaces manual formatting, mounting, and package installation.
# We mount the target partition temporarily so Zoi knows where to install
sudo mount /dev/sdX2 /mnt
# Orchestrate the entire build
sudo zoi system distro build --target /mnt --config ./target-system.luaWhat happens under the hood?
In this single step, Zoi:
- Automates Formatting: Executes
mkfs.btrfsandmkfs.ext4on your partitions. - Manages Btrfs Subvolumes: Creates
@root,@home, and@varas defined in your mount options. - Initializes Sysroot: Drops the
/etc/os-releasemarker (ID=zoios) so the disk is recognized as ZoiOS. - Bootstrap Installation: Directly installs the entire base package set (
@core/linux,@core/glibc, etc.) into the target Zoi store. - Builds the First Generation: Creates the FHS symlink farm (
/usr/bin, etc.) so the disk layout is complete.
Step 4: Finalize the Bootloader
Once the build is complete, the final step is to ensure the bootloader is installed on the target disk's master boot record (MBR) or EFI partition.
sudo chroot /mnt
grub-install /dev/sdX
grub-mkconfig -o /boot/grub/grub.cfg
exitStep 5: Reboot
Unmount the filesystems and reboot into your newly built ZoiOS system!
sudo umount -R /mnt
sudo rebootHow It Works: The ZoiOS Guard
You might wonder why you can't run zoi system apply on a standard Ubuntu or macOS host.
Zoi includes a ZoiOS Environment Guard. Commands like zoi system apply, list, and rollback check for specific OS markers (like ID=zoios or ID=parlex in /etc/os-release). If the system is not a recognized ZoiOS distribution, these commands are safely disabled to prevent accidental damage to a standard generic Linux environment.
The zoi system distro build command is explicitly allowed on generic systems so that you can bootstrap new disks, and its primary job is to establish that initial marker so the target disk becomes a valid ZoiOS environment.
2026 © All Rights Reserved.
- All the content is available under CC BY-SA 4.0, expect where otherwise stated.
- Source code is available on GitLab, licensed under Apache 2.0.
Last updated on
