Launching Linux from Busybox (pivot_root or switch_root, or ? )

Bob Dunlop bob.dunlop at xyzzy.org.uk
Tue Jun 10 11:16:20 UTC 2014


Hi,

On Tue, Jun 10 at 11:05, St??phane Massot wrote:
> Hi,
> 
> On a beaglebone hardware, I want to start on a partition with a minimalist
> busybox system (/dev/mmcblk0p2), run some checks on the 2 other partitions
> (/dev/mmcblk0p5 & /dev/mmcblk0p6) containing more complete Linux systems
> (Angstr??m), then start on one or the other of the 2 Linux systems based on
> those tests.

Mail is scrambled.  HTML mail Grr.
However as already suggested systemd is probably some of the problem.

If you're booting from two different sources arn't you likey to want to
run different kernels with each ?  Angstom kernel for angstom etc.  If
so kexec [1] is your friend and will probably give systemd a better start
in life as it will be called from the new kernel.


A fragement of code from one of our system startup scripts, I'm sure you
can work out what the missing functions do by name.  The target file
system has been checked and mounted on /mnt.


. /etc/params.sh
. /etc/functions.sh


do_switch_root()
{
	local init=/sbin/init

	echo "Switching root"

	stop_network

	echo > /proc/sys/kernel/hotplug

	umount /tmp
	umount /sys
	umount /proc

	[ -s /mnt/linuxrc ] && init=/linuxrc

	exec switch_root -c /dev/console /mnt $init
}

do_kexec_boot()
{
	echo "Calling kexec"

	stop_network

	if kexec -l /mnt/boot/zImage 
	then
		kexec -e
	fi
}

...

	if [ -e /mnt/boot/zImage ]
	then
		do_kexec_boot
	elif [ -c /mnt/dev/console -a -x /mnt/sbin/init ]
	then
		do_switch_root
	else
		echo "Mount successful but no boot options available"
	fi


[1] http://en.wikipedia.org/wiki/Kexec

-- 
        Bob Dunlop


More information about the busybox mailing list