Identify OS version on a mounted memstick

I have FreeBSD-13.0-RELEASE-i386-memstick.img which I wrote to an USB stick. I also have FreeBSD-13.0-RELEASE-amd64-memstick.img on another, and FreeBSD-12.2-RELEASE-xxx-memstick.img on yet another.
Now, from the comfort of the FreeBSD installed and loaded from my HDD/SSD:
How can I tell that any of those sticks has WHAT version of a FreeBSD installer set on it, and for WHAT architecture?

The UFS volume label is always FreeBSD_install. So that is not going to help.
Mounting the volume and looking at the contents used to provide a README or HARDWARE txt, in which I could find what FreeBSD version it was for. But I no longer see such files on the sticks. I tried looking inside some files under /boot/ and /etc/, but I found nothing to clarify the version/arch of that particular installer set. And my inability to identify something this simple, bugs me.
Yes, I can boot the sticks, one after the other, and then I can tell which one is what release. But, how would I tell without booting them? Just by mounting it.
Suggestions are welcome!
 
Since you have i386 and amd64 versions you can distinguish by that. Simple check on some files from bin with readelf(1) can help (readelf -h /path/to/bin/ls). There is no lib32 under i386 version,etc.
Edit: for simplicity you can even use file(1) instead of readelf.
 
I use self adhesive labels.
adhesive-label-500x500.jpeg
 
For 13.0-RELEASE, mount the ufs partition number 5 on /mnt and run /mnt/bin/freebsd-version

It outputs 13.0-RELEASE

Then ls /mnt/usr/freebsd-dist/lib32.txt will display that filename on amd64, but, (I'm guessing,) an error on i386.
 
How can I tell that any of those sticks has WHAT version of a FreeBSD installer set on it, and for WHAT architecture?
The ABI (Application binary interface) of a binary can be queried. From pkg.conf(5):
Code:
     ABI: string      The ABI of the package you want to install.  Default:
                      derived from the ABI of the /usr/bin/uname binary, if
                      not found then /bin/sh binary.

Mounted USB installer image (12.2-RELEASE):
Code:
# file /mnt/usr/bin/uname
/mnt/usr/bin/uname: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 12.2, FreeBSD-style, stripped

Mounted USB installer image (13.0-RELEASE):
Code:
# file /mnt/usr/bin/uname
/mnt/usr/bin/uname: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.0 (1300139), FreeBSD-style, stripped
 
Bash:
ADDR=$(nm -D /boot/kernel/kernel |grep sccs|cut -f1 -w|tr '[a-f]' '[A-F]');SOF=$(readelf --headers /boot/kernel/kernel |grep " \\.data .*PROGBITS"|cut -w -f5,6|tr '[a-f]' '[A-F]'|tr "\\t" "+");dd if=/boot/kernel/kernel bs=1 count=128 iseek=$(echo -e "ibase=16\n$ADDR-$SOF" |bc) 2>/dev/null|tr -s '\0' '\n'
:) !#$!@#$@
tested on 10 to 13
dumps the sccs string from the file
sccs is generated by newvers.sh at buildtime
 
From 13.0 onward you can look at /etc/os-release:
Code:
NAME=FreeBSD
VERSION=13.0-RELEASE-p5
VERSION_ID=13.0
ID=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="FreeBSD 13.0-RELEASE-p5"
CPE_NAME=cpe:/o:freebsd:freebsd:13.0
HOME_URL=https://FreeBSD.org/
BUG_REPORT_URL=https://bugs.FreeBSD.org/
 
From 13.0 onward you can look at /etc/os-release:
Unfortunately, no such file is present on the 13.0-Release installer memstick.
Interestingly, there is a difference in HOW it is not there, between the i386 and the amd64 sets. The i386 installer memstick has a symlink named os-release in /etc/, pointing to ../var/run/os-release. But, the file being referenced does not exist. The amd64 installer memstick does not contain a /var/run/os-release file either. And it is also missing the /etc/os-release symlink.

I would have spotted something this obvious when I was browsing through the files on the memstick in search of any content to identify the version.
 
Bash:
ADDR=$(nm -D /boot/kernel/kernel |grep sccs|cut -f1 -w|tr '[a-f]' '[A-F]');SOF=$(readelf --headers /boot/kernel/kernel |grep " \\.data .*PROGBITS"|cut -w -f5,6|tr '[a-f]' '[A-F]'|tr "\\t" "+");dd if=/boot/kernel/kernel bs=1 count=128 iseek=$(echo -e "ibase=16\n$ADDR-$SOF" |bc) 2>/dev/null|tr -s '\0' '\n'
I cannot be anything other than completely amazed by people who come up with answers like this.
On my part though, I would rather just boot the installer memstick to see what version it is than ever run a command like the one above, as its complexity kind of beats the point.
Still, well done, covacat!
 
Code:
To    inspect    a system being repaired    using a    live CD:
      mount -rt ufs /dev/ada0p2 /mnt
      env ROOT=/mnt /mnt/bin/freebsd-version -ku
Excellent point. Thanks for bringing this to my attention!
I did not read the freebsd-version(1) manual. Or if I did, I failed to recognize at the time what I was looking at. This is ALMOST as good as I hoped.
Much appreciated!
 
From 13.0 onward you can look at /etc/os-release:
Code:
NAME=FreeBSD
VERSION=13.0-RELEASE-p5
VERSION_ID=13.0
ID=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="FreeBSD 13.0-RELEASE-p5"
CPE_NAME=cpe:/o:freebsd:freebsd:13.0
HOME_URL=https://FreeBSD.org/
BUG_REPORT_URL=https://bugs.FreeBSD.org/
Note this is just a link to /var/run/os-release, which is only valid for the booted kernel.

file /mnt/usr/bin/uname was Golden..tks
 
Nowadays, I keep a file (boot environments.txt) to record boot environment details. To minimise uncertainty.

Code:
root@mowa219-gjp4-zbook-freebsd:~ # bectl mount 1500014-sa-base /tmp/down
/tmp/down
root@mowa219-gjp4-zbook-freebsd:~ #  env ROOT=/tmp/down /tmp/down/bin/freebsd-version -ku
15.0-CURRENT
15.0-CURRENT
root@mowa219-gjp4-zbook-freebsd:~ # env ROOT=/tmp/down /tmp/down/usr/bin/uname -aKU
FreeBSD mowa219-gjp4-zbook-freebsd 15.0-CURRENT FreeBSD 15.0-CURRENT main-n268792-a7b9f4d96e8b GENERIC amd64 1500015 1500014
root@mowa219-gjp4-zbook-freebsd:~ # bectl list -c creation | tail -n 3
1500014-ra-base        -      -          1.11G 2024-03-13 01:19
1500014-sa-base        -      -          1.09G 2024-03-13 13:07
1500015-01-base        NR     /          290G  2024-03-14 01:44
root@mowa219-gjp4-zbook-freebsd:~ # uname -aKU
FreeBSD mowa219-gjp4-zbook-freebsd 15.0-CURRENT FreeBSD 15.0-CURRENT main-n268792-a7b9f4d96e8b GENERIC amd64 1500015 1500015
root@mowa219-gjp4-zbook-freebsd:~ # grep 1500014-sa-base /home/grahamperrin/Documents/boot\ environments.txt
1500014-sa-base                 2024-03-13 13:07 main-n268772-906521f8176b
root@mowa219-gjp4-zbook-freebsd:~ # file /tmp/down/usr/bin/uname
/tmp/down/usr/bin/uname: ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 15.0 (1500014), FreeBSD-style, stripped
root@mowa219-gjp4-zbook-freebsd:~ # bectl umount 1500014-sa-base
root@mowa219-gjp4-zbook-freebsd:~ # file /usr/bin/uname
/usr/bin/uname: ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 15.0 (1500015), FreeBSD-style, stripped
root@mowa219-gjp4-zbook-freebsd:~ #
 
"strings kernel" is just as easy; im my case it was a shell img file with no kernel, so I needed to find out what version it was built from.
 
Back
Top