写入/ dev / loop USB映像?

时间:2015-10-29 11:00:25

标签: image loops usb

我有一张我写入可启动USB的图像,我需要调整它。我已经成功地将棒安装为/ dev / loopX,包括允许分区起始偏移量,我可以从中读取文件。然而,回写“似乎工作”(没有报告错误)但在将生成的调整后的图像写入USB驱动器后,我无法再正确读取调整后的文件。 失败的文件很大,也是压缩的tarfile。 以这种方式写回来只是一个“不 - 不”或有什么方法可以使这项工作? 如果可能的话,我不想重新格式化分区并从头开始重写,因为这会(我假设)更改UUID,然后我需要担心启动分区等。

1 个答案:

答案 0 :(得分:0)

I believe I have the answer. When using losetup to create a writeable virtual device from the partition on your USB drive, you must specify the --sizelimit parameter as well as the offset parameter. If you don't then the resulting writes can go past the last defined sector on the partition (presumably requires your USB drive to have extra space). Linux reports no errors until later when you try to read. The key hints/evidence for this are that when reads (or (re)written data) fail, dmesg shows read errors attempting to read past the end of the drive. fsck tools such as dosfsck also indicate that the drive claims to be larger than it is.