1
我的系統(ARM32)通過U-Boot引導Linux。內核獲取console=ttymxc1,115200
作爲u-boot的參數。 然後它在initramfs中使用一個帶有switch_root
(由busybox
解釋)的shell腳本來初始化根文件系統。 此外,此initramfs腳本解析內核命令行以獲取正確的console
。Linux initramfs switch_root無法找到內核使用的控制檯
問題是switch_root
正在打印到tty1
。儘管如此,內核使用正確的控制檯,在其參數中指定。 如果我通過-c
參數switch_root
它也使用/dev/tty1
,這是我的情況顯示。
有沒有人有一個想法如何我可以得到init
(sysvinit)使用內核參數中指定的控制檯?
這裏的initramfs的腳本源:
#!/bin/sh
echo "init: rootfs setup"
# mount temporary filesystems
mount -n -t devtmpfs devtmpfs /dev
mount -n -t proc proc /proc
mount -n -t sysfs sysfs /sys
mount -n -t tmpfs tmpfs /run
read -r cmdline < /proc/cmdline
# define filesystems
ROOT_DEV="/dev/mydev"
ROOT="/newroot"
# mount rootfs
mkdir -p ${ROOT}
mount ${ROOT_DEV} ${ROOT}
# get & create console
CONSOLE=$(echo $cmdline) | sed 's/.*console=\(.*\),.*/\1/'
mknod -m 644 ${ROOT}/dev/${CONSOLE} c 5 1
# switch to new rootfs and exec init
echo "init: rootfs successful mounted (${ROOT})"
cd ${ROOT}
exec switch_root -c /dev/${CONSOLE} . "/sbin/init" "[email protected]"
而這裏的initramfs的config.cfg
dir /bin 755 1000 1000
dir /dev 755 0 0
dir /mnt 755 0 0
dir /proc 755 0 0
dir /run 755 0 0
dir /sys 755 0 0
file /bin/busybox initramfs/busybox 755 0 0
file /init initramfs/init 755 0 0
nod /dev/console 644 0 0 c 5 1
nod /dev/ttymxc1 644 0 0 c 5 1
slink /bin/chroot busybox 777 0 0
slink /bin/find busybox 777 0 0
slink /bin/grep busybox 777 0 0
slink /bin/mkdir busybox 777 0 0
slink /bin/mknod busybox 777 0 0
slink /bin/mount busybox 777 0 0
slink /bin/sed busybox 777 0 0
slink /bin/sh busybox 777 0 0
的init你用哪個? systemd或sysv-init?當沒有'-c'指定時,switch_root不會改變tty,我認爲它是'init'來改變tty。 –
我使用sysvinit。是的,我知道,因此我添加了'-c/dev/$ {CONSOLE}'參數;-) – g0hl1n