linux-kernel – 在运行时调整MTD分区大小
我正在使用嵌入式设备,并希望能够通过
Linux调整其MTD分区大小而无需重新启动.
问题是我的Linux映像大小已经增加,它所在的当前MTD分区(mtd0)现在太小了.但是,它之后的分区(mtd1)是用于存储配置信息的JFFS2部分,因此重新调整大小不是一个选项,因为配置可能会丢失. 我的目标是: 1. Copy contents of JFFS2 into /tmp/ 2. Unmount JFFS2 from mtd1 3. Increase the starting offset + reduce size of mtd1 by X bytes (or delete mtd1 and create new mtd of proper size and offset) 4. Mount JFFS2 on new mtd1 and restore contents from /tmp/ 5. Increase the size of mtd0 by X bytes 6. Burn new (larger) Linux image into mtd0 (the new image will contain a device tree with an updated partition structure) 7. Reboot 几年前我找到了“mtd-utils”的补丁: http://article.gmane.org/gmane.linux.drivers.mtd/30949 http://article.gmane.org/gmane.linux.drivers.mtd/30950 http://article.gmane.org/gmane.linux.drivers.mtd/30951 以此为指导,我能够编写内核和用户空间代码来创建一个新的MTD分区,我可以在其上安装JFFS2.但是,此代码无法正确删除分区.即使从mtd1卸载JFFS2并调用put_mtd_device,当调用del_mtd_device时,内核会抱怨: user.notice kernel: Removing MTD device #1 (jffs2) with use count 1 我想知道的是: 1. How to fix the patch to allow deleting my old mtd1 2. How to change the starting offset of mtd1 instead of creating/deleting partitions 我尝试联系该补丁的作者,但他们的电子邮件不再有效,所以我将不胜感激任何建议! 更新: 似乎mtdchar.c中的mtd_open()触发了get_mtd_device(),这可能会占用额外的usecount增量.但我的用户空间应用程序需要调用分区上的open()来发送一个ioctl()来删除分区:/ catch 22?有没有更正确的方法呢? 解决方法
我最后通过修补mtd实用程序增加“mtd0”大小来解决这个问题,然后创建一个正确缩小大小的全新分区来安装JFFS,这让我有机会将配置信息复制到新的flash位置.
为了降低复杂性,我也做到了这一点,因此我无法多次运行此应用程序.它最终是一个“运行一次,做你的事,重新启动”类型的程序. 更新: 这是我的代码,认为它可以使一些人受益: https://github.com/mikzat/mtd_runtime_partition (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |