私は、ビジーボックスを備えた組み込み Linux 環境にいます。switch_rootの使用方法を学ぼうとするいくつかの 投稿を読みました。私はこれを試しました:
exec switch_root -c /dev/console /mnt/newroot /bin/busybox init
switch_root
ヘルプが表示され、新しいログインが表示されます。
[root@buildroot ~]# exec switch_root -c /dev/console /mnt/newroot /bin/busybox init
BusyBox v1.21.0 (2015-04-24 18:14:40 MDT) multi-call binary.
busybox init
Usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT [ARGS]root /bin/busybox in
Free initramfs and switch to another root fs:
chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,
execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.
-c DEV Reopen stdio to DEV after switch
Welcome to Buildroot
buildroot login:
ログインすると、newrootが読み込まれておらず、古いものがまだ残っています。これは、ある種の init スクリプトからではなく、コマンド ラインから直接このコマンドを実行しているためですか?
この記事を読んだところ、実行する前に他の手順を実行していることがわかりましたswitch_root
。
mount --move /sys /newroot/sys
mount --move /proc /newroot/proc
mount --move /dev /newroot/dev
まず、これは私を混乱させます。を実行する前にこれらのコマンドを実行する必要があるのはなぜswitch_root
ですか? 私のためにこれをしませswitch_root
んか?
とにかく、先に進んで、最初にそれらを実行してから、switch_root
コマンドを実行してみました。ただし、これは物事を完全にホースでつなぎます。
[root@buildroot /]# switch_root -c /dev/console /mnt/newroot /bin/busybox init
BusyBox v1.21.0 (2015-04-24 18:14:40 MDT) multi-call binary.
Usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT [ARGS]
Free initramfs and switch to another root fs:
chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,
execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.
-c DEV Reopen stdio to DEV after switch
can't open /dev/ttyS0: No such file or directoryole /mnt/newroot /bin/busybox init
can't open /dev/ttyS0: No such file or directory
can't open /dev/ttyS0: No such file or directory
can't open /dev/ttyS0: No such file or directory
can't open /dev/ttyS0: No such file or directory
can't open /dev/ttyS0: No such file or directory
can't open /dev/ttyS0: No such file or directory
... message continues to repeat ...
dev のマウントを移動したため、init が実行され、シリアル ポートに getty を配置しようとすると、見つからないように見えますか? 錯乱........
ここで何か基本的なことが欠けていswitch_root
ますか? または、単にコマンドラインの変更が必要ですか?