I have successfully booted into a NetBSD kernel with a custom ramdisk that has a statically linked init that does nothing.
Baby steps!
Discussion
I have successfully booted into a NetBSD kernel with a custom ramdisk that has a statically linked init that does nothing.
Baby steps!
Interesting... MEMORY_DISK_DYNAMIC is enabled, so the ramdisk size shouldn't matter, as far as I understand things.
Nevertheless, I'll try a new approach: I'll write a very small init that bootstraps things, and execs dinit.
I need to figure out how to write to the console during early boot.
The solution is populating /dev.
Nice. I wrote a small C program that mounts /, and execs the NetBSD init. This is fine short-term. All I really need from the ramdisk's init is to mount / and the store (name tbd, not /store, perhaps /polyamory, or /fuckery?), and then execs the real init.
It will need to do a lot more long term, but I'm very far from that.
Next up: Don't ship /dev, mknod(2) the few device nodes my rd-initd needs.
Or, you know... I'll just ship /dev in the ramdisk, because that's easier. I'll address that part later.
What to do next... I suppose making it boot with dinit would be the logical next step, and then I can try building a minimal system in the store, boot that up, and go from there.
Whee!
Booted with dinit, kind of. Only have two services so far: mount -a and getty on constty, but we're getting there, this is enough to validate the approach.
Now to figure out the next step!
Previously, I considered setting up a hand-built store, and going from there, but... that's a very big leap: it involves not only moving netbsd's userland to the store, I'd also have to write the "lets reconstruct the ephemeral parts of /".
Like, the goal is to have / on tmpfs...
Idea is turning out to be harder than anticipated, because I have to figure out how to mount mfs on /, and mfs_args has a caddr_t base member, and what's that, and how does that and size relate to the parameters given to mount_mfs?
And where's the source of mount_mfs? Because I can't find it in /usr/src/sbin/...
Aha! It's /sbin/newfs.
Yeah, well, I'm not gonna do that from C, and /rescue/mount_mfs is big. But perhaps it fits.
Buut, there's mount_tmpfs! And I suppose I actually want that, not mfs, so lets see how hard it is to do in C.
Nice. That works. So the next step then is:
tmpfs as /altroot/dev/dk0 as /altroot/tbd/altroot/tbd to /altroot/altroot/usr/pkg/sbin/dinit