Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable fsck for MergerFS? #840

Open
dinvlad opened this issue Oct 17, 2024 · 3 comments
Open

Disable fsck for MergerFS? #840

dinvlad opened this issue Oct 17, 2024 · 3 comments
Labels
enhancement New feature or request question Not a bug or issue, but a question asking for help or information

Comments

@dinvlad
Copy link

dinvlad commented Oct 17, 2024

First of all, thanks for the excellent piece of software!

I've configured MergerFS through Disko:

    mergerfs = {
        type = "filesystem";
        device = "/mnt/data_*";
        content = {
          type = "filesystem";
          format = "fuse.mergerfs";
          mountpoint = "/mnt/data";
          mountOptions = [
            "noatime"
            "defaults"
            "cache.files=partial"
            "dropcacheonclose=true"
            "category.create=mfs"
          ];
        };
      };
    };

(here, disk(s) already mounted to /mnt/data_1, /mnt/data_2 are then mounted as a combined FUSE filesystem to /mnt/data)

This works, but at mount time I see the following in dmesg:

[   22.376728] systemd-fstab-generator[1683]: Checking was requested for "/mnt/data_*", but it is not a device.

And fstab shows this:

➜  ~ grep '/mnt/data ' /etc/fstab
/mnt/data_* /mnt/data fuse.mergerfs noatime,defaults,cache.files=partial,dropcacheonclose=true,category.create=mfs 0 2

As you can see, fsck check is enabled due to the last flag (2).

Is it possible to disable it through Disko config somehow? Thank you!

@iFreilicht
Copy link
Contributor

First of all, a really fun hack that uses the fact that we allow arbitrary strings in the format. AFAIU, you only used disko --mode mount or even just the module, right? Because I think --mode format would fail with this, as /mnt/data_* is not an actual device.

I think the "proper" solution for this issue would be for us to support mergerfs as an actual filesystem, with options dedicated to it, but as a workaround for your situation, it should be enough to add this top-level option to your config:

  fileSystems.mergerfs.noCheck = lib.mkForce true;

Just out of curiosity, did you have to do anything else to get mergerfs to work? Also, could you try if instead of "fuse.mergerfs", simply "mergerfs" works as well?

@iFreilicht iFreilicht added enhancement New feature or request question Not a bug or issue, but a question asking for help or information labels Oct 18, 2024
@dinvlad
Copy link
Author

dinvlad commented Oct 18, 2024

OK, thanks for your suggestions! I set lib.mkForce true and format = "mergerfs" successfully.

Other than that, the only other pieces I added earlier to make it work, in configuration.nix, are:

  environment.systemPackages = with pkgs; {
    mergerfs
    # ...
  };

  systemd.services.mergerfs-uncache = {
    path = [
      (pkgs.python3.withPackages (ps: with ps; [
        aiofiles
      ]))
    ];
    serviceConfig = {
      Type = "oneshot";
      ExecStart = ''
        ${./mergerfs-uncache.py} -s /mnt/cache -d /mnt/mergerfs_slow -a 90 -t 90
      '';
    };
    startAt = "Sat 00:00:00";
  };

where mergerfs-uncache.py is a slightly modified version of https://github.com/notthebee/nix-config/blob/main/modules/mover/mergerfs-uncache.py (I added -a, --atime option handling). This script is used to move more rarely accessed data from /mnt/cache (which is my fast NVME RAID 1 array) to /mnt/mergerfs_slow (HDD SnapRAID array).

Note also that since my last post, I've modified Disko config to use 2 nested MergerFS filesystems, such that I could access the combined NVME+HDD storage under /data (and under the hood, it would first write the data to NVMEs and then slowly over time move it to HDDs - thus achieving a tiered storage solution):

let
  cacheArray = "/mnt/cache";
  slowArray = "/mnt/data*";
  mergerArrays = {
    mergerfs_slow = {
      device = slowArray;
      mountpoint = "/mnt/mergerfs_slow";
      extraOpts = [];
    };
    data = {
      device = "${cacheArray}:${slowArray}";
      mountpoint = "/data";
      extraOpts = ["category.create=epff"];
    };
  };
  # ...
in
  { disks ? [], lib, ... }: {

  fileSystems = lib.mapAttrs' (_: fs: lib.nameValuePair fs.mountpoint {
    noCheck = lib.mkForce true;
  }) mergerArrays;
  
  disko.devices = {
    disk = (
      lib.mapAttrs (name: fs : {
        type = "filesystem";
        device = fs.device;
        content = {
          type = "filesystem";
          format = "fuse.mergerfs";
          mountpoint = fs.mountpoint;
          mountOptions = [
            "defaults"
            "moveonenospc=1"
            "minfreespace=100G"
            "func.getattr=newest"
            "cache.files=partial"
            "dropcacheonclose=true"
            "fsname=${name}"
          ] ++ fs.extraOpts;
        };
      }) mergerArrays
    ) // # ... the rest of Disko config, for the actual disks
};

@iFreilicht
Copy link
Contributor

@dinvlad if you have time, could you check if this still works with latest master? We made changes to quote the device name and labels properly to fix issues with whitespace, and this might break your device = "/mnt/data_*"; hack.

If it doesn't I'll open an issue for dedicated mergerFS support. The info you gave should be enough to make that happen.

Apart from that, can I close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Not a bug or issue, but a question asking for help or information
Projects
None yet
Development

No branches or pull requests

2 participants