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

本小妞迷上赌 提交于 2020-01-01 10:17:12

问题


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 /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 ?

来源:https://stackoverflow.com/questions/24083712/launching-linux-from-busybox-pivot-root-or-switch-root-or

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!