无法运行“/etc/init.d/rcS”:没有这样的文件或目录

问题描述

我正在尝试使用 qemu 模拟固件映像。在启动过程中,我收到以下错误

can't run '/etc/init.d/rcS': 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
.
.
.

这是inittab文件内容

# Startup the system
null::sysinit:/etc/init.d/rc.sysinit

# Now run any rc scripts
::sysinit:/etc/init.d/rcS

# Put a getty on the serial port
ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100

# Stuff to do before rebooting
null::shutdown:/bin/umount -a -r

它能够运行 rc.sysinit,但不能运行 rcS。 我已经检查了 rcS 的权限。此外,文件系统安装为只读 cramfs。这会导致问题吗?

这是我正在运行的命令:

QEMU_AUdio_DRV=none \qemu-system-arm -m 256M -M versatilepb 
-kernel ~/linux-2.6.23/arch/arm/boot/zImage 
-append "console=ttyAMA0,115200 root=/dev/ram rdinit=/sbin/init" 
-initrd ~/tmpcramfs2 
-nographic

这些是运行命令时获得的启动消息:

Linux version 2.6.23 (hsailer@SvanteArrhenius) (gcc version 4.0.2) #1 Thu May 27 09:31:10 EDT 2021
cpu: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ),cr=00093177
Machine: ARM-Versatile PB
Memory policy: ECC disabled,Data cache writeback
cpu0: D VIVT write-through cache
cpu0: I cache: 4096 bytes,associativity 4,32 byte lines,32 sets
cpu0: D cache: 65536 bytes,512 sets
Built 1 zonelists in Zone order.  Total pages: 65024
Kernel command line: console=ttyAMA0,115200 root=/dev/ram rdinit=/sbin/init
PID hash table entries: 1024 (order: 10,4096 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 32768 (order: 5,131072 bytes)
Inode-cache hash table entries: 16384 (order: 4,65536 bytes)
Memory: 256MB = 256MB total
Memory: 249600KB available (2508K code,227K data,100K init)
Mount-cache hash table entries: 512
cpu: Testing write buffer coherency: ok
NET: Registered protocol family 16
NET: Registered protocol family 2
Time: timer3 clocksource has been installed.
IP route cache hash table entries: 2048 (order: 1,8192 bytes)
TCP established hash table entries: 8192 (order: 4,65536 bytes)
TCP bind hash table entries: 8192 (order: 3,32768 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
TCP reno registered
checking if image is initramfs...it isn't (bad gzip magic numbers); looks like an initrd
Freeing initrd memory: 7184K
Netwinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
jffs2 version 2.2. (NAND) © 2001-2006 Red Hat,Inc.
JFS: nTxBlock = 2007,nTxLock = 16063
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
CLCD: Versatile hardware,VGA display
Clock CLcdclK: setting VCO reg params: S=1 R=99 V=98
Console: switching to colour frame buffer device 80x60
Serial: AMBA PL011 UART driver
dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
console [ttyAMA0] enabled
dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011
fpga:09: ttyAMA3 at MMIO 0x10009000 (irq = 38) is a AMBA/PL011
RAMdisK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
smc91x.c: v1.1,sep 22 2004 by Nicolas Pitre <nico@cam.org>
eth0: SMC91C11xFD (rev 1) at d098e000 IRQ 25 [Nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
armflash.0: Found 1 x32 devices at 0x0 in 32-bit bank
 Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
RedBoot partition parsing not available
afs partition parsing not available
armflash: probe of armflash.0 Failed with error -22
mice: PS/2 mouse device common for all mice
input: AT Raw Set 2 keyboard as /class/input/input0
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0
input: ImExPS/2 Generic Explorer Mouse as /class/input/input1
RAMdisK: cramfs filesystem found at block 0
RAMdisK: Loading 7184KiB [1 disk] into ram disk... done.
VFS: Mounted root (cramfs filesystem) readonly.
Freeing init memory: 100K
can't run '/etc/init.d/rcS': 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
.
.
.

解决方法

关于 /dev/ttyS0 的错误是因为您的 inittab 为您正在运行的(模拟)硬件的串行端口指定了错误的设备名称。您的 QEMU 命令指定了“versatilepb”板,其串行设备是 PL011s,在 /dev/ 中显示为 /dev/ttyAMA0、/dev/ttyAMA1 等(/dev/ttyS0 是 x86 PC 上的串行端口显示的内容) as.) 您需要修复 inittab 的那一行以引用 ttyAMA0。

对于 rcS 错误,我建议您首先仔细检查对 this older question 的所有响应中列出的所有内容。