a girl sits at a computer thinking about her next move

I recently, built a new server for my home lab. The server was built out of recycled parts of course, but it's got and intel i7 third generation and is significantly more powerful than anything I've ever built. At least on the server end of things. Somehow when moving the drives over from my old server. One of the drives from my old desktop was put in instead of the drives from the server.

This would ordinarily not be an issue, the drive from the desktop had more storage then the server drive that would have gone in instead. And the server drive contained very old backups dating back to my college days. Now ten years gone. I do want to retrieve some of the music off of it but that's a project for another day.

The problem with the drive from the desktop is that it is formatted as BTRFS, and I am not in a position to reformat it to ZFS right now. It still contains project data for stuff upcoming on my YouTube channel for example.

You might think that this is not a problem, Linux has support for both file systems after all. You'd be right on that, but for the fact I use BSD on any server I can get away with deploying it on. At this point only three out of the seven servers I maintain still have Linux installed. I would use a BSD operating system as my daily driver, except that my addiction to monster taming video games, and AI shenanigans definitively rules out such a configuration.

That notwithstanding I refuse to have my new server corrupted by the penguin. So what is a bird do.

file systems the final frontier

                                                         ,        ,
                                                        /(        )`
                                                        \ \___   / |
           BYE BYE LEENOX!                              /- _  `-/  '
              BYE BYE x86!                             (/\/ \ \   /\
                                                       / /   | `    \
                                                         |   ) /    |
                                                       `-^--'`<     '
                   ?                                   (_.)     )   /
                  _o)                                   `.__  `    /
                   /\\                     __             `-----' /
          (O_     _\/V                     / \---.     __ / __   \
      (o< //\                              \\/---|====O)))==) \) /====
      //\ V|/_     (._        (o_/\        >-)---'    `--' `.__,' \
      V_/_          |        /\\<--)->      ,            |        |
  (:_       (~<    //\       \_/_\/                      \       /
 / /\       //\    V_/_  (._                `       ______( (_  / \_____
 \/_/_  (o_ V\/_         (/)                 ,    ,'  ,-----'   |       \
        (\)      (o_   (~<   (-<           .      `--{__________) (smj) \/
      (O_   >O)  //\   _|_  //\.-                                  (fl)
      /      (\) V_/_ //L\\ V\/_             .
    //\               V\ /V
 Oo.V|/_               - -

Those unfamiliar with the politics involved, might believe the solution is simple both Linux and FreeBSD or open source operating system, that operates on a similar baseline, given that they're both unix implementations.

One should be able to take a feature from one, and trivially poured it to the other. You would be right except for politics my friend. both Linux and FreeBSD are open source operating system, that is true enough. However, each of them has a different approach to how the essential freedom open source are implemented. This results in features from Linux not being able to be cross pollinated into FreeBSD without political cooperation on both sides.

In the early days of both projects such collaboration was relatively common. But the developers have increasingly grown apart over the last fifteen or twenty years. This leads to often bizarre gaps in feature coverage.

Nowhere is this more evident then in the file system layer of either operating system. For example Linux can't write to a freebsd formatted partition, despite the core data structures, being relatively stable and well documented over the last thirty years. And if you trust google you might be left with the impression that FreeBSD is completely unable to read from modern Linux file systems. However as I recently discovered this implies only to kernel, and base system development. Workarounds exist for the problem of Linux file system mounts on a FreeBSD host and have for almost five years now.

I dug through forum posts so you don't have to

The problem I was having of not being a to run BTRFS on FreeBSD is quite easily solved. However you would not know that from a google search. The solution comes from a project known LKL or Linux kernel as a library.

as you might guess this implements Linux kernel functions as a library. It is distinct from FreeBSD's Linux emulation layer, which seeks only to translate the user facing system calls from Linux into FreeBSD style system calls. This is sufficient to run most Linux programs on freebsd.

But file systems are different and require significant amount of kernel internals to function. LKL Implements most of these functions as a library available on any POSIX conforming system including Linux itself. This makes it possible for BTRFS to be run as a userspace file system server. Here's how I set it up.

First install the appropriate packages

$ doas pkg install fusefs-lkl

Then load the correct kernel modules

$ doas kldload fusefs

Then find your BTRFS partition, the geom disk list command, Coupled with some greping through the dev directory should do it.

Next perform read only test of the mount, depending on the permissions on your device node this can be done as a non root user.

$ lklfuse -o type=btrfs -o ro /dev/ada5p1 /home/matt/linuxdisk

If you can read the data the drive you are ready for the final step,

deploying it system wide

The mounts created by userspace file system demons, or ordinarily not readable by other users on bsd. Not even root. And permission checks are not performed by the kernel but by the demon itself. Ordinarily this is what you want, as it prevent users from spying on each other's IO. However if you're deploying a Linux file system to be used by multiple users on FreeBSD you will want to change this default behavior.

But first you want to edit /boot/loader.conf to make sure the fuse fs kernel module is loaded at boot

+ fusefs_load="YES"

Finally add this line or something similar to /etc/fstab

/dev/ada2p1 /linuxdisk        fuse    rw,mountprog=/usr/local/bin/lklfuse,type=btrfs,allow_other,default_permissions 0 0


Reboot and test to see if you can write to the file system if you can you're done have a coke. If not there is more digging through man pages and forum posts in your future. If you contact me through the usual channels I may be able to help you. But I make no guarantees of that of course.