gpt4 book ai didi

linux - 使用 ramdisk 作为 rootfs 启动时找不到 Init 进程

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:54:20 36 4
gpt4 key购买 nike

我正在尝试为我使用 AT91SAM9261 和 2.6.30 内核的设置设置一个 ramdisk。我知道你会说我为什么不使用 initramfs?我也会使用那个,截至目前,我想检查是否可以使用 ramdisk 作为 rootfs 启动。

我已经有一个以 jffs2 格式在这个系统上运行良好的根文件系统。我使用了以下教程:

http://www.ibm.com/developerworks/library/l-initrd/

所以我直接在嵌入式目标上创建了 4MB 大小的 ramdisk。我使用了“dd”和“mkefs”,当 rootfs 是我的 jffs2 时,如果我将它挂载为循环,则 ramdisk 镜像工作正常。我可以浏览 mount_point 并在里面做事。内容根据上述链接中“手动构建初始RAM盘”部分创建。

在/dev 中,我放置了 null 和控制台,在/bin 中,我复制了 busybox 并创建了链接。我也将 execute 属性设置为 init 脚本,当我在这里运行它时它工作正常(作为循环设备,jffs2 作为 rootfs)

在我的内核配置中,我启用了 ramdisk 支持,如下所示:

CONFIG_BLK_DEV_INITRD=y
CONFIG_RD_GZIP=y

CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=4096

我使用 tftp 将 ramdisk 镜像下载到 0x21100000。在 0x20008000 处我解压缩了内核,在 0x22000000 处复制了 zImage。

但是,我无法成功启动系统,因为它在检查 init 进程时挂起。正如我提到的,我多次检查我的 init 可以执行,

我还在 bootargs init=/bin/busybox 或其他脚本/二进制文件中使用来检查是否有任何可以用作 init。

我现在使用的命令行:

bootargs=64M console=ttyS0,115200 root=/dev/ram0 rw initrd=0x21100000,4194304 init=/init

对于某些人,我将所有权设置为“无人”只是为了检查它是否有任何区别。从日志输出中可以看出,ramdisk 已挂载,但 init 失败。它给出了检查 ext2 镜像的警告,我在复制它之前就这样做了,但我没有报告任何错误。

tftp 服务器在 Windows7 上。我虽然如果我将 ramdisk 镜像从 linux 复制到 Windows 然后从 Windows 服务器执行 tftp,我可能会有一些不兼容。所以我再次将镜像从 Windows 复制到 Linux,安装它并检查 FS 是否报告任何错误并且可以执行脚本 - 一切看起来都很正常。

所以我确实已经准备好所有文件,设置了属性,报告 ramdisk 作为 rootfs 安装正常,但找不到 init。

 Uncompressing Linux......................................................................................................... done, booting the kernel.
Linux version 2.6.30-olimex (mishu@KubuntuVM) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #1 Mon Dec 29 13:53:54 CET 2014
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: Olimex SAM9-L9261
Ignoring unrecognised tag 0x54410008
Memory policy: ECC disabled, Data cache writeback
Clocks: CPU 198 MHz, master 99 MHz, main 18.432 MHz
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: 64M console=ttyS0,115200 root=/dev/ram0 rw initrd=0x21100000,4194304 init=/init
NR_IRQS:192
AT91: 96 gpio irqs in 3 banks
PID hash table entries: 256 (order: 8, 1024 bytes)
Console: colour dummy device 80x30
console [ttyS0] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 57384KB available (2924K code, 246K data, 132K init, 0K highmem)
Calibrating delay loop... 99.12 BogoMIPS (lpj=495616)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 716 bytes
NET: Registered protocol family 16
AT91: Power Management
AT91: Starting after user reset
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
Trying to unpack rootfs image as initramfs...
rootfs image is not initramfs (junk in compressed archive); looks like an initrd
Freeing initrd memory: 4096K
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
msgmni has been set to 120
io scheduler noop registered
io scheduler anticipatory registered (default)
atmel_lcdfb atmel_lcdfb.0: backlight control is not available
atmel_lcdfb atmel_lcdfb.0: 225KiB frame buffer at 23140000 (mapped at ffc00000)
Console: switching to colour frame buffer device 40x30
atmel_lcdfb atmel_lcdfb.0: fb0: Atmel LCDC at 0x00600000 (mapped at c4866000), irq 21
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xfffb0000 (irq = 6) is a ATMEL_SERIAL
brd: module loaded
loop: module loaded
ssc ssc.1: Atmel SSC device at 0xc4878000 (irq 15)
Driver 'sd' needs updating - please use bus_type methods
dm9000 Ethernet Driver, V1.31
eth0 (dm9000): not using net_device_ops yet
eth0: dm9000e at c486a000,c486e044 IRQ 107 MAC: 3a:1f:34:08:54:64 (chip)
NAND device: Manufacturer ID: 0xec, Chip ID: 0xdc (Samsung NAND 512MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 1478 at 0x00000b8c0000
Creating 2 MTD partitions on "atmel_nand":
0x000000000000-0x000000040000 : "Partition 1"
0x000000040000-0x000020000000 : "Partition 2"
atmel_spi atmel_spi.0: Atmel SPI Controller at 0xfffc8000 (irq 12)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
at91_ohci at91_ohci: AT91 OHCI
at91_ohci at91_ohci: new USB bus registered, assigned bus number 1
at91_ohci at91_ohci: irq 20, io mem 0x00500000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: AT91 OHCI
usb usb1: Manufacturer: Linux 2.6.30-olimex ohci_hcd
usb usb1: SerialNumber: at91
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
udc: at91_udc version 3 May 2006
g_serial gadget: Gadget Serial v2.4
g_serial gadget: g_serial ready
mice: PS/2 mouse device common for all mice
input: gpio-keys as /class/input/input0
ads7846 spi0.2: touchscreen, irq 29
input: ADS784x Touchscreen as /class/input/input1
rtc-at91sam9 at91_rtt.0: rtc core: registered at91_rtt as rtc0
IRQ 1/rtc0: IRQF_DISABLED is not guaranteed on shared IRQs
rtc-at91sam9 at91_rtt.0: rtc0: SET TIME!
i2c /dev entries driver
i2c-gpio: probe of i2c-gpio failed with error -16
Registered led device: led1
Registered led device: led2
Registered led device: led3
Advanced Linux Sound Architecture Driver Version 1.0.20.
at73c213 spi0.3: at73c213: supported bitrate is 48500 (64 divider)
usb 1-1: new full speed USB device using at91_ohci and address 2
usb 1-1: New USB device found, idVendor=0457, idProduct=0151
usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=3
usb 1-1: Product: USB Mass Storage Device
usb 1-1: SerialNumber: 8d54bd8186b42c
usb 1-1: configuration #1 chosen from 1 choice
scsi0 : SCSI emulation for USB Mass Storage devices
ALSA device list:
#0: SAM9-L9261 external DAC on irq 15
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
rtc-at91sam9 at91_rtt.0: hctosys: unable to read the hardware clock
RAMDISK: ext2 filesystem found at block 0
RAMDISK: Loading 4096KiB [1 disk] into ram disk... done.
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem) on device 1:0.
Freeing init memory: 132K
Failed to execute /init. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
[<c002f414>] (unwind_backtrace+0x0/0xdc) from [<c025bd34>] (panic+0x40/0x110)
[<c025bd34>] (panic+0x40/0x110) from [<c0029500>] (init_post+0xd0/0xf8)
[<c0029500>] (init_post+0xd0/0xf8) from [<c00085a0>] (kernel_init+0xbc/0xe4)
[<c00085a0>] (kernel_init+0xbc/0xe4) from [<c0041998>] (do_exit+0x0/0x5ac)
[<c0041998>] (do_exit+0x0/0x5ac) from [<00000001>] (0x1)

我计划重建 busybox 并重试,但由于我当前的 ramdisk 镜像在我将其挂载为循环时可以正常工作,所以我不太相信它会改变某些东西。我没主意了。我一整天都在努力让它工作。

非常感谢您的帮助。

谢谢。

最佳答案

缺少库是 ramdisk 上不可执行的 init 的根本原因。事实证明,使用 chroot 非常有用。通过这个问题,我学会了如何使用 chroot 和模拟 jail 。

另一个技巧是使用 user_debug=31在命令行中,以便内核将输出一条消息,指出找不到该文件。看起来“找不到文件”并不是真正指向丢失的文件,而是由于 busybox 未正确执行(缺少库)导致无法读取文件系统。

与此同时,我为我的 arm 架构动态编译了 busybox 1.20.02,并且 ramdisk 工作正常(没有库)。这user_debug=31当我编译并运行 busybox 时,它再次变得有用,因为它在安装 ramdisk 后也失败了,但它抛出了一个“未定义的异常”,这导致我在编译 busybox 时使用了错误的“arch”值。更改后一切正常。

关于linux - 使用 ramdisk 作为 rootfs 启动时找不到 Init 进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27697326/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com