3

I have an old ext4 disk partition that I have to investigate without disturbing it. So I copied the complete partition to an image file and mounted that image file while continuing my investigation.

Now while I do not write to the mounted filesystem, I do have to mount it with read/write access, because one of the programs makes assumptions on what I intend to do, and requires write access, even though I do not intend to write to it. You know the kind of 'smart' programs.

Now the problem is that, when mounting an ext4 filesystem read/write, the last mount point is written into the filesystem itself, i.e. the mount command changes my image file, including file access time and file modification time. That is annoying for a lot of other reasons. I cannot find an option in mount(8) nor in ext4(5) to avoid this.

Is there another way to mount with read/write access, without the mount command writing to the filesystem?

Paulo Tomé
  • 3,754
  • 6
  • 26
  • 38
db-inf
  • 313
  • 1
  • 7
  • 6
    I don't have enough practical experience with it to properly suggest it, but [OverlayFS](https://en.wikipedia.org/wiki/OverlayFS) could be useful to put a writeable separate layer over your image file. – Ulrich Schwarz Feb 17 '20 at 16:06
  • I don't know about the "write the last mount point" issue, but the `lazytime` option should at least inhibit the on-disk update of `atime/mtime/ctime`. – AdminBee Feb 17 '20 at 16:08
  • This isn’t all that helpful, but on Ext4, the mount point is stored the first time a file is *opened* in a file system, not when the file system is mounted. – Stephen Kitt Feb 18 '20 at 10:20
  • @AdminBee I use the noatime mount option; mtime and ctime won't change as long as I don't create or modify files, I guess. – db-inf Feb 20 '20 at 13:12
  • @StephenKitt Not immediately helpfull, but interesting. – db-inf Feb 20 '20 at 13:13
  • @UlrichSchwarz Good thinking. First I dismissed it, because I do not want to write to the filesystem at all. But now I understand your trick; it just serves to trick that one program into thinking it has a writeable file system. I tested it (with unionfs-fuse instead), and the mountpoint is indeed NOT written to the image file. – db-inf Feb 20 '20 at 13:30

1 Answers1

3

I agree with @UlrichSchwarz mount it read-only, then use overlayFS or unionFS to create a writeable file-system. You can make the writable layer (the bit where the modifications go, disposable, or persistent. Ether way the changes are not stored on the master file-system.

ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102