Last night I was about to reimplement my tiny initrd initd in Rust, and start playing with some configuration. Or something along those lines.
We'll see, I'm going to wing it: close my eyes, type, see where it leads.
Discussion
Last night I was about to reimplement my tiny initrd initd in Rust, and start playing with some configuration. Or something along those lines.
We'll see, I'm going to wing it: close my eyes, type, see where it leads.
The hard part about fsck is that I can't just run /sbin/fsck, because I need its output not on stdout / stderr, but both of those on /dev/console.
Hm. Maybe I can... redirect stdout/stderr there from my main()! And then fsck becomes reasonably simple.
Ok, fine. command.stdout(Stdio::from(console)) gets the job done.
Hrm. The rust init causes a panic somewhere. But the !@#!@# console doesn't let me scroll back more than one page.
Disabling kern.dump_on_panic still puts me into the debugger.
A few logs later: it's fsck. It's probably missing stdin or something.
OH, and I need to disable ddb.onpanic too, I guess.
Yep, it was stdin missing. But now there's a new bug: chrooting into /altroot fails!
Or maybe something after that, because chroot looses /dev/console until I set it up again.
Oh dear. I know. PEBKAC! It's my log() function that panics rust, because it tries to log to /dev/console, but right after chroot, there is no /dev/console.
On the flip side: fsck works!
Another progress, we're inside the chroot now. But /rescue/mount fails.
I'll see if I can /rescue/sh -i, and go from there.
Oh. Yes. There's no /rescue. There's /sexshop/bondage/rescue. Duh.
Ah! /rescue/mount tries to run mount_null, from $PATH (or /rescue, I guess), but it won't find it there. Calling /rescue/mount_null directly should help.
Aaand booted with rust-y initd. Neat.
Some of these commits are... something.
Remove
dildo, as it has been replaced byforeplay.
I'm so proud of myself right now.
Soo... the new initrd works fine, can even fsck. That's cool.
Would be nice to have a kernel that boots faster than the GENERIC kernel. Something a bit tailored to running in QEMU/KVM. But there are so many kernel options in GENERIC! And... a leaner kernel isn't that important, once I stop booting every 2 minutes.
Oh. I'm also missing some certs, so curl-ing an HTTPS resource fails.
Hm. Where did those things go.
Mkay. I can boot into this thing, the initrd init is working okay. There are sharp edges, but... there's no immediate need to fiddle with the booting process or either initd.
So... what's next?
I think the hardest part about my mini-initd will be
fsck. Who would have thought it would be fucking hard. It's not like it's in the name.