我在这里问了一个问题是否必须拥有文件系统
评论之一是:
没有文件系统的系统如何在 linux 上工作,因为即使打印机或以太网卡也被视为文件?你在这里的目标是什么?...新西兰 2 月 24 日 14:18
现在这是在没有文件系统的情况下启动 linux 时的日志消息(挂在最后):
[Tue Apr 08 20:07:18.298 2014]
[Tue Apr 08 20:07:18.298 2014]
[Tue Apr 08 20:07:18.298 2014] U-Boot 2013.07 (Apr 08 2014 - 14:27:03)
[Tue Apr 08 20:07:18.298 2014]
[Tue Apr 08 20:07:18.298 2014] Memory: ECC disabled
[Tue Apr 08 20:07:18.298 2014] DRAM: 1 GiB
[Tue Apr 08 20:07:18.308 2014] SF: Detected N25Q128A with page size 64 KiB, total 16 MiB
[Tue Apr 08 20:07:18.341 2014] *** Warning - bad CRC, using default environment
[Tue Apr 08 20:07:18.341 2014]
[Tue Apr 08 20:07:18.341 2014] In: serial
[Tue Apr 08 20:07:18.341 2014] Out: serial
[Tue Apr 08 20:07:18.341 2014] Err: serial
[Tue Apr 08 20:07:18.341 2014] U-BOOT for Xilinx-ZC702-14.7
[Tue Apr 08 20:07:18.341 2014]
[Tue Apr 08 20:07:18.341 2014]
[Tue Apr 08 20:07:18.341 2014] SF: Detected N25Q128A with page size 64 KiB, total 16 MiB
[Tue Apr 08 20:07:18.697 2014] Linux
[Tue Apr 08 20:07:18.697 2014] Load Address: 0x00008000
[Tue Apr 08 20:07:18.697 2014] Entry Point: 0x00008000
[Tue Apr 08 20:07:18.697 2014] Verifying Hash Integrity ... OK
[Tue Apr 08 20:07:18.697 2014] ## Loading fdt from FIT Image at 01000000 ...
[Tue Apr 08 20:07:18.697 2014] Using 'conf@1' configuration
[Tue Apr 08 20:07:18.697 2014] Trying 'fdt@1' fdt subimage
[Tue Apr 08 20:07:18.697 2014] Description: Flattened Device Tree blob
[Tue Apr 08 20:07:18.697 2014] Type: Flat Device Tree
[Tue Apr 08 20:07:18.697 2014] Compression: uncompressed
[Tue Apr 08 20:07:18.697 2014] Data Start: 0x0111d344
[Tue Apr 08 20:07:18.697 2014] Data Size: 11179 Bytes = 10.9 KiB
[Tue Apr 08 20:07:18.697 2014] Architecture: ARM
[Tue Apr 08 20:07:18.697 2014] Hash algo: crc32
[Tue Apr 08 20:07:18.697 2014] Hash value: a7a92b47
[Tue Apr 08 20:07:18.697 2014] Hash algo: sha1sha1+ OK
[Tue Apr 08 20:07:18.702 2014] Booting using the fdt blob at 0x111d344
[Tue Apr 08 20:07:18.702 2014] UncomprOK
[Tue Apr 08 20:07:18.702 2014] Loading Device Tree to 07ffa000, end 07fffbaa ... OK
[Tue Apr 08 20:07:18.702 2014]
[Tue Apr 08 20:07:18.702 2014] Starting kernel ...
[Tue Apr 08 20:07:18.702 2014]
[Tue Apr 08 20:07:19.453 2014] u @c0a7b000 s5568 r8192 d14912 u32768
[Tue Apr 08 20:07:19.453 2014] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260096
[Tue Apr 08 20:07:19.453 2014] Kernel command line: root=mtd:jffs2 rw rootfstype=jffs2 console=ttyPS0,115200
[Tue Apr 08 20:07:19.453 2014] PID hash table entries: 4096 (order: 2, 16384 bytes)
[Tue Apr 08 20:07:19.453 2014] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[Tue Apr 08 20:07:19.453 2014] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[Tue Apr 08 20:07:19.453 2014] __ex_table already sorted, skipping sort
[Tue Apr 08 20:07:19.453 2014] Memory: 1024MB = 1024MB total
[Tue Apr 08 20:07:19.453 2014] Memory: 1036960k/1036960k available, 11616k reserved, 270339 16
[Tue Apr 08 20:07:19.625 2014] I reach build/linux/kernel/xlnx-3.8/source/net/socket.c:
[Tue Apr 08 20:07:19.625 2014] DMA: preallocated 256 KiB pool for atomic coherent allocations
[Tue Apr 08 20:07:19.625 2014] xgpiops e000a000.ps7-gpio: gpio at 0xe000a000 mapped to 0xf004e000
[Tue Apr 08 20:07:19.625 2014] GPIO IRQ not connected
[Tue Apr 08 20:07:19.625 2014] XGpio: /amba@0/gpio@41220000: registered, base is 255
[Tue Apr 08 20:07:19.625 2014] GPIO IRQ not connected
[Tue Apr 08 20:07:19.625 2014] XGpio: /amba@0/gpio@41200000: registered, base is 251
[Tue Apr 08 20:07:19.625 2014] usbcore: registered new interface driver usbfs
[Tue Apr 08 20:07:19.625 2014] usbcore: registered new interface driver hub
[Tue Apr 08 20:07:19.625 2014] usbcore: registered new device driver usb
[Tue Apr 08 20:07:19.625 2014] Switching to clocksoutyPS0 at MMIO 0xe0001000 (irq = 82) is a xuartps
[Tue Apr 08 20:07:19.629 2014] console [ttyPSxusbps-ehci xusbps-ehci.0: irq 53, io mem 0x00000000
[Tue Apr 08 20:07:19.670 2014] xusbps-ehci xusbps-ehci.0: USB 2.0 started, EHCI 1.00
[Tue Apr 08 20:07:19.675 2014] hub 1-0:1.0: USB hub found
[Tue Apr 08 20:07:19.675 2014] hub 1-0:1.0: 1 port detected
[Tue Apr 08 20:07:19.681 2014] xi2cps e0004000.ps7-i2c: 400 kHz mmio e0004000 irq 57
[Tue Apr 08 20:07:19.686 2014] xadcps f8007100.ps7-xadc: enabled: yes reference: external
[Tue Apr 08 20:07:19.709 2014] xwdtps f8005000.ps7-wdt: Xilinx Watchdog Timer at f00ea000 with timeout 10s
[Tue Apr 08 20:07:19.709 2014] sdhci: Secure Digital Host Controller Interface driver
[Tue Apr 08 20:07:19.709 2014] sdhci: Copyright(c) Pierre Ossman
[Tue Apr 08 20:07:19.709 2014] sdhci-pltfm: SDHCI platform and OF driver helper
[Tue Apr 08 20:07:19.729 2014] usbcore: registered new interface driver usbhid
[Tue Apr 08 20:07:19.729 2014] usbhid: USB HID core driver
[Tue Apr 08 20:07:19.729 2014] I am at build/linux/kernel/xlnx-3.8/source/drivers/hid/usbhid/hid-core.c
[Tue Apr 08 20:07:19.729 2014] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[Tue Apr 08 20:07:19.781 2014] MTD: MTD device with name "jffs2" not found.
[Tue Apr 08 20:07:19.781 2014] List of all partitions:
[Tue Apr 08 20:07:19.781 2014] No filesystem could mount root, tried: jffs2
[Tue Apr 08 20:07:19.781 2014] Kernel panic - not syncing: VFS: Unable to mount root fs on mtd:jffs2
[Tue Apr 08 20:07:19.781 2014] CPU1: stopping
[Tue Apr 08 20:07:19.781 2014] Backtrace:
[Tue Apr 08 20:07:19.781 2014] Function entered at [<c0011094>] from [<c01c6408>]
[Tue Apr 08 20:07:19.781 2014] r6:c0246418 r5:00000000 r4:00000001 r3:60000193
[Tue Apr 08 20:07:19.781 2014] Function entered at [<c01c63f0>] from [<c0011fbc>]
[Tue Apr 08 20:07:19.781 2014] Function entered at [<c0011f78>] from [<c0012270>]
[Tue Apr 08 20:07:19.781 2014] r4:c0247ef4 r3:c0011f78
[Tue Apr 08 20:07:19.781 2014] Function entered at [<c001220c>] from [<c00084e4>]
[Tue Apr 08 20:07:19.781 2014] r5:ef07bf68 r4:f8f00100
[Tue Apr 08 20:07:19.824 2014] Function entered at [<c0008484>] from [<c000da00>]
[Tue Apr 08 20:07:19.824 2014] Exception stack(0xef07bf68 to 0xef07bfb0)
[Tue Apr 08 20:07:19.824 2014] bf60: c0a838d0 00000000 00000003 00000000 ef07a000 c01cd528
[Tue Apr 08 20:07:19.824 2014] bf80: ef07a000 c025c418 0000406a 413fc090 00000000 ef07bfbc ef07bfc0 ef07bfb0
[Tue Apr 08 20:07:19.824 2014] bfa0: c000e94c c000e950 60000113 ffffffff
[Tue Apr 08 20:07:19.824 2014] r6:ffffffff r5:60000113 r4:c000e950 r3:c000e94c
[Tue Apr 08 20:07:19.824 2014] Function entered at [<c000e924>] from [<c000eacc>]
[Tue Apr 08 20:07:19.824 2014] Function entered at [<c000ea40>] from [<c01c4208>]
[Tue Apr 08 20:07:19.824 2014] r5:00000001 r4:c024cf68
[Tue Apr 08 20:07:19.824 2014] Function entered at [<c01c4118>] from [<001c37c8>]
[Tue Apr 08 20:07:19.844 2014] r6:10c03c7d r5:00000015 r4:2f06406a r3:c01c37b0
[Tue Apr 08 20:07:19.844 2014] MTD: MTD device with name "jffs2" not found.
[Tue Apr 08 20:07:19.844 2014] List of all partitions:
[Tue Apr 08 20:07:19.844 2014] No filesystem could mount root, tried: jffs2
[Tue Apr 08 20:07:19.844 2014] Kernel panic - not syncing: VFS: Unable to mount root fs on mtd:
Run Code Online (Sandbox Code Playgroud)
我正在从闪存启动。
现在从日志中可以很明显地看出,即使文件系统加载失败,许多驱动程序已经加载(因为我故意没有将文件系统 rootfs.jffs2 放在 flash 中)。
现在参考上面的评论,如果在linux中一切都是文件,那么驱动程序如何成功加载?你可以看到 USB、GPIO、SD 一切都在它要求文件系统(并且失败)之前到来了。
那么这样说在技术上是否正确
linux必须有一个文件系统
一些背景 我试图实现的是让 linux 在将运行控制应用程序的系统上运行。该应用程序只是捕获一些数据并将其发送给一些从站。根本不存在存储数据的问题。所以想彻底摆脱文件系统。根据我的理解,存储数据需要文件系统,并且由于我不会存储任何数据,所以为什么要使用文件系统并增加资源使用量?
更新
虽然我在后台有提到过,但具体来说,数据的发送是使用USB或以太网进行的,所以自然有相应的驱动程序。
War*_*ung 15
如果你需要 Linux,你需要一个文件系统。
(我的意思是这里的操作系统是 Linux,而不是操作系统内核的 Linux。我将在下面进行更狭义的解释。)
您对在文件系统存在之前启动时加载的设备驱动程序的观察是一个红鲱鱼。您可以在没有文件系统的情况下加载驱动程序。你不能做的是fd = open("/dev/foo", O_RDONLY)没有文件系统。
这并不意味着您需要使用传统文件系统格式化的持久可重写存储介质,就像您的 JFFS2 示例一样。所有你需要支持传统的/dev树是一种数据结构,是的行为像一个磁盘上的文件系统。例如,现代 Linux在内存文件系统上使用udev以允许访问/dev节点,而无需节点的持久存储/dev。
您还需要一个文件系统来使用 Linux-the-OS 的其他几个功能:
需要共享库或脚本语言模块吗?你需要一个文件系统来存储/lib/libfoo.*,/usr/lib/perl5/*,/lib/ld.so,/etc/ld.so.cache,等。
需要可加载的内核模块?你需要一个文件系统/lib/modules/$(uname -r)/*
需要多个可执行文件,例如 shell 或文本编辑器?他们需要一个文件系统来生存。
需要内核来强制执行访问控制吗?其中大部分是通过某个文件或目录上的权限位、ACL和SELinux 标签完成的。
我可能会想出更多的例子,但这也行。
可以将系统所需的所有资源从持久存储加载到 RAM 中,这样一旦启动,系统就根本不使用持久存储。Live Linux 发行版就是这样做的。嵌入式 Linux 操作系统在启动时在 RAM 中构建其整个文件系统也很常见,因此一旦启动,它们就不再继续引用诸如闪存设备之类的持久存储。
如果您正在构建一个范围狭窄的单一用途单任务嵌入式系统,您可能不需要 Linux-the-OS。您可能只需要一个较小的、功能较少的嵌入式操作系统,或者您可以直接写入金属。
这里的其他一些答案谈到将 Linux 剥离到只剩下 Linux-the-kernel 的地步,要么与单个可执行文件配对——你的程序,在内核下运行——或者作为一个整体程序运行您的代码静态合并在其中。无论哪种方式,您都可以完全摆脱对文件系统的需求,但最终得到的不再是 Linux-the-OS。
我写了一个相关问题的答案,其中详细说明了文件的概念如何成为 Unix 工作方式的核心,并且由于没有某种文件系统就无法拥有文件,这意味着您肯定需要一个。
然而,如果没有任何持久存储介质上存在的文件系统,它也可以继续存在。您的initramfs映像可以编译到内核本身(或以其他方式放置在引导加载程序可以访问它的地方)。从技术上讲,写入存储介质的映像是存档而不是文件系统;它只有在加载后才会变成这样。如果你把你需要的所有二进制文件都放在里面,就没有必要把它们放在存储介质上的文件系统中。这样,您可以确保系统运行所需的所有必要文件系统完全存在于内存中。
当然,缺点是因为系统需要的所有东西都必须存在于内存中,你可能会发现你没有足够的东西来做你想做的事。此外,您将很难写入任何要在重新启动后保留的数据。
小智 5
实际上,从技术上讲,您不需要文件系统。默认行为是拥有一个从中引导的文件系统。(例如/sbin/init从那里启动)。但是,如果你喜欢,你可以看看会发生什么do_basic_setup()的linux-source/init/main.c。到该例程被调用时,内核和 CPU0 已准备好进行实际工作。您可以粉碎启动 initramfs 所需的所有工作——它也是一个文件系统!- 以及之后的任何内容,并用您自己的代码替换它以在没有文件系统的情况下工作。
然后,您可以使用内核线程来生成您想要的任何进程。然而,这一切都将是超级丑陋的。
小智 -3
不,Linux 并不需要严格意义上的文件系统。在你的情况下,你有一个不同的问题。
“没有文件系统可以挂载 root,已尝试:jffs2”“MTD:未找到名为“jffs2”的 MTD 设备。”
我的猜测是加载过程的某些部分要么没有找到安装的位置,要么没有能力安装该文件系统。
| 归档时间: |
|
| 查看次数: |
1170 次 |
| 最近记录: |