|
| 1 | +# folk-live-build |
| 2 | + |
| 3 | +Builds a bootable Folk OS image. |
| 4 | + |
| 5 | +To run Folk on a PC, [download the latest pre-built Folk image for USB |
| 6 | +stick from the Releases |
| 7 | +page.](https://github.com/FolkComputer/folk-live-build/releases) |
| 8 | +Follow the instructions there. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +Below are details on how the Folk OS image is constructed; **you don't |
| 13 | +need to worry about any of the below if you're just trying to install |
| 14 | +Folk.** |
| 15 | + |
| 16 | +## Key files |
| 17 | + |
| 18 | +- `folk-live/`: becomes writable partition on disk, including Folk repo |
| 19 | +- `config/package-lists/folk.list.chroot`: apt packages |
| 20 | +- `config/hooks/normal/9999-setup-folk.hook.chroot`: executed in |
| 21 | + `/` chroot at image construction time |
| 22 | +- `config/includes.chroot_after_packages/`: copied into `/` at boot |
| 23 | +- `config/includes.chroot_after_packages/lib/live/config/9999-folk`: |
| 24 | + executed at boot |
| 25 | + |
| 26 | +## How to build folk-amd64.img from scratch |
| 27 | + |
| 28 | +You need to build on a computer running amd64 Debian Bookworm. (Use a |
| 29 | +virtual machine if you need to. A Folk system built by folk-live-build |
| 30 | +itself should work, though, whether on a virtual or physical machine.) |
| 31 | + |
| 32 | +In this live-build/ subdirectory of the Folk repo: |
| 33 | + |
| 34 | +``` |
| 35 | +# apt install live-build parted dosfstools zip |
| 36 | +$ git submodule update --init |
| 37 | +$ make -C config/includes.chroot_after_packages/home/folk/apriltag libapriltag.a libapriltag.so |
| 38 | +$ make |
| 39 | +``` |
| 40 | + |
| 41 | +emits `folk-amd64.img`. |
| 42 | + |
| 43 | +(It runs from scratch each time -- can take 30 minutes or more.) |
| 44 | + |
| 45 | +## How it works |
| 46 | + |
| 47 | +Image (-> USB drive) contains Master Boot Record with: |
| 48 | + |
| 49 | +1. 'Binary' ext4 partition (~1.3GB) |
| 50 | + - Contains a bunch of stuff (?), including the SquashFS file of |
| 51 | + the chroot filesystem, which ultimately maps to / in the |
| 52 | + running system |
| 53 | + - Could be fat32 or iso9660 I think but ext4 is reliable |
| 54 | + |
| 55 | +2. EFI system partition (100MB) |
| 56 | + - syslinux-efi bootloader |
| 57 | + - Linux kernel image (annoying if you update kernel but this is a |
| 58 | + sealed live USB so that shouldn't be an issue) |
| 59 | + |
| 60 | +3. Writable FAT32 partition (~500MB) |
| 61 | + - Contains /folk with Folk evaluator code and virtual programs, |
| 62 | + /folk-printed-programs, etc. |
| 63 | + - Contains setup.folk which you can edit to set runtime settings |
| 64 | + (Wi-Fi credentials) |
| 65 | + - Designed to automount on all operating systems when the USB is |
| 66 | + plugged in, to make it easy to configure Wi-Fi and other stuff |
| 67 | + before boot |
| 68 | + |
| 69 | +Cannot have FAT32 partition be same as efi partition (and use iso |
| 70 | +loopback) because macOS (and probably other OSes?) won't automount an |
| 71 | +efi partition. |
| 72 | + |
| 73 | +#### Build process |
| 74 | + |
| 75 | +The build process uses Debian live-build to build a live image, then |
| 76 | +appends EFI system partition (to make it bootable on UEFI machines) |
| 77 | +and a writable partition (to make it easy for end-user to set config |
| 78 | +settings and update Folk). |
| 79 | + |
| 80 | +(live-build can make a complete bootable disk image on its own, but |
| 81 | +only in iso-hybrid mode, which doesn't let you modify the partition |
| 82 | +table to add the writable partition, so we instead use hdd mode and |
| 83 | +modify the partition table ourselves.) |
| 84 | + |
| 85 | +1. Run live-build, emit a disk image (with MBR with only a binary |
| 86 | + partition. not bootable on many modern systems) |
| 87 | + |
| 88 | +2. Use parted to mutate the disk image to add EFI system partition |
| 89 | + |
| 90 | +3. Copy syslinux-efi bootloader and bootloader config and Linux kernel |
| 91 | + etc onto EFI system partition |
| 92 | + |
| 93 | +4. Use parted to mutate the disk image to add the writable FAT32 partition |
| 94 | + |
| 95 | +## References |
| 96 | + |
| 97 | +- <https://ianlecorbeau.github.io/blog/debian-live-build.html> |
| 98 | +- <https://manpages.debian.org/testing/live-build/lb_config.1.en.html> |
| 99 | +- <https://live-team.pages.debian.net/live-manual/html/live-manual/index.en.html> |
| 100 | + |
| 101 | +## License |
| 102 | + |
| 103 | +Apache 2.0 |
| 104 | + |
| 105 | +## TODO |
| 106 | + |
| 107 | +- ~~Replace "NO NAME" title of FAT32 writable partition with Folk name~~ |
| 108 | +- Test MBR+EFI on various systems (BIOS, UEFI, Chromebook, Beelink, |
| 109 | + NUC, UTM) |
| 110 | +- ~~Make fstab automount the writable partition (how do we know it's |
| 111 | + /dev/sdb2?)~~ |
| 112 | +- ~~Put Wi-Fi config on writable partition~~ |
| 113 | +- Allow setting display and webcam from setup.folk |
| 114 | +- Figure out disk installation process |
| 115 | +- ~~Handle printed programs~~, ~~calibration (make folk prefix that goes to folk-live?)~~ |
| 116 | + |
0 commit comments