I realize this is marked as SOLVED , yet no working solution is provided.
And just now I was creating a USB flash based small system for a router/gateway/wifi. With USB being very slow at writes, I'm using memory file system wherever possible -- specifically in
/var that has to be written to. And I was also searching forums as to how exactly my
/etc/fstab entry should look.
So, just for future reference and to save your time as it would have saved mine )))
In fact, while
rc.conf or
loader.conf settings WILL create such image at boot time, you can very well do without them.
Note, the simple answer of how it works is found in
mdmfs(8):
Code:
Create and mount a 32 megabyte swap-backed file system on /tmp:
mdmfs -s 32m md /tmp
The same file system created as an entry in /etc/fstab:
md /tmp mfs rw,-s32m 2 0
Generally, then, the 4th block is your specific mount options -- first,
mount(8) related options, then your file system-specific ones. Accordingly, in order to boot-time mount
/var as vnode-backed
mfs (with image found at
/var.img) the following string in
/etc/fstab is enough:
Code:
md /var mfs rw,sync,noatime,-P,-F=/var.img 0 0
For
mount(8) related options
sync and
noatime are good enough AFAIK. Other OS manuals also use
nodev in similar scenarious, but it is not used in FreeBSD (see
mount(8)) and will
only make mount fail. Then
-P -F $file.img
are needed to mount vnode-backed
mfs.
With this single entry in
/etc/fstab and nothing else
mdconfig will create
md image from my
/var.img file and
mfs mount it on
/var. Note, too, that md device numbering will be handled automatically, as explained in the man.