How to mount FreeBSD-13.2-RELEASE-armv7.img file on Linux using the loop devices

Hello to everyone.

I would like to mount the FreeBSD 13.2 img file for arm v7 on Linux using the loop devices. I wrote a litte script to do that,but it does not work. In origin I've got the img file here :

https://download.freebsd.org/releas...eeBSD-13.2-RELEASE-arm-armv7-GENERICSD.img.xz

but later I've resized the space that it offered using the truncate command. Actually I'm on Linux and I want to extract the files that are inside the img file. This is the script that I wrote to do it :

Code:
nano mount-freebsd-img-on-linux.sh :

losetup -fP FreeBSD-13.2-RELEASE-armv7.img
losetup -a
fdisk -l /dev/loop0 mount -r -t ufs -o ufstype=ufs2 /dev/loop0p2 FreeBSD-13.2-
RELEASE-armv7

Unfortunately it does not work,probably because the file system used by the image is not ufs2 :

Code:
./mount-freebsd-img-on-linux.sh

/dev/loop0: (/mnt/zroot2/zroot2/OS/Chromebook/FreeBSD-guestOS/FreeBSD-13.2-
RELEASE-armv7.img)

Disk /dev/loop0: 100 GiB, 107374182400 bytes, 209715200
sectors Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device       Boot  Start       End   Sectors  Size Id Type

/dev/loop0p1 *      2048    104447    102400   50M  c W95 FAT32 (LBA)
/dev/loop0p2      104448 209715199 209610752  100G a5 FreeBSD

mount: /mnt/zroot2/zroot2/OS/Chromebook/FreeBSD-guestOS/FreeBSD-13.2-RELEASE-
armv7: unknown filesystem type 'ufs'.
dmesg(1) may have more information after failed mount system call.

The partition has code ID = a5. It's not UFS. It is some kind of DOS fs. I tried vfat,but it hasn't been accepted.

The error message seems to indicate my system doesn't recognize UFS2 as a filesystem type. BUT it's not true because I have several disks on my PC that have UFS2 as a fs,and they can be mounted :

[CODE]
Disk /dev/sdc: 298.09 GiB, 320072933376 bytes, 625142448 sectors
Disk model: WDC WD3200AAJS-0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 1765E314-F3CF-11EC-8C52-E0D55EE21F22

Device         Start       End   Sectors   Size Type
/dev/sdc1         40    532519    532480   260M EFI System
/dev/sdc2     532520 616562727 616030208 293.7G FreeBSD UFS
/dev/sdc3  616562728 624951335   8388608     4G FreeBSD swap

# mount -r -t ufs -o ufstype=ufs2 /dev/sdc2 /mnt/sdc2
ok
How to fix it ?
 
probably you have a bsd disklabel so there is an offset from the fdisk partition to the actual filesystem
linux loop devices support offsets so you can use that
you just need to know the offset of disks0s2a from disk0 and pass it to the loop device
if you can use freebsd gpart you can determine the offset
otherwise use dd+file
for i in $(seq 100);do dd if=/dev/loop0p2 skip=$i count=400 2>/dev/null|file -|grep mounted && echo $i;done
that will display the offset in sectors from the disk0s2 to disk0s2a
 
On FreeBSD, you could use mdconfig.
On Linux, it's probably an iso9660 file type.

Perhaps:
mount -o loop <filename> <mount_point>
 
Code:
nano monta-img :

losetup -fP FreeBSD-13.2-RELEASE-armv7.img
losetup -a
fdisk -l /dev/loop0
for i in $(seq 100);do dd if=/dev/loop0p2 skip=$i count=400 2>/dev/null|file -|grep  mounted && echo $i;done

# ./monta-img
/dev/loop0: [0032]:12 (/mnt/zroot2/zroot2/OS/Chromebook/FreeBSD-guestOS/FreeBSD-13.2-RELEASE-armv7.i
mg)
Disk /dev/loop0: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device       Boot  Start       End   Sectors  Size Id Type
/dev/loop0p1 *      2048    104447    102400   50M  c W95 FAT32 (LBA)
/dev/loop0p2      104448 209715199 209610752  100G a5 FreeBSD
 
Code:
# mount -o loop FreeBSD-13.2-RELEASE-armv7.img ./FreeBSD-13.2-RELEASE-armv7

mount: /mnt/zroot2/zroot2/OS/Chromebook/FreeBSD-guestOS/FreeBSD-13.2-RELEASE-armv7: wrong fs type, bad
option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.
 
Code:
# dmesg

[12155.067209] FAT-fs (loop0p2): bogus number of reserved sectors
[12155.067226] FAT-fs (loop0p2): Can't find a valid FAT filesystem
[12335.905192] FAT-fs (loop0p2): bogus number of reserved sectors
[12335.905207] FAT-fs (loop0p2): Can't find a valid FAT filesystem
[39336.081260] loop0: detected capacity change from 0 to 209715200
[39336.085442]  loop0: p1 p2
[39651.457044] loop0: detected capacity change from 0 to 209715200
 
does not seem to find the fs
change 100 from seq 100 to something larger like 200 or 400
Code:
titus@ubuntu:~$ for i in $(seq 100);do dd if=disk.img skip=$i count=400 2>/dev/null|file -|grep  mounted && echo $i;done
/dev/stdin: Unix Fast File system [v2] (little-endian) last mounted on , last written at Tue Nov 21 06:50:00 2023, clean flag 1, readonly flag 0, number of blocks 5117, number of data blocks 4868, number of cylinder groups 4, block size 32768, fragment size 4096, average file size 16384, average number of files in dir 64, pending blocks to free 0, pending inodes to free 0, system-wide uuid 0, minimum percentage of free blocks 8, TIME optimization
17
this show 17 as the offset of the ffs from the begining of the disk
 
On FreeBSD, tar can read iso files. Maybe you can use bsdtar on the penguin?
 
Back
Top