Running Linux from Busybox (pivot_root or switch_root or?)

On beaglebone hardware, I want to start with a partition with a minimalistic busybox system (/ dev / mmcblk0p2), run some checks on 2 other partitions (/ dev / mmcblk0p5 and / dev / mmcblk 0p6) containing a more complete Linux system (Angström), and then start with one or the other of the two Linux systems based on these tests.

The problem is that I cannot find how to properly start another system from busybox.

What I've done:

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:

  • 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 results in the following error:

    Couldn't find an alternative telinit implementation to spawn.
    

    Angström, "init" , (, "", ; "killall busybox", ).

    "./usr/sbin/chroot.", .

  • switch_root

    exec switch_root -c /dev/ttyO0 /mnt/root /mnt/root/sbin/init
    

    busybox, busybox

, ? ? , - , , ?

+4

Source: https://habr.com/ru/post/1543571/


All Articles