Analysing differences in images produced with mkimg and makefs

Fabian Keil fk at fabiankeil.de
Tue Dec 7 08:29:31 UTC 2021


"Chris Lamb" <lamby at debian.org> wrote on 2021-12-06 at 16:45:25:

> Fabian Keil wrote:
> 
> (Noting the issues you mention with ElectroBSD binaries so will
> proceed using FreeBSD memstick images as you suggest.)

Great.
 
> > You could download a FreeBSD 12.3 memstick image from
> > <https://download.freebsd.org/ftp/snapshots/amd64/amd64/ISO-IMAGES/12.3/>,
> > copy it and modify a couple of bytes in the copy and try to
> > compare them.
> 
> Sure thing. Although instead of modifying a few bytes which might
> damage the file beyond sensible comparison I'm just going to compare
> two pristine FreeBSD memstick images, specifically:
> 
>   $ sha1sum *
>   ff3bac56a48161a175ebe340f2d094f864183c33  FreeBSD-12.3-STABLE-amd64-20211125-r371091-mini-memstick.img
>   842b252835975d21334f55bc93eb88108f4886e6  FreeBSD-13.0-STABLE-amd64-20211111-7647baa1e8f-248036-mini-memstick.img
> 
> However, there seems to be something a little interesting about these
> images. Specifically, whilst this works:
> 
>   $ virt-list-partitions FreeBSD-12.3-STABLE-amd64-20211125-r371091-mini-memstick.img
>   /dev/sda1
>   /dev/sda2
>   /dev/sda5
> 
> ... the following does not:
> 
>   $ virt-list-filesystems FreeBSD-12.3-STABLE-amd64-20211125-r371091-mini-memstick.img           
>   list_filesystems: sfdisk exited with status 1: sfdisk: /dev/sda: partition 5: partition table contains only 4 partitions at /usr/bin/virt-list-filesystems line 166.
> 
> I'm using these two tools as diffoscope's filesystem image support
> uses libguestfs (the library underlying the virt-* tools).

Unfortunately it looks like libguestfs hasn't been ported to FreeBSD
yet, so I can't trivially build and install it on ElectroBSD either
at this time.

It's listed at <https://wiki.freebsd.org/WantedPorts> without
any details that would explain why it hasn't been ported yet.

I've added looking into this to my TODO list.

> Any ideas about what is different about these images? Getting them mountable by
> guestfs first step as I see it.

I suspect that virt-list-partitions gets the "partition" count wrong.

According to gpart the images only have two "slices":

[fk at elektrobier3 ~/scratch/freebsd-12.3]$ sudo mdconfig -o readonly -f FreeBSD-12.3-STABLE-amd64-20211125-r371091-mini-memstick.img 
md0
[fk at elektrobier3 ~/scratch/freebsd-12.3]$ gpart show md0
=>     1  805200  md0  MBR  (393M)
       1    1600    1  efi  (800K)
    1601  803600    2  freebsd  [active]  (392M)

[fk at elektrobier3 ~/scratch/freebsd-12.3]$ ls -l /dev/md0*
crw-r-----  1 root  operator  0x32c 2021-12-07 08:53:21 /dev/md0
crw-r-----  1 root  operator  0x330 2021-12-07 08:53:21 /dev/md0s1
crw-r-----  1 root  operator  0x332 2021-12-07 08:53:21 /dev/md0s2
crw-r-----  1 root  operator  0x337 2021-12-07 08:53:21 /dev/md0s2a

Apparently the memstick images used to have partitions in the past
but in 2018 the creation process got changed and now they have slices.

Apparently I had to adjust image-checksum.sh back then:
<https://www.fabiankeil.de/sourcecode/electrobsd/ElectroBSD-20211130-817fe7d130ce/0223-image-checksum.sh-Adjust-to-deal-with-slices-instead-.diff>

The following FreeBSD commit seems relevant:
<https://svnweb.freebsd.org/base?view=revision&revision=334337>

I suspect the images now contain some "compatibility goo" so
old BIOSes are able to boot from them and it seems conceivable
that the guestfs tools behave similar to an old BIOS and thus
don't "see" the real disk layout.

Fabian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.reproducible-builds.org/pipermail/rb-general/attachments/20211207/38a5c5d1/attachment.sig>


More information about the rb-general mailing list