Solved Mounting FreeBSD mini-memstick image

balanga

Son of Beastie

Reaction score: 217
Messages: 4,024

Is there any way to mount or extract a FreeBSD mini-memstick img file?
 
OP
B

balanga

Son of Beastie

Reaction score: 217
Messages: 4,024

Actually, I found I needed
mount -r /dev/md0p2 /mnt
 

Phishfry

Beastie's Twin

Reaction score: 2,668
Messages: 5,588

I always wanted to ask this question but never found a real need.

I noticed that the image is mounted readonly in Beastie 's post.
Can images be mounted readwrite as well? I would like to inject files and edit others. Is this possible with the same method?
Will the image grow to accommodate extra files?
 

dch

Active Member

Reaction score: 56
Messages: 141

FWIW 11.2R needed mount -r /dev/md0s2a /mnt
 

obsigna

Daemon

Reaction score: 889
Messages: 1,283

FWIW 11.2R needed mount -r /dev/md0s2a /mnt
This is worth only for your target. Probably an ARM device. The actual mount command depends on the partition scheme of the image.

Directly after the mdconfig command, we want to look at the output of gpart show in order to be informed how this particular disk image has been formatted. Then we are able to take an informed decision on which mount command is the correct one in the present use case.

Only for example, if I am correct and your image is destined to an ARM device, then mount_msdosfs -o noatime /dev/md0s1 /mnt would mount the U-Boot partition.
 
  • Thanks
Reactions: dch

dch

Active Member

Reaction score: 56
Messages: 141

thanks - this wasn't ARM but boring amd64 but the steps will be useful next time I am scratching my head. I just looked in `/dev/md*` for something resembling a partition.
 
OP
B

balanga

Son of Beastie

Reaction score: 217
Messages: 4,024

hIn other words, using an mdconfig(8) memory disk. E.g.:
# mdconfig -a -t vnode -f /path/to/FreeBSD-11.0-RELEASE-amd64-mini-memstick.img -o readonly -u 0
# mount -r /dev/md0 /mnt
<...>
# umount /mnt
# mdconfig -d -u 0
Just as an exercise in using mdconfig() I thought I'd come up with a one-liner:-


mount -r /dev/`mdconfig -a -t vnode -f /root/Downloads/FreeBSD-12.2-RELEASE-amd64-mini-memstick.img -o readonly`s2a /mnt/md

I guess I may have learnt something in four years :)..


It's odd that I needed to use mount -r /dev/md0p2 /mnt previously but now it's mount -r /dev/md0s2a /mnt as others seem to have found.
 

T-Daemon

Daemon

Reaction score: 876
Messages: 1,750

mount -r /dev/`mdconfig -a -t vnode -f /root/Downloads/FreeBSD-12.2-RELEASE-amd64-mini-memstick.img -o readonly`s2a /mnt/md

I guess I may have learnt something in four years :)..

There is always room to learn more. :) You can skip the -a -t vnode -f options. From mdconfig(8):

Code:
SYNOPSIS
        ....      
        mdconfig file
        ....
        The last form, mdconfig file, is provided for convenience as an
         abbreviation of mdconfig -a -t vnode -f file.
        ....

It's odd that I needed to use mount -r /dev/md0p2 /mnt previously but now it's mount -r /dev/md0s2a /mnt as others seem to have found.

If you inspect gpart show md0 it will show a MBR partition table. MBR partitions are called slices on FreeBSD, indicated with a "s" (ie. ada0s0). GPT partitions are indicated in the device naming with an "p" (ada0p0). If you saw "p" named partitions on earlier versions of installer images then those had an GPT partition table.

 
OP
B

balanga

Son of Beastie

Reaction score: 217
Messages: 4,024

There is always room to learn more. :) You can skip the -a -t vnode -f options. From mdconfig(8):

Code:
SYNOPSIS
        ....     
        mdconfig file
        ....
        The last form, mdconfig file, is provided for convenience as an
         abbreviation of mdconfig -a -t vnode -f file.
        ....

Not exactly sure about this... I ran the following to check:-
Code:
mdconfig -l
mount -r /dev/`mdconfig -a -t vnode -f FreeBSD.img -o readonly`s2a /mnt/md
ls -al /mnt/md
mdconfig -l
gpart show md0
umount /mnt/md
mdconfig -d -u 0
mdconfig -l
mount -r /dev/`mdconfig FreeBSD.img -o readonly`s2a /mnt/md
gpart show md0
ls -al /mnt/md
mdconfig -l

and this is what it produced:-
Code:
Script started on Wed May 12 18:23:37 2021
Command: sh ./mount-FreeBSD-img
total 552^M
drwxr-xr-x  18 root  wheel     512 Dec  7  2018 .^M
drwxr-xr-x  15 root  wheel     512 May  6 22:21 ..^M
-rw-r--r--   2 root  wheel     951 Dec  7  2018 .cshrc^M
-rw-r--r--   2 root  wheel     470 Dec  7  2018 .profile^M
-r--r--r--   1 root  wheel    6177 Dec  7  2018 COPYRIGHT^M
-r--r--r--   1 root  wheel    6994 Dec  7  2018 ERRATA.HTML^M
-r--r--r--   1 root  wheel    3266 Dec  7  2018 ERRATA.TXT^M
-r--r--r--   1 root  wheel  255886 Dec  7  2018 HARDWARE.HTML^M
-r--r--r--   1 root  wheel  119849 Dec  7  2018 HARDWARE.TXT^M
-r--r--r--   1 root  wheel   23899 Dec  7  2018 README.HTML^M
-r--r--r--   1 root  wheel   14333 Dec  7  2018 README.TXT^M
-r--r--r--   1 root  wheel   20415 Dec  7  2018 RELNOTES.HTML^M
-r--r--r--   1 root  wheel    8336 Dec  7  2018 RELNOTES.TXT^M
drwxr-xr-x   2 root  wheel    1024 Dec  7  2018 bin^M
drwxr-xr-x   9 root  wheel    1536 Dec  7  2018 boot^M
dr-xr-xr-x   2 root  wheel     512 Dec  7  2018 dev^M
-r--r--r--   1 root  wheel    6914 Dec  7  2018 docbook.css^M
drwxr-xr-x  25 root  wheel    2048 Dec  7  2018 etc^M
drwxr-xr-x   4 root  wheel    1536 Dec  7  2018 lib^M
drwxr-xr-x   3 root  wheel     512 Dec  7  2018 libexec^M
drwxr-xr-x   2 root  wheel     512 Dec  7  2018 media^M
drwxr-xr-x   2 root  wheel     512 Dec  7  2018 mnt^M
drwxr-xr-x   2 root  wheel     512 Dec  7  2018 net^M
dr-xr-xr-x   2 root  wheel     512 Dec  7  2018 proc^M
drwxr-xr-x   2 root  wheel     512 Dec  7  2018 rescue^M
drwxr-xr-x   2 root  wheel     512 Dec  7  2018 root^M
drwxr-xr-x   2 root  wheel    2560 Dec  7  2018 sbin^M
drwxrwxrwt   2 root  wheel     512 Dec  7  2018 tmp^M
drwxr-xr-x  13 root  wheel     512 Dec  7  2018 usr^M
drwxr-xr-x  24 root  wheel     512 Dec  7  2018 var^M
md0 ^M
=>      1  1906064  md0  MBR  (931M)^M
        1     1600    1  efi  (800K)^M
     1601  1904464    2  freebsd  [active]  (930M)^M
^M
usage: mdconfig -a -t type [-n] [-o [no]option] ... [-f file]^M
                [-s size] [-S sectorsize] [-u unit] [-L label]^M
                [-x sectors/track] [-y heads/cylinder]^M
       mdconfig -d -u unit [-o [no]force]^M
       mdconfig -r -u unit -s size [-o [no]force]^M
       mdconfig -l [-v] [-n] [-f file] [-u unit]^M
       mdconfig file^M
<------><------>type = {malloc, vnode, swap}^M
<------><------>option = {cache, cluster, compress, force,^M
<------><------>          readonly, reserve, ro, verify}^M
<------><------>size = %d (512 byte blocks), %db (B),^M
<------><------>       %dk (kB), %dm (MB), %dg (GB), ^M
<------><------>       %dt (TB), or %dp (PB)^M
mount: /dev/s2a: No such file or directory^M
gpart: No such geom: md0.^M
total 8^M
drwxr-xr-x   2 root  wheel  512 Apr 24 11:10 .^M
drwxr-xr-x  15 root  wheel  512 May  6 22:21 ..^M

Command exit status: 0
Script done on Wed May 12 18:23:37 2021

So, not entirely convinced... This is under FreeBSD 13.0-RELEASE

Sorry about the DOS line endings which script() produces...
 

T-Daemon

Daemon

Reaction score: 876
Messages: 1,750

mount -r /dev/`mdconfig FreeBSD.img -o readonly`s2a /mnt/md

Apparently the short form mdconfig file doesn't accept options after file. But options before file are accepted:
Code:
mount -r /dev/`mdconfig -o readonly FreeBSD.img`s2a /mnt/md

Alternatively, with -f option setting (-f option set alone implies -a -t vnode mdconfig(8) ):
Code:
mount -r /dev/`mdconfig -f FreeBSD.img -o readonly`s2a /mnt/md
 

grahamperrin

Daemon

Reaction score: 678
Messages: 2,145

Is this type of ⋯.img file not supported by sysutils/dsbmc?

<https://github.com/mrclksr/DSBMC#mounting-disk-image-files>

1622320223637.png


Sorry, ignore the question. I was confused by the DSBMC window not showing what I had opened.
After closing the client and stopping the service, I found:

1622321937604.png
 
Top