2

With FAT32 images, copying files to an unmounted image is possible with the mcopy command:

mcopy -v -i [image file] -s [files to copy] ::/

However, this is not possible with an ext4-based image file. Is there an equivalent command to achieve the same result for an ext4-based image file? Mounting is not an option due to the image build tool (Yocto) being used not having sudo access.

Ozmydis
  • 53
  • 4
  • Please [edit] your question and add more details about your image build tool, what exactly it does and the location of the image file. Did you try adding a user-mountable `fstab` entry? – Bodo Feb 15 '23 at 12:46
  • @Bodo The build tool is Yocto. The aim is to create an image which can be written to the partition of another image, achieved through a custom image bbclass file. I don't think this information is too relevant though and overcomplicates the question, as I just want to know whether there is an alternative command to mcopy for ext4. – Ozmydis Feb 15 '23 at 13:37
  • You could probably make a similar tool using `libext2fs` from [E2fsprogs](https://e2fsprogs.sourceforge.net/) if one doesn't already exist. Perhaps the code in `misc/` like the FUSE server, or `create_inode.c` (`do_write_internal`) used by `mke2fs` to populate the filesystem might be a good reference (it seems to even have efficient support for copying sparse files). If you're creating the image to begin with, you could just let `mke2fs` do the work for you, though. – Hasturkun Feb 15 '23 at 13:40
  • 1
    The fact that nobody wrote an answer pointing to a tool you asked for seems to indicate that the answer to your question might be NO. Your question looks like an [XY problem](https://xyproblem.info/). If you add detailed information to your question about the problem you want to solve, someone might come up with an alternative solution. Why is granting limited `sudo` permissions to the user running Yocto not an option? The access could be limited to the specific commands needed for mounting the image file. – Bodo Feb 15 '23 at 16:39

0 Answers0