newfs(1) on a file

Warner Losh imp at
Thu Jun 4 21:24:38 UTC 2020

On Thu, Jun 4, 2020 at 3:14 PM <goatshit54108 at>

> On 6/4/20 5:04 PM, Nazim Can Bedir via freebsd-fs wrote:
> > in order to include efficient and proper caching of disk
> > blocks into the equation, damn filesystem backing stores need to be
> > exist as devices.
> I find that hard to believe, at least with that exact wording. An
> alternative "Sorry, but all current FreeBSD-kernel filesystem-code is
> designed only with underlying block devices in mind, so some work is needed
> to handle other cases." sounds acceptable.
> The caching strategy mainly depends on the filesystem type, its
> implementation, and the settings. For some "filesystems", such as swap
> spaces, caching is specifically to be avoided.
> Linux is able to perform `swapon ./file`, FreeBSD isn't.

echp | dd oseek=10000 count=1 of=fred
swapon /dev/$(mdconfig -f fred)

Does the trick.

> > if mount command couldn't mount a GAY filesystem from the file
> > as-is, then newfs(8) command shouldn't allow to create filesystem on
> > file as-is (otherwise, idiot FreeBSD users like me could think that
> > "aah, if newfs initialises filesystem on file without md, then it must
> > be able to mount without md).
> But newfs *is* able to create a filesystem on a regular file.

It's a bug, born from a long legacy of needing the information in the
disklabel in the past. That requirement has passed...

> > I really don't understand what is the damn problem here? Filesystem
> > operations are performed on special files (a.k.a disks); and md kernel
> > driver does exist for that purpose.
> Again, I don't like this way of thinking. First, it goes again the Unix
> philosophy. Second, there is a clear separation between (a) creating,
> attempting to repair or debugging an instance of a filesystem, and (b)
> mounting a filesystem, thus connecting it to the kernel's filesystem-system
> -- a highly flammable area --, which practically assumes that the instance
> is well-formatted, and demands exclusive write access.

 I agree. makefs is what's usually used since it lets you layer in a tree
as well. newfs on a file, by itself, isn't so useful, so this has remained


More information about the freebsd-fs mailing list