# 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
Yes and yes.Can images be mounted readwrite as well? I would like to inject files and edit others. Is this possible with the same method?
No.Will the image grow to accommodate extra files?
This is worth only for your target. Probably an ARM device. The actual mount command depends on the partition scheme of the image.FWIW 11.2R neededmount -r /dev/md0s2a /mnt
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. mount_msdosfs -o noatime /dev/md0s1 /mnt
would mount the U-Boot partition.Just as an exercise in using mdconfig() I thought I'd come up with a one-liner:-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
mount -r /dev/`mdconfig -a -t vnode -f /root/Downloads/FreeBSD-12.2-RELEASE-amd64-mini-memstick.img -o readonly`s2a /mnt/md
mount -r /dev/md0p2 /mnt
previously but now it's mount -r /dev/md0s2a /mnt
as others seem to have found.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 ..
-a -t vnode -f
options. From mdconfig(8):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 usemount -r /dev/md0p2 /mnt
previously but now it'smount -r /dev/md0s2a /mnt
as others seem to have found.
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.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. ....
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
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
mount -r /dev/`mdconfig FreeBSD.img -o readonly`s2a /mnt/md
mdconfig file
doesn't accept options after file
. But options before file
are accepted:mount -r /dev/`mdconfig -o readonly FreeBSD.img`s2a /mnt/md
-f
option setting (-f
option set alone implies -a -t vnode
mdconfig(8) ):mount -r /dev/`mdconfig -f FreeBSD.img -o readonly`s2a /mnt/md