简体   繁体   English

我应该在嵌入式系统上使用ext3吗?

[英]Should I fsck ext3 on embedded system?

We have a number of embedded systems requiring r/w access to the filesystem which resides on flash storage with block device emulation. 我们有许多嵌入式系统需要对文件系统进行r / w访问,该文件系统驻留在具有块设备仿真的闪存存储器上。 Our oldest platform runs on compact flash and these systems have been in use for over 3 years without a single fsck being run during bootup and so far we have no failures attributed to the filesystem or CF. 我们最古老的平台运行在紧凑型闪存上,这些系统已经使用了3年以上,在启动过程中没有运行单个fsck,到目前为止我们没有归因于文件系统或CF的故障。

On our newest platform we used USB-flash for the initial production and are now migrating to Disk-on-Module for r/w storage. 在我们的最新平台上,我们使用USB闪存进行初始生产,现在正在迁移到磁盘模块以进行硬件存储。 A while back we had some issues with the filesystem on a lot of the devices running on USB-storage so I enabled e2fsck in order to see if that would help. 前段时间我们在USB存储器上运行的很多设备上遇到了一些文件系统问题,所以我启用了e2fsck以查看是否有帮助。 As it turned out we had received a shipment of bad flash memories so once those were replaced the problem went away. 事实证明,我们收到了一批不良闪存,因此一旦被更换,问题就会消失。 I have since disabled e2fsck since we had no indication that it made the system any more reliable and historically we have been fine without it. 我已经禁用了e2fsck,因为我们没有迹象表明它使系统更加可靠,而且从历史上看,我们没有它就没事了。

Now that we have started putting in Disk-on-Module units I've started seeing filesystem errors again. 现在我们已经开始使用Disk-on-Module单元,我已经开始再次看到文件系统错误。 Suddenly the system is unable to read/write certain files and if I try to access the file from the emergency console I just get " Input/output error ". 突然,系统无法读取/写入某些文件,如果我尝试从紧急控制台访问该文件,我只会收到“ 输入/输出错误 ”。 I enabled e2fsck again and all the files were corrected. 我再次启用了e2fsck并且所有文件都已更正。

O'Reilly's " Building Embedded Linux Systems " recommends running e2fsck on ext2 filesystems but does not mention it in relation to ext3 so I'm a bit confused to whether I should enable it or not. O'Reilly的“ 构建嵌入式Linux系统 ”建议在ext2文件系统上运行e2fsck但是没有提到它与ext3有关,所以我对是否应该启用它有点困惑。

What are your takes on running fsck on an embedded system? 在嵌入式系统上运行fsck有什么需要? We are considering putting binaries on ar/o partition and only the files which has to be modified on ar/w partition on the same flash device so that fsck can never accidentally delete important system binaries, does anyone have any experience with that kind of setup (good/bad)? 我们正在考虑将二进制文件放在ar / o分区上,只考虑在同一个闪存设备上的ar / w分区上必须修改的文件,以便fsck永远不会意外删除重要的系统二进制文件,是否有人对这种设置有任何经验(好坏)?

I think the answer to your question more relates to what types of coherency requirements you application has relative to its data. 我认为您的问题的答案更多地涉及您应用程序相对于其数据的一致性要求类型。 That is, what has to be guaranteed if power is lost without a formal shutdown of the system? 也就是说,如果在没有正式关闭系统的情况下断电,必须保证什么? In general, none of the desktop operating system type file systems handle this all that well without specific application closing/syncing of files and flushing of the disk caches, etc. at key transaction points in the application to ensure what you need to maintain is in fact committed to the media. 通常,如果没有特定的应用程序关闭/同步文件以及在应用程序中的关键事务点刷新磁盘缓存等,桌面操作系统类型文件系统都不能很好地处理这一点,以确保您需要维护的是事实致力于媒体。

Running fsck fixes the file-system but without the above care, there is no guarantees about what changes you made will actually be kept. 运行fsck会修复文件系统,但如果没有上述保护,则无法保证实际保留的更改。 ie: It's not exactly deterministic what you'll lose as a result of the power failure. 即:由于电源故障,您将失去什么并不完全确定。

I agree that putting your binaries or other important read-only data on a separate read-only partition does help ensure that they can't erroneously get tossed due to an fsck correction to file-system structures. 我同意将二进制文件或其他重要的只读数据放在一个单独的只读分区上确实有助于确保它们不会因文件系统结构的fsck更正而被错误地抛出。 As a minimum, putting them in a different sub-directory off the root than where the R/W data is held will help. 至少,将它们放在根目录下不同于R / W数据所在的子目录中会有所帮助。 But in both cases, if you support software updates, you still need to have scheme to deal with writing the "read-only" areas anyway. 但在这两种情况下,如果您支持软件更新,您仍然需要有计划来处理编写“只读”区域。

In our application, we actually maintain a pair of directories for things like binaries and the system is setup to boot from either one of the two areas. 在我们的应用程序中,我们实际上为二进制文件维护了一对目录,系统设置为从两个区域中的任何一个启动。 During software updates, we update the first directory, sync everything to the media and verify the MD5 checksums on disk before moving onto the second copy's update. 在软件更新期间,我们更新第一个目录,将所有内容同步到介质并验证磁盘上的MD5校验和,然后再转到第二个副本的更新。 During boot, they are only used if the MD5 checksum is good. 在引导期间,仅在MD5校验和良好时才使用它们。 This ensures that you are booting a coherent image always. 这可确保您始终启动连贯的图像。

Dave, 戴夫,

I always recommend running the fsck after a number of reboots, but not every time. 我总是建议在重新启动后运行fsck,但不是每次都重新启动。

The reason is that, the ext3 is journal-ed. 原因是,ext3是期刊。 So unless you enable the writeback (journal-less), then most of the time, your metadata/file-system table should be in sync with your data (files). 因此,除非您启用回写(无日记),否则大多数情况下,您的元数据/文件系统表应与您的数据(文件)保持同步。

But like Jeff mentioned, it doesn't guarantee the layer above the file-system. 但是像杰夫提到的那样,它并不能保证文件系统上面的层。 It means, you still get "corrupted" files, because some of the records probably didn't get written to the file system. 这意味着,您仍然会收到“损坏”的文件,因为某些记录可能无法写入文件系统。

I'm not sure what embedded device you're running on, but how often does it get rebooted? 我不确定你运行的是什么嵌入式设备,但是它经常重启的频率是多少? If it's controlled reboot, you can always do "sync;sync;sync" before restart. 如果它是受控重启,您可以在重启之前始终执行“同步;同步;同步”。

I've been using the CF myself for years, and very rare occasion I got file-system errors. 我自己多年来一直在使用CF,而且我很少遇到文件系统错误。 fsck does help on that case. fsck对这种情况有所帮助。

And about separating your partition, I doubt the advantage of it. 关于分离你的分区,我怀疑它的优势。 For every data/files on the file-system, there's a metadata associated with it. 对于文件系统上的每个数据/文件,都有与之关联的元数据。 Most of the time, if you don't change the files, eg. 大多数情况下,如果您不更改文件,例如。 binary/system files, then this metadata shouldn't change. 二进制/系统文件,那么这个元数据不应该改变。 Unless you have a faulty hardware, like cross-talking write & read, those read-only files should be safe. 除非你有一个错误的硬件,比如串口写和读,否则这些只读文件应该是安全的。

Most problems arises when you have something writable, and regardless where you put this, it can cause problems if the application doesn't handle it well. 当你有可写的东西时会出现大多数问题,无论你把它放在哪里,如果应用程序不能很好地处理它会导致问题。

Hope that helps. 希望有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM