[Toybox] Booting a toybox system
ibid.ag at gmail.com
ibid.ag at gmail.com
Sat Dec 21 21:26:04 PST 2013
I did some testing on what it took to get a minimal toybox system to boot,
autoload modules, and connect to the network (manually).
I'm testing in qemu with user networking; the ethernet drivers are built
as modules (pcnet32.ko/e1000.ko).
Instead of building a root filesystem, I'm just using the initrd as a
live filesystem.
I create bin/, dev/, proc/, sys/, var/run/, var/log/, lib/modules/, lib/dhcp/,
tmp/, and mnt/. sbin can be a symlink to bin.
toybox gets dropped in bin/ and all the necessary symlinks created.
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,
Isaac Dunham
Commands needed:
Other programs:
pdksh (as /bin/sh)
>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
#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!)
#!/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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tb-bootscripts.cpio.bz2
Type: application/octet-stream
Size: 1426 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20131221/d47213cd/attachment-0005.obj>
More information about the Toybox
mailing list