Minimal and Full Image¶
LibreToy is shipped in two versions: minimal and full. They differ in what the stick carries and in where the preparation happens.
Which Variant to Use¶
For almost everyone, the full image is the right choice. It is written to a stick like the image of any other distribution, with the standard tools of your operating system — no special tool, no Nix, no command line. Later it can boot any distribution you choose. It is not as small as the minimal image, but still small and quick to write. The full image is planned; until it is released, only the minimal image exists.
For advanced users, the minimal image is the right choice. It is small and leaves every step under your control. It makes sense when you build LibreToy yourself, when you need your own adjustments, or when you flash a preconfigured image onto many sticks and want the declared state to be reached while flashing.
The Minimal Image¶
The minimal image contains only the two parts: the bootloader GRUB and an empty partition for images. GRUB is started by the firmware — the first program that runs when a computer is switched on, called BIOS on older machines and UEFI on newer ones. The image has no kernel and no initrd; it is about 16 MiB.
The computer that writes the stick is the host; the computer that boots from it is the target.
flowchart LR
subgraph host[Host]
A["libretoy-flash<br/>write, grow, copy"]:::cost
end
subgraph target[Target machine]
C["image"]
end
subgraph stick[Stick]
B["GRUB"]
D["images"]
end
A -->|writes| B
A -->|writes| D
C -->|boots| B
B -->|boots| D
linkStyle 0,1 stroke-width:1px,stroke-dasharray:4 4
linkStyle 2,3 stroke-width:3px
classDef cost fill:#f8d7da,stroke:#b02a37,color:#58151c
The host prepares the stick in three steps:
- write the bootloader onto the stick,
- grow the data partition to fill the rest of the stick,
- copy the distribution images you want to boot onto that partition.
The dashed writes edges in the diagram are the host's work; the solid boots
edges happen later, when the stick is used.
The stick is complete. On the target machine, the firmware starts GRUB, and GRUB boots one of the distribution images.
The catch is the red box: everything happens on the host, and it needs
libretoy-flash. We recommend that only to Nix users and to people who want to
follow this guide step by step. In exchange the image stays small and under your
control.
The manual steps are in Installation.
The build produces LibreToy-minimal-<version>.img and the version-free
LibreToy-minimal.img.
The Full Image¶
The full image creates the same two parts, but prepares them in a different way. You write it to a stick like the image of any other distribution, with the tools your host operating system already provides — no special tool, no Nix, no command line. It is not as small as the minimal image, but still small and quick to write.
On top of these two parts comes a small addition, green in the diagram:
libretoy-live, a tiny live Linux.
flowchart LR
subgraph host[Host]
A["write the image"]
end
subgraph target[Target machine]
E["libretoy-live"]
end
subgraph stick[Stick]
B["GRUB"]
C["libretoy-live<br/>write, grow, copy"]:::gain
D["images"]
end
A -->|writes| B
A -->|writes| C
E -->|boots| B
B -->|boots| C
C -->|downloads| D
B -->|boots| D
linkStyle 0,1,4 stroke-width:1px,stroke-dasharray:4 4
linkStyle 2,3,5 stroke-width:3px
classDef gain fill:#d1e7dd,stroke:#146c43,color:#0a3622
libretoy-live is always the same, no matter which image you want to boot later.
That is why it can be built into the image once, and why preparing the stick
fits into a single step: write the image, and your part on the host is done.
The first boot starts libretoy-live instead of a distribution. It runs on the
target machine and does there what libretoy-flash did on the host in the
minimal variant:
- it grows the data partition to fill the rest of the stick,
- it downloads the images you choose and copies them onto that partition.
The next boot starts any of those images directly from the stick. For you it feels like writing any other distribution in one go; the result is what you may know from Ventoy — any distribution can be booted later. Because the tools that prepare the stick run on the stick itself, the host needs nothing but a way to write an image.
Filling the Stick Later¶
With Ventoy there is one way to fill a stick: download the images yourself and
copy them onto it. LibreToy supports that too, and more. Once the stick is
booted, libretoy-live also works as a kind of installer and updater for it: you
pick images from a selection maintained by the LibreToy maintainers, and they are
installed automatically. You do not have to download them yourself first.
That is not only easier. It also helps to verify the integrity and authenticity of the downloads, which protects against tampered images from unknown sources.
The full image is planned, not built yet. When it is built, it will produce
LibreToy-full-<version>.img and the version-free LibreToy-full.img.
How Images Are Built¶
Both variants are built by the same function, mkLibreToyImage from
src/libretoy-image. You build an image from the flake:
nix build github:LibreToy/LibreToy#image-minimal
The builder takes its arguments from the libretoy.image module: the variant and
version, the partitions and their filesystems, the bootloader configuration,
and the files that go into the partitions.
mkLibreToyImage evaluates the configuration, checks its assertions, and
produces the disk image: the GPT, the filesystems, GRUB on the EFI system
partition, and any optional partition contents.
Using the Builder in Other Projects¶
The flake exports the builder as lib.mkLibreToyImage and the modules that go
with it under modules. Add LibreToy as a flake input:
inputs.libretoy.url = "github:LibreToy/LibreToy";
libretoy.lib.mkLibreToyImage is then used the same way the LibreToy flake
itself uses it: it takes your pkgs, and the modules plus the libretoy.image
configuration are passed as a list.
A minimal image with an extra GRUB entry
{
description = "Your flake.nix using mkLibreToyImage (with an extra GRUB entry)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
libretoy.url = "github:LibreToy/LibreToy";
};
outputs = { self, nixpkgs, libretoy }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages.${system}.default =
libretoy.lib.mkLibreToyImage { inherit pkgs; } [
libretoy.modules.grubIsoMultiboot
{
libretoy.image = {
variant = "minimal";
version = "0.2.2";
partitions.ESP.size = 13 * 1024 * 1024;
bootloader.grubConfig = ''
menuentry "Hallo Welt" {
echo "Hallo Welt"
}
'';
};
}
];
};
}
The libretoy.image module itself is not in the list: mkLibreToyImage
imports it. partitions.ESP.size matches image-minimal; without it the
module default of 100 MiB applies. The GRUB entry is appended to the ones
the module generates, because grubConfig is a types.lines option.