23

It looks like mount -o loop changes the mounted image file. I downloaded the ISO image file and checked its SHA-1 checksum. Then I mounted that ISO file and the checksum changed. Here are the exact steps I made, a copy-paste from my console, CentOS 7 x64 (note, that ISO file is read-only):

[mbartnicki@89-78-33-81 Downloads]$ ls -lh
total 3.1G
-r--r--r--. 1 mbartnicki mbartnicki 3.1G Mar 31 18:28 X17-58997.iso
[mbartnicki@89-78-33-81 Downloads]$ sha1sum X17-58997.iso 
6c9058389c1e2e5122b7c933275f963edf1c07b9  X17-58997.iso
[mbartnicki@89-78-33-81 Downloads]$ sudo mount -o loop X17-58997.iso /mnt/iso/
mount: /dev/loop0 is write-protected, mounting read-only
[mbartnicki@89-78-33-81 Downloads]$ sha1sum X17-58997.iso 
994944df320e9e03c032263d7b9e36157a0a587c  X17-58997.iso

I was so surprised, that I repeated above steps on another machine (Ubuntu 14.04 x64), just to get the same result: file checksum changed after mount -o loop. Unmounting ISO image doesn't return its checksum to original value; file change is persistent. Moreover, next mount change the checksum again to some new value. How can it be explained?

PS

Mounting explicitly read-only by adding ro mount option prevents file from being changed, so that if I use:

sudo mount -o ro,loop X17-58997.iso /mnt/iso

then everything is OK, and ISO image file lasts unchanged after mount. The wrong behaviour occurs only when ro option is not specified, even if the ISO image file is read-only on the file system level. I tried on three different ISO images: Windows 7 installation DVD (official), SystemRescueCD (small rescue Linux) and hand-made ISO created by genisoimage tool.

I checked all that ISO files with file utility, and file said that all of them are ISO 9660 CD-ROM filesystem data. Files inside ISO images are not changed - I also checked it - it looks like the faulty mount scenario adds some meta-data or just garbage.

  • What is the sha1sum after unmounting? – Volker Siegel Aug 10 '14 at 01:13
  • Can you try with an empty iso image, created by `genisoimage -o empty.iso emptydir`? – Volker Siegel Aug 10 '14 at 01:15
  • can you try making new loop device and try to mount the `iso` to it? You can use `mknod -m 660 /dev/loop1 b 7 1` also after run `chmod 660 /dev/loop*` – Simply_Me Aug 10 '14 at 01:16
  • @VolkerSiegel unmounting doesn't return previous checksum. File is changed for good. But thanks for pointing this out, I 'm going to edit my question to include this information. –  Aug 10 '14 at 01:20
  • All really strange... Does mounting it again change it again? – Volker Siegel Aug 10 '14 at 01:24
  • @VolkerSiegel yes, I also noted it in my edit. –  Aug 10 '14 at 01:29
  • Because it looks like a bug - anything relevant in `/var/log/syslog` or `/var/log/kern.log`? Can you try other iso files? – Volker Siegel Aug 10 '14 at 01:32
  • 3
    Similar bug report at launchpad: [mount -o loop.... changes the udf image](https://bugs.launchpad.net/ubuntu/+source/kernel-package/+bug/1277146) – Volker Siegel Aug 10 '14 at 01:42
  • I added a link to this question to the launchpad bug. – Volker Siegel Aug 10 '14 at 01:50
  • QUESTION: What happens if you EXPLICITLY mount the ISO as read-only using the 'ro' option parameter on the mount command? – mdpc Aug 10 '14 at 04:14
  • @goldilocks I see... so I'll post this solution to the bug report I linked. To me, part of the confusion is from the expectation that an iso image should behave the same like a CD - not change. – Volker Siegel Aug 10 '14 at 12:12
  • It does not apply to the iso9660 Linux driver, but it's interesting to note that some lower level modifications are still possible in other cases. See the [--read only](http://man7.org/linux/man-pages/man8/mount.8.html#COMMAND_LINE%20OPTIONS) option in the manpages. –  Aug 10 '14 at 22:09

1 Answers1

1

Iso isn't synonym for read only, under some circunstances, you may wish to mount an iso read/write (when creating a boot media).

If you want read only, use option

 mount -o ro,iso
Archemar
  • 31,183
  • 18
  • 69
  • 104
  • 3
    My ISO file was read-only by file system permissions, and it was mounted read-only as stated in the mount output. –  Aug 10 '14 at 08:12