最近,对于embedded式项目,我被要求在Linux上模拟Windows XP Embedded的增强型写入filter (EWF)的效果。
特别是,我需要一种EWF:
据我所知,Linux没有类似EWF的function,而且它的磁盘空间也不像Windows那么多(请参阅这个答案) ,但是我的负责人让我调查一些可以为这两个要求提供解决scheme的东西。
目前我正在尝试这个简单的策略 :
任何想法/build议?
我在x86架构上使用了Ext2格式化的分区Debian Lenny(顺便说一句,对于简单的日志/ COW文件系统适合这个任务的任何build议?)。
谢谢。
通过遵循优秀的如何:build立一个只读的Linux系统解决 。
从制作魔法的两个小脚本之一(使用aufs联盟):
ro_mount_point="${rootmnt%/}.ro" rw_mount_point="${rootmnt%/}.rw" # Create mount points for the read-only and read/write layers: mkdir "${ro_mount_point}" "${rw_mount_point}" # Move the already-mounted root filesystem to the ro mount point: mount --move "${rootmnt}" "${ro_mount_point}" # Mount the read/write filesystem: mount -t tmpfs root.rw "${rw_mount_point}" # Mount the union: mount -t aufs -o "dirs=${rw_mount_point}=rw:${ro_mount_point}=ro" root.union "${rootmnt}" # Correct the permissions of /: chmod 755 "${rootmnt}"
结果:系统保护和应用程序可以写他们的东西(在RAM中)。
如果我没有“提交”重新启动,系统上的所有更改将会丢失,但是如果我需要保留永久性的东西,我可以重新挂载分区读写(此时r / w意思是“在磁盘上”而不是“在RAM上” ),执行“提交”并以只读方式重新挂载分区。
脚本非常优雅,通过在GRUB中select正确的标签条目,我也可以在“保护”(用于生产)或“不受保护”(用于开发)模式之间切换。
为了logging, UnionFS是aufs的另一个select,它可以完成许多相同的事情。 stream行的Live Linux发行版KNOPPIX使用UnionFS将只读CDROM文件系统与只读的只读tmpfs文件系统合并。