Analysing differences in images produced with mkimg and makefs

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

"Chris Lamb" <lamby at> 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.)

> > You could download a FreeBSD 12.3 memstick image from
> > <>,
> > 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 <> 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 
[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 back then:

The following FreeBSD commit seems relevant:

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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the rb-general mailing list