Douglas B
Douglas B

Reputation: 832

What is the 'right' way to replace /sbin/init or preempt it on an image built with Yocto (petalinux)

I have a Yocto (petalinux) project that builds the artifacts for an embedded system. This system gets its rootfs as an overlay from one of two partitions, depending on boot conditions. To accomplish this, I build a separate ramfs from a stripped down version of the projects rootfs, and replace /sbin/init with one that mounts the correct overlay, changes root, and reruns /sbin/init (now replaced by the overlays version, which does the rest of a normal sysvinit).

So right now, the system boots u-boot, which runs an image containing my kernel and a custom ramfs. The init in the ramfs mounts a new rootfs as an overlay, changes root, and executes the now overwritten /sbin/init.

Is there a better/more standard way to accomplish this? All of my googling is leading me to init.d scripts, which I don't believe are exactly what I am looking for as I want something that will 100% always be the first thing to run after u-boot hands off to the kernel.

Ideally, I would like to be able to point Petalinux/yocto to my script to be run as a 'preinit' script, but I am open to any other less complicated solutions than having to build a special out of band uboot image/rootfs.

Upvotes: 0

Views: 14

Answers (0)

Related Questions