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

Didier Kryn kryn at in2p3.fr
Tue Jun 10 10:56:15 UTC 2014


     Hi Stéphane.

     I do exactly what you want to do (I boot Debian Wheezy on diskless 
PowerPC servers):

     Here is my busybox init script (in initramfs)
/bin/busybox mount -t proc none /proc
     /bin/busybox mount -t sysfs none /sys
busybox --install
export PATH="/bin:/sbin:/usr/bin:/usr/sbin"
     # now configure network (I skip the dirty details)
mkdir -m 755 /dev/pts
     mount -t devpts devpts /dev/pts
     mdev -s
     # now play private tricks to find usable root filesystems and 
decide which one to boot
     # more tricks to mount some tmpfs dirs like Debian's init expects them
     exec /sbin/switch_root $ROOTFS $INIT 2

     The only difference I see with what you do is mounting /proc and 
running mdev. I guess you have the busybox links ready made since you 
don't run busybox --install. Of course, the init command you pass to 
switch_root must be executable.

     Critical point: your script or interactive shell must be process #1.

     One detail more: my busybox is statically linked; I don't know if 
it matters; just avoids the burden of shared libs.

     Hope it helps.
                                 Didier

Le 10/06/2014 11:05, Stéphane Massot a écrit :
> 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.
>
> The problem is that I cannot find how to start another system 
> correctly from busybox.
>
> What I did:
>
> From the (perfectly working) busybox system:
>
> /export PATH=/bin:/sbin:/usr/bin:/usr/sbin
> mount -t sysfs sysfs /sys
> mkdir -p /dev/pts
> mount -t devpts devpts /dev/pts
> mount /dev/mmcblk0p5 /mnt/root/
>
> Then I tried 2 ways:
>
> *1) pivot_root*
>
> /cd /mnt/root
> pivot_root . ./initrd
> ./bin/mount -n --move ./initrd/sys ./sys
> ./bin/mount -n --move ./initrd/proc ./proc
> ./bin/mount -t devtmpfs none ./dev
> ./bin/mount -n --move ./initrd/dev/pts ./dev/pts
> exec ./usr/sbin/chroot . ./sbin/init < ./dev/ttyO0 > ./dev/ttyO0 2>&1/
>
> This gives the following error :
>
> /Couldn't find an alternative telinit implementation to spawn./
>
> It then starts a new Angström login prompt, but after logging in, any 
> call to "init" will return the error above, and the system doesn't 
> work (for example, if I call "reboot", it fails; if I call "killall 
> busybox", it triggers a reboot).
>
> I tried without the "./usr/sbin/chroot . ", and it gives the same results.
>
> *2) switch_root*
>
> /exec switch_root -c /dev/ttyO0 /mnt/root /sbin/init/
>
> This gives me a new busybox login prompt, and I am still on the 
> busybox partition
>
>
> Any idea what I've done wrong ? Have I missed a step ? Any parameter I 
> forgot to take into account or any method to see more details about 
> what went wrong ?
>
>
> -- 
> Stéphane Massot
> Lead Embedded Developper
> Téléphone : +33 (0)1 84 17 31 20
> Portable : +33 (0)6 79 38 18 87
> stephane.massot at smart-impulse.com 
> <mailto:stephane.massot at smart-impulse.com>
>
> SMART IMPULSE
> 48 rue René Clair
> 75018 PARIS
> www.smart-impulse.com <http://www.smart-impulse.com>
>
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20140610/835b79ab/attachment.html>


More information about the busybox mailing list