u-root is a set of about 180 unix commands (and some plan9-only commands) written in Go.
It uses a tool called the gobusybox, which does a source-source transformation of a set of Go prgorams, turning each command into a package, then compiles them all into a single command. A tool called mkuimage packages that single binary and, on Plan 9, creates a set of #! files, into a cpiofs in newc-format. Since a recent change on 9front, you can mount newc files with cpiofs. So to get, e.g., find, you can do this: #!/bin/rc u-root '-defaultsh=' '-initcmd=' '-shellbang=true' fs/cpiofs /tmp/initram*cpio bind -a /n/tapefs / bind -a /bbin /bin and in /bbin you can see about 60 commands. I try to port one more very few months. I welcome contributors. A few of the things I find useful: grep -r works; I still use find from time to time; timeout and backoff are two useful commands (backoff tries a command and, if it fails, backs off and tries again; timeout runs a command and, if it does not complete, kills it); and there's a known-good sshd and scp command. To get u-root, 1. install go 1.22 2. git/clone https://github.com/u-root/u-root 3. you can use the script above. Let me know if you hit a problem, or you feel like contributing. The entire rewrite-all-commands and create the initramfs is about 20s for 180 commands on linux/*bsd/darwin; about 36s for 60 commands on Plan 9 on my T420. The combined binary is 7 MiB, or about 120K per command on Plan 9. For 160 commands, it's about the same size. For one command, it's about 2M. See slide 11 on https://docs.google.com/presentation/d/1sFI4xSveKgi2iCJ95gc8VzrmdJwxiwNbMS6KcKX62Tg/edit?usp=sharing to get some idea of size and the limits at each end. Also, note, there's nothing special about the u-root commands; they are all standalone Go programs. Which means, you can include anything you want into the cpio. The u-root busybox needs no special programming for its commands, unlike every C and Rust and Go busybox I've used before. Also, note, you can use the gobusybox command, and the mkuimage command, and never use u-root at all. They are separate. U-root is used in every firmware image in every datacenter platform at Google. It's pretty hardened. U-root is another project which the late Andrey Mirtchovski contributed to in its early days. Ron p.s. "Why didn't you write it in Rust?" -- I take that question seriously, and did some measurements. Rust does not do as well for this purpose as Go. A good thing; we have native Go on Plan 9, and I doubt we'll see native Rust on Plan 9 any time soon, if ever. ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tb9714d4771613034-M288294a67a083b2635cc97a7 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription