How to mount an image file so its checksum doesn't change?

Moderator: BarryK

Post Reply
User avatar
BarryK
Posts: 2264
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 93 times
Been thanked: 561 times

How to mount an image file so its checksum doesn't change?

Post by BarryK »

A couple of people have reported this problem.

Easy is an image file, and right now I am uploading 'easy-4.2-amd64.img'
it has two partition in it, a 7MiB fat12 and a 816MiB ext4 (without a journal).

Easy has a utility that will automatically mount the partitions of any image file, /usr/sbin/mount-img
Attached, with a false ".gz" appended.

mount-img should work in any pup that has ROX-Filer. I have made a change, it uses 'popup', a utility in Easy, but I put in a test so will fallback to using 'xmessage' if popup doesn't exist.

So if you do this in a terminal, two rox windows will appear:

Code: Select all

# mount-img easy-4.2-amd64.img

Run it again to umount:

Code: Select all

# mount-img

The problem is, if mount, then unmount, without doing anything, the checksum of the file has changed.
If put in "-o ro" for the mount operation, mounting the partitions read-only, the checksum is still changed.

I would like to put the question out there, is there some way to mount and unmount such that the checksum is unchanged?

In my case, I am using md5sum.

I have also attached /usr/local/easy_version/easy-update from the latest Easy. This can be used to update an existing installation of Easy to 4.2.

As a workaround to the checksum getting changed, easy-update will download 'easy-4.2-amd64.img' and immediately make a copy 'easy-4.2-amd64.imgPRISTINE'

That latter file can be kept, as I have put in place code in easy-update to download "xdelta" file when next do a version update. There will be difference-file only, the difference between 4.2 and 4.3, that will be downloaded, then applied to easy-4.2-amd64.imgPRISTINE to generate easy-4.3-amd64.imgPRISTINE

It's a woraround, would be happier if could find out how to mount and unmount the partitions without changing anything in the file.

Attachments
easy-update.gz
/usr/local/easy_version remove the false .gz
(22.36 KiB) Downloaded 34 times
mount-img.gz
/usr/sbin remove the false .gz
(2.72 KiB) Downloaded 32 times
User avatar
BarryK
Posts: 2264
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 93 times
Been thanked: 561 times

Re: How to mount an image file so its checksum doesn't change?

Post by BarryK »

Have been googling, found this:

https://linux.die.net/man/8/mount

-r, --read-only
Mount the filesystem read-only. A synonym is -o ro.

Note that, depending on the filesystem type, state and kernel behavior, the system may still write to the device. For example, Ext3 or ext4 will replay its journal if the filesystem is dirty. To prevent this kind of write access, you may want to mount ext3 or ext4 filesystem with "ro,noload" mount options or set the block device to read-only mode, see command blockdev(8).

On my baby laptop right now. Will try "-o ro,noload" later. But, it may only apply to ext4 with a journal, and my partition does not have a journal.

User avatar
JakeSFR
Posts: 254
Joined: Wed Jul 15, 2020 2:23 pm
Been thanked: 124 times

Re: How to mount an image file so its checksum doesn't change?

Post by JakeSFR »

BarryK wrote: Sat Jun 25, 2022 9:14 am

Will try "-o ro,noload" later. But, it may only apply to ext4 with a journal, and my partition does not have a journal.

You may also want to try losetup with '-r Read-only' option (if available) as a middleman.

Greetings!

[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
User avatar
BarryK
Posts: 2264
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 93 times
Been thanked: 561 times

Re: How to mount an image file so its checksum doesn't change?

Post by BarryK »

This has some options that may do the trick:

https://linux.die.net/man/8/blockdev

Note, The Easy 4.2 image file is uncompressed and is a whopping 825MiB, so you can see why I want smaller downloads when doing an update.

Want to open up the image file and copy out the new 'vmlinuz', 'initrd' and 'easy.sfs', then unmount, leaving checksum of the image file unchanged.

Then, at the next update, can just download a "difference file".
Using the 'xdelta3' utility to create the difference-file and then generate the new image file, having as input the previous image-file and the difference-file.

User avatar
BarryK
Posts: 2264
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 93 times
Been thanked: 561 times

Re: How to mount an image file so its checksum doesn't change?

Post by BarryK »

Fixed! See attached.

It defaults to mounting read-only. If you want to mount read-write, have to explicitly pass in "rw". Optionally also can pass in "quiet" and won't popup any messages nor run rox. Ex:

Code: Select all

# mount-img easy-4.2-amd64.img quiet rw
Attachments
mount-img.gz
remove false .gz
(2.93 KiB) Downloaded 72 times
Post Reply

Return to “EasyOS”