[Toybox] Booting a toybox system

ibid.ag at gmail.com ibid.ag at gmail.com
Sat Dec 28 16:04:55 PST 2013


On Sat, Dec 28, 2013 at 11:57:55AM -0600, Rob Landley wrote:
> On 12/21/13 23:26, ibid.ag at gmail.com wrote:
<snip>
> >Modules get installed in /lib/modules/$KERNRELEASE/kernel/, as they would
> >ordinarily; I then run in the project root:
> >/sbin/depmod -b . $KERNRELEASE
> >rm lib/modules/*/*.bin lib/modules/modules.{softdep,devname}
> >#extract any files I need
> >#create the initrd:
> >find ./|cpio -o -H newc |gzip -9c >../tbinitrd.img
> >
> >And that's ready for qemu.
> >
> >
> >In qemu, I configure the network like so:
> >ifconfig eth0 up
> >dhcp -v -s /lib/dhcp/set.sh
> >
> >Hope this is helpful to someone,
> 
> Sounds good. So what's the prognosis, anything major missing? (You
> used depmod and toybox hasn't got one, but is that a build tool or a
> runtime tool...)

depmod is an install tool, which is called when you build a module
package or install a new module.
In other words, for the normal kernel drivers you just need it as
a build tool; if you install out-of-tree or backported drivers,
you will also need depmod.
Functionally, it's more-or-less modinfo + nm with a bit of glue changing
the output format.

As far as "anything missing" goes:
besides a fully working sh, there are or have been submissions for all of it.
Not all have been merged:
modprobe, getty, resolve_modalias, and mount are not in stock toybox.
The "mount" I used is derived from the 1400+ line version that used 
RPC to handle NFS mounts; when I axed all the special code for NFS,
it ended up being 688 lines long.

> >Isaac Dunham
> >
> >
> >Commands needed:
> >Other programs:
> >pdksh (as /bin/sh)
> 
> I really need to find time to tackle toysh properly. I know what I
> need to _do_, I'm just having to stay more fully employed to support
> my family than I did a few years back...
> 
> >>From toybox:
> >#boot
> >init
> >mount # hacked version of Ashwini Sharma's last version; all probably work
> >mkdir # for /dev/pts
> >getty # I used mine
> >login # if you use pdksh directly, you don't need getty or login
> >
> >#autoload modules; no, the kernel doesn't seem to do this...
> >find
> >cat
> >xargs
> >resolve_modalias # mine; because modprobe -q isn't quiet (optional)
> >modprobe         #v2 from Ashwini
> 
> Is that a bug in modprobe?

Yes, though it's more cosmetic...

> >#networking
> >ifconfig
> >dhcp
> >route
> >
> >#testing
> >ftpget  # from Ashwini with my patch, to test network
> >echo
> >env
> >ls
> >lsmod
> >
> >#shutdown
> >sync
> >umount
> >kill
> >killall
> >poweroff # optional if you send the right signal to init
> >
> >Scripts:
> >
> >/init: (devtmpfs is not automounted from the initrd!)
> 
> I need to send another kernel patch to make the devtmpfs automount
> thing actually happen for initmpfs...
> 
> >#!/bin/sh
> >mount -t devtmpfs dev /dev
> >exec toybox init
> >
> >/etc/fstab (simplifies rcS)
> >/etc/inittab (not needed with Ashwini's getty)
> >/etc/init.d/rcS (autostart at boot)
> >/lib/dhcp/set.sh
> >
> >Files for user accounts...
> >/etc/passwd
> >/etc/shadow
> >/etc/group
> >/etc/profile
> 
> Looks good to me. I might be up for adding a www/rootfs directory
> with an example root filesystem layout. (It would logically be
> doc/skeleton but our documentation directory is a copy of the
> website, so...)
> 
> Or maybe ascript to generate such (via here documents) would make
> more sense, living in scripts?

The one difficulty is the need to set up passwords. I've found that it can
be tricky.
So possibly a script would be better.
On the other hand, documenting the rootfs structure makes sense...

I'd like to write up something that generates the proper rootfs
structure; I'll make sure to explain the logic in comments.


Is there somewhere that "set.sh" script should go? It's a "works-for-me"
version of default.script.

> 
> Thanks for the heads up,
> 
> Rob

Thanks,
Isaac

 1388275495.0


More information about the Toybox mailing list