Installation¶
LibreToy is shipped as a disk image: one file that contains a partition table, a bootloader and, depending on the variant, a payload. Writing that file to a USB stick is the first step; what follows differs between the two variants — both end with a stick that boots images.
| Variant | Carries | Installation |
|---|---|---|
| Full | bootloader, kernel and initrd | write the image, boot it, choose what to load |
| Minimal | bootloader only | write the image, extend it to the size of the stick, copy images |
Minimal and Full Image explains which variant to use and what the two contain.
Full Image¶
This is the variant we recommend to most users, once it has been tested and released. It carries a kernel and an initrd. The kernel starts the initrd, a small system that needs no command line. From there, the stick is prepared and you choose which further images to load over the network.
todo
The minimal image below produces a stick of the same kind, but you do the work that the initrd would do.
Minimal Image¶
The minimal image carries the bootloader and nothing else, and it is deliberately small. The rest of the stick stays unused until you add a data partition and copy images onto it.
It is the variant you get when you build LibreToy yourself, and it is meant for people who work with Nix: they decide what goes onto the stick.
A maintained script will do the steps below in one call. Until it exists, the manual way is:
Step by Step¶
The commands are written for a Linux system and a USB stick whose contents you
can lose. They assume that /dev/sdb is that stick; replace it with what the
listing below shows.
Find the device¶
lsblk lists the block devices of the system. Identify the stick by its size
and model and take the device itself — TYPE=disk, not one of the partitions
listed below it.
lsblk -o NAME,SIZE,TYPE,MODEL
# Replace /dev/sdb with the stick from the listing above.
DEVICE=/dev/sdb
Check the value once more before anything is written to it: lsblk "$DEVICE"
shows the same size and model. If it shows a disk you care about, stop here.
Get the image¶
The minimal image is built by CI. Either download it or build it yourself.
Download the stable build
The download page for the stable build is
gradient.c3d2.de.
It serves LibreToy-minimal.img.
IMG=~/Downloads/LibreToy-minimal.img
Build it from source
From a checkout of this repository. The first build compiles GRUB, so it takes a few minutes.
nix build .#image-minimal
IMG=$(ls result/LibreToy-minimal-*.img)
Both ways end with IMG pointing at the file that the next step writes.
Write the image¶
dd copies the image onto the device. image-minimal is tiny (~16 MiB), so
downloading and writing are very quick. conv=fsync keeps dd from returning
before the data has reached the stick.
sudo dd if="$IMG" of="$DEVICE" bs=4M status=progress conv=fsync
The image was built for its own size, not for your stick. Its partition table therefore ends where the image ends — somewhere in the middle of the device. The copy at the end of that table, the backup header, has to be moved to the real end of the stick:
sudo sgdisk -e "$DEVICE"
What sgdisk -e repairs
Immediately after dd, the check reports the mismatch:
$ sudo sgdisk -v "$DEVICE"
Problem: The secondary header's self-pointer indicates that it doesn't
reside at the end of the disk. If you've added a disk to a RAID array, use
the 'e' option on the experts' menu to adjust the secondary header's and
partition table's locations.
Identified 1 problems!
After sgdisk -e the same check is clean:
$ sudo sgdisk -e "$DEVICE"
The operation has completed successfully.
$ sudo sgdisk -v "$DEVICE"
No problems found. 122851261 free sectors (58.6 GiB) available in 2
segments, the largest of which is 122849247 (58.6 GiB) in size.
The numbers are from a 58.6 GiB stick; only the free space differs between sticks.
Locate the free space¶
sgdisk -p prints the partition table that came with the image.
sudo sgdisk -p "$DEVICE"
The table
$ sudo sgdisk -p "$DEVICE"
Number Start (sector) End (sector) Size Code Name
1 2048 4095 1024.0 KiB EF02 BBP
2 4096 30719 13.0 MiB EF00 ESP
The first two rows are the same on every stick, because the image defines them:
a 1 MiB BIOS boot partition (BBP) and a 13 MiB EFI system partition
(ESP, the small FAT partition that carries the bootloader). Everything behind
sector 30719 is free.
The new partition starts one sector behind the ESP. Read that sector from the table:
# Start sector = end sector of the ESP + 1
START_SECTOR=$(($(sudo sgdisk -p "$DEVICE" | awk '$6 == "EF00" { print $3 + 1 }')))
Nothing to adjust when the image changes. The same number, computed from the partition sizes instead of the table, is a cross-check that the table was read correctly:
# 1 MiB before the partitions + 1 MiB BBP + 13 MiB ESP, in 512-byte sectors
$(( (1024 + 1024 + 13 * 1024) * 1024 / 512 )) # 30720
Both print 30720 in our example. If they disagree, the ESP of the image on the stick has a different size than the one used here.
Create and format the data partition¶
Three names, then two commands. PART is the number the new partition gets,
PART_LABEL is its name in the partition table — the Name column above —
and FS_LABEL is the label of the filesystem inside it, which file managers
and lsblk -f show.
PART=3
PART_LABEL=LibreToy-VFAT
FS_LABEL=LIBRETOY
sudo sgdisk -n "${PART}:${START_SECTOR}:0" -c "${PART}:${PART_LABEL}" "$DEVICE"
sudo mkfs.vfat -n "$FS_LABEL" "${DEVICE}${PART}"
-n creates the partition from START_SECTOR to the last usable sector (0);
-c sets its name in the same call. mkfs.vfat formats it as FAT, the
filesystem that firmware and GRUB read without extra drivers.
The result
$ sudo sgdisk -p "$DEVICE"
Number Start (sector) End (sector) Size Code Name
1 2048 4095 1024.0 KiB EF02 BBP
2 4096 30719 13.0 MiB EF00 ESP
3 30720 122879966 58.6 GiB 8300 LibreToy-VFAT
$ sudo mkfs.vfat -n "$FS_LABEL" "${DEVICE}${PART}"
mkfs.fat 4.2 (2021-01-31)
The end sector is the last usable sector of the stick; the size follows from it.
If sgdisk -n fails, the backup header is probably still in the wrong place:
go back and check that sgdisk -e ended with "No problems found". If
/dev/sdb3 does not appear afterwards, sudo blockdev --rereadpt "$DEVICE"
makes the kernel re-read the table.
Copy the images¶
ISO_DIR is the directory on your machine that holds the images.
MOUNTPOINT=/mnt
ISO_DIR=~/Downloads
sudo mount "${DEVICE}${PART}" "$MOUNTPOINT"
sudo mkdir -p "${MOUNTPOINT}/iso"
sudo cp "$ISO_DIR"/*.iso "${MOUNTPOINT}/iso/"
sync
sudo umount "$MOUNTPOINT"
/iso is the recommended place for images; GRUB also finds them in the root of
the partition. /mnt is usually free — if something is already mounted there,
pick another empty directory. sync and umount make sure nothing is still in
flight when the stick is unplugged.
What is on the partition
Before umount, the directory holds the images you copied:
$ ls "$MOUNTPOINT/iso"
debian-amd64-netinst.iso nixos-minimal.iso
The stick is finished. It is an ordinary LibreToy stick now: it boots on BIOS and UEFI machines and lists the images it finds. Booting describes that menu.