Bored? How about trying a Linux speedrun? (2020)
rachelbythebay.com
rachelbythebay.com
First person to watch a specific youtube video, which contains the password, wins.
Or maybe you're literally locked in a room, and you have to bootstrap the PC to the point where you can connect to the local network, then connect to the insecure Citrix server which is running the security software that controls the door locks. From there you can unlock the door to your cell and escape.
Only to find you're standing alone on an abandoned oil rig in the north Atlantic.
Why would that be difficult?
I owe my love of chroot to Gentoo.
The guide[1] is incredibly straightforward and easy to follow.
My arc was gentoo -> lfs -> arch Linux when I realized I didn’t want to fiddle as much.
Personally, gentoo is nice because, once you know your way, you can do a big emerge and go get a coffe while it compiles everything.
Obviously it should also install any additional apps like vim, adjust terminal colors, create and copy your ssh keys to machines needed, and configure any windows managers, etc as well from the single shell command.
Making that single shell command as small, reliable, readable, and maintainable as possible is the real challenge.
Especially if you are the kind of learner who needs to be challenged to truly ingest the material at hand, just read every word and apply what you have learned. You'll be astonished by the distance that you covered in a month!
Whenever Gentoo is brought up, somebody always brings up LFS.
LFS becomes repetitive fast. I also don't think trying to use esoteric build systems that come with cryptic readme files is newbie-friendly. Just learn to read ebuild scripts if you are after that kind of skill :)
Related: https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-... and https://guix.gnu.org/manual/en/html_node/Reduced-Binary-Seed... - AIUI, the idea is that you can bootstrap from a tiny hex program (small enough to hand-enter) and then iterate compilers up to current gcc on normal GNU/Linux.
Long story short, someone accidentally did rf -rf * in the wrong place as root, and they had to rebuild the system enough to restore from the backups, including writing an executable in machine code as hex and then converting it to binary to call the appropriate system call to effectively "mkdir /etc".
It wasn't Linux, but close enough.
But the story is the Chuck Moore, when he wrote ColorFORTH, essentially started with DOS, DEBUG, and a floppy drive.
And from this sprang forth (ahem) ColorFORTH. Essentially he hand keyed in the most minimal core necessary to start working with his own tools until he had a boot floppy. Then he tossed DOS and DEBUG and off he went.
Appreciate that the original FigForth is about 80 screens of code. And a 3.5” PC floppy can store over 1400 screens.
Chuck seems to be the kind of person that could type in a rough Forth in raw assembly and get it editable a feed on itself to get more powerful.
It’s an interesting thought experiment to be sure.
Probably the most bang-for-buck.
Was "screens" a common unit of code length back in the day? Interesting.
Take a look at the Fig Forth Installation Manual, which has the source code to Fig Forth, in Fig Forth. The source is listed as Forth screens.
http://archive.6502.org/books/forth_interest_group/fig_forth...
You can see it in action in e.g. the CollapseOS emulator[2], as it comes preloaded with ~300 blocks: try writing "0 LIST" (uppercase, as it is case-sensitive - see also [3]).
[1]: https://forth-standard.org/standard/block/
Ah, still on the net:
https://bellard.org/tcc/tccboot.html
Uses TinyCC in place of a bootloader. Of course that would require other software like a shell / BusyBox or similar besides the kernel. But after booting on-the-fly-compiled-Linux that seems like a minor issue.
Project is from 2004. Surely doing this with source code for current(ish) Linux kernels would be more involved? Especially those including Rust code. :-)
Would be fun to have a more up to date something of the above. Anyone?
https://wiki.realmofespionage.xyz/distros:fedora_workstation...
Fresh Fedora installs involve me opening Terminal, Firefox, going to that page, and copy/pasting commands. I can reproduce my set-up in less than an hour.
https://wiki.debian.org/DebianInstaller/Preseed
Quite different than bootstrapping a system as described in the OP, but relevant in the context of your comment.
Mostly sets up repos, installs packages, does some basic configuration. But also calls a bash script that sets up KDE/Gnome, down to the launcher icons, widgets, themes, a wallpaper, and application settings.
Basically "cattle not pets" approach to workstations and laptops.
The only thing I struggle with are Firefox extensions. The last time I checked automating them was such a drag. Surprised there's nothing like apt or dnf for them.
https://pyinfra.com/ https://stackoverflow.com/questions/37728865/install-webexte...
I'd been working on the system bootstrap and verified execution chain, and often had to cobble stuff together in our shell. The shell on Fuchsia is a bit weird though (also my doing, largely), we'd avoid installing most software, and instead most of the programs in the shell are little stubs containing e.g. `#!resolve fuchsia-pkg://fuchsia.com/vim#bin/vim`. If you have bricked your update system you can't run those programs, as you can't resolve an up to date and safe version of vim. What was there though, was always a very small number of utilities from sbase. If you were to pick between sbase, toybox, busybox and so on, I'm not necessarily sure you'd pick sbase, but for Fuchsia it was definitely one of the easier to port for a variety of reasons.
So you have basically a hexdump tool, cat, and a hacked up version of dash as a shell (a POSIX shell, essentially, on a system without fork, ttys, signals or sessions, so it worked a little differently). A similar set of constraints to this article.
I sent them an email which looked something like: run lsblk on target and capture the output. mount the efi device to /mnt, assuming it's good that's fine. copy files using the pattern "cat file | ssh target 'cat - > target-path'". Copy the following files in build-name:target-path form: zircon.bin:/mnt/zircon.bin bootx64.efi:/mnt/EFI/BOOT/bootx64.efi ramdisk.bin:/mnt/ramdisk.bin. umount /mnt. On target do 'for i in {1..4096}; do echo -n a > /dev/{path-to-minfs}; done`, the system will crash and reboot shortly after, and should boot into your new ramdisk.
At the time there was a bug that'd trigger the final reboot when a mounted but broken partition had its magic header overwritten. A couple of months later I made this way harder to recover from, but we also added an A/B/R partition scheme so that there was essentially always a recovery strategy even if you send really broken software.
If you're on a Linux system though, I think some of this gets in some ways easier. There's some ABI junk to deal with, but you can get really far with disgusting behavior in a posix shell that has a tty and signals, as you can write a bunch of not very feature complete, but very functional programs quickly in shell. A quick editor - probably 20 lines or so, and each time you make it better it gets easier to be better. Already got some read/write loop going on in that editor, great, plain text http isn't far off.
This is all a bit of an interesting set of trivialities though, not to discount the idea. DNS is a good example as in the article, but if you have no DNS tools you are missing ip(1) and friends, and you need to go implement netlink first - otherwise having a DNS client doesn't matter, you don't have configured network interfaces! If you have ip(1) then you likely also have ss(1) and you can trick the latter into acting as a dns client. If you have to hand roll netlink without headers, a compiler and a linker though, that's not really a from-memory job there, and the netlink part is far worse than the DNS part really. If you're on a systemd system, and all you have is systemd a shell and ip tools, you're basically completely set from the get-go, as you can jump straight to `machinectl pull-tar` and you're off to the races.
Of course if you're on an EFI system that hasn't trimmed down much from the reference tianocore build, then you can probably reboot into an efi shell and get network configuration and pull an image from there, which is likely easier than escalating from a zero compiler zero network environment against the linux abi.
Fun idea, I'm just not totally sure how to put a good modern bound around "minimal linux system".
It feels like a CTF, but kind of in reverse. Following that theme perhaps it should be "escape the pot", modelling the stripped down system as a honeypot.
Editing text. Construct an ed-like editor in shell - the first character/token of each input line is a command. You could use awk or shell for this.
Creating binary files. If you have gnu coreutils, it has a powerful echo option to output bytes. If you have posix/busybox/toybox, use od(1), head and tail to extract a library of 1-byte files from existing binaries. Cat these together to create multibyte binaries.
Assembler and linker. You don't need to use conventional notation. Create an assembly syntax around the same first-token-is-command approach used for the text editor. Implement an assembler that reads that notation and outputs binary. You would need to create elf headers. You would need to map system calls.
Previous discussion: https://news.ycombinator.com/item?id=22846250
> copying files over FTP, and SSH'd into my router from it.
Did you add a network card or connect through another machine with serial/ppp/uucp?
I'd like to see something like this, but with hardware included - something like Junkyard Wars, but with random computer hardware - which then people need to get going to be able to do specific functional things.
> Linux "distro" that only includes a Lua interpreter and a Lua library to issue syscalls
So basically an Arch or Gentoo install speedrun. I'm pretty sure I've already seen those on Youtube.
Try you only have a single bootloader and a little bit of source code and building all the way up to a complete linux distro
https://github.com/fosslinux/live-bootstrap
(checkout the builder-hex0/fiwix work)
> I mean speedrunning the Linux situation itself.
I think “the Linux situation” is an amazing choice of words. It truly covers it all, doesn’t it?