linux内核mtd分区,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?有没有更正确的方法呢?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值