m 1 omo: configure mergerfs

This commit is contained in:
makefu 2016-07-27 00:05:59 +02:00
parent b308c77e7a
commit 88a220f788
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -4,6 +4,7 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
toMapper = id: "/media/crypt${builtins.toString id}";
byid = dev: "/dev/disk/by-id/" + dev; byid = dev: "/dev/disk/by-id/" + dev;
keyFile = byid "usb-Verbatim_STORE_N_GO_070B3CEE0B223954-0:0"; keyFile = byid "usb-Verbatim_STORE_N_GO_070B3CEE0B223954-0:0";
rootDisk = byid "ata-SanDisk_SD8SNAT128G1122_162099420904"; rootDisk = byid "ata-SanDisk_SD8SNAT128G1122_162099420904";
@ -33,7 +34,8 @@ let
# all physical disks # all physical disks
# TODO callPackage ../3modules/MonitorDisks { disks = allDisks } # TODO callPackage ../3modules/MonitorDisks { disks = allDisks }
allDisks = [ rootDisk cryptDisk0 cryptDisk1 cryptDisk2 ]; dataDisks = [ cryptDisk0 cryptDisk1 cryptDisk2 ];
allDisks = [ rootDisk ] ++ dataDisks;
in { in {
imports = imports =
[ [
@ -73,25 +75,34 @@ in {
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
# HDD Array stuff # HDD Array stuff
environment.systemPackages = [ pkgs.mergerfs ];
services.smartd.devices = builtins.map (x: { device = x; }) allDisks; services.smartd.devices = builtins.map (x: { device = x; }) allDisks;
makefu.snapraid = let makefu.snapraid = {
toMapper = id: "/media/crypt${builtins.toString id}";
in {
enable = true; enable = true;
disks = map toMapper [ 0 1 ]; disks = map toMapper [ 0 1 ];
parity = toMapper 2; parity = toMapper 2;
}; };
# TODO create folders in /media
system.activationScripts.createCryptFolders = ''
${lib.concatMapStringsSep "\n"
(d: "install -m 755 -d " + (toMapper d) )
[ 0 1 2 "X" ]}
'';
environment.systemPackages = [ pkgs.mergerfs ];
fileSystems = let fileSystems = let
cryptMount = name: cryptMount = name:
{ "/media/${name}" = { device = "/dev/mapper/${name}"; fsType = "xfs"; };}; { "/media/${name}" = { device = "/dev/mapper/${name}"; fsType = "xfs"; };};
in cryptMount "crypt0" in cryptMount "crypt0"
// cryptMount "crypt1" // cryptMount "crypt1"
// cryptMount "crypt2"; // cryptMount "crypt2"
// { "/media/cryptX" = {
device = (lib.concatMapStringsSep ":" (d: (toMapper d)) [ 0 1 2 ]);
fsType = "mergerfs";
options = [ "defaults" "allow_other" ];
};
};
powerManagement.powerUpCommands = lib.concatStrings (map (disk: '' powerManagement.powerUpCommands = lib.concatStrings (map (disk: ''
${pkgs.hdparm}/sbin/hdparm -S 100 ${disk} ${pkgs.hdparm}/sbin/hdparm -S 100 ${disk}