基于Linux的Firmware,如何实现良好的更新方式?
我正在使用 alix 2d13 开发基于 Linux 的设备。
我开发了一个脚本,负责创建映像文件、创建分区、安装引导加载程序(syslinux)、内核和 initrd,并且负责将根文件系统文件放入正确的分区。
配置文件位于 tmpfs 文件系统上,并在系统启动时由读取驻留在自己分区上的 XML 文件的软件创建。
我正在寻找一种更新文件系统的方法,我考虑了两种解决方案:
- 固件更新是一个压缩文件,可以包含内核、initrd 和/或 rootfs 分区,这样,在重新启动时,initrd 将负责将 rootfs 映像添加到右侧分区;
- 固件更新是一个压缩文件,可能包含两个 tar 存档,一个用于引导,一个用于根文件系统。
每个解决方案都有其自身的优点: - 文件系统映像可以让我删除任何未使用的文件,但需要大量时间,并且会快速耗尽紧凑型闪存; - 存档较小,更新需要的时间较少,但我会在短时间内在根文件系统上拥有caos。
另一种解决方案是将文件列表放入 tar 存档中,并将更新前/更新后脚本放入 tar 存档中,这样任何不驻留在文件列表中的文件都将被删除。
你怎么认为?
I'm developing a linux-based appliance using an alix 2d13.
I've developed a script that takes care of creating an image file, creating the partitions, installing the boot loader (syslinux), the kernel and the initrd and, that takes care to put root filesystem files into the right partition.
Configuration files are on tmpfs filesystem and gets created on system startup by a software that reads an XML file that resides on an own partition.
I'm looking a way to update the filesystem and i've considered two solutions:
- the firmware update is a compressed file that could contain kernel, initrd and/or the rootfs partition, in this way, on reboot, initrd will takes care to dd the rootfs image to the right partition;
- the firmware update is a compressed file that could contain two tar archives, one for the boot and one for the root filesystem.
Every solution has its own advantages:
- a filesystem image will let me to delete any unused files but needs a lot of time and it will kill the compact flash memory fastly;
- an archive is smaller, needs less time for update, but i'll have the caos on the root filesystem in short time.
An alternative solution could be to put a file list and to put a pre/post update script into the tar archive, so any file that doesn't reside into the file list will be deleted.
What do you think?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用了以下方法。它在某种程度上基于论文“构建 Murphy 兼容的嵌入式 Linux 系统”,可用 此处。我使用了该论文中描述的 versions.conf 内容,而不是 cfgsh 内容。
I used the following approach. It was somewhat based on the paper "Building Murphy-compatible embedded Linux systems," available here. I used the versions.conf stuff described in that paper, not the cfgsh stuff.
您可以有一个单独的分区用于更新(例如 Side1/Side2)。
现有的内核,rootfs在Side1,然后将更新放在Side2并切换。
通过这种方式,您可以减少磨损均衡并延长使用寿命,但设备会变得更加昂贵。
You can have a seperate partition for update(Say Side1/Side2).
The existing kernel,rootfs is in Side1, then put the update in Side2 and switch.
By this you can reduce wear leveling and increase the life but the device gets costlier.
您可以在提取 tar 文件之前快速格式化分区。或者使用图像解决方案,但使用尽可能小的图像,并在 dd 之后调整文件系统大小(尽管这对于只读存储不是必需的)
You can quick format the partitions before extracting the tar files. Or go with the image solution but use the smallest possible image and after dd do a filesystem resize (although that is not necessary for readonly storage)