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.

12
  • What is the sha1sum after unmounting? Aug 10, 2014 at 1:13
  • Can you try with an empty iso image, created by genisoimage -o empty.iso emptydir? Aug 10, 2014 at 1: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, 2014 at 1: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.
    – user77422
    Aug 10, 2014 at 1:20
  • 3
    Similar bug report at launchpad: mount -o loop.... changes the udf image Aug 10, 2014 at 1:42

1 Answer 1

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
1
  • 3
    My ISO file was read-only by file system permissions, and it was mounted read-only as stated in the mount output.
    – user77422
    Aug 10, 2014 at 8:12

You must log in to answer this question.