Add snapraid parity

This commit is contained in:
Yan Lin 2025-09-07 00:52:27 +02:00
parent 04431c8cce
commit b57aee3d67
3 changed files with 89 additions and 20 deletions

View file

@ -68,6 +68,7 @@
};
};
};
};
zpool = {
@ -127,6 +128,8 @@
};
};
};
};
};
}

View file

@ -19,8 +19,43 @@
# Enable systemd stage-1 and ZFS support
boot.initrd.systemd.enable = true;
boot.supportedFilesystems = [ "zfs" ];
boot.supportedFilesystems = [ "zfs" "xfs" ];
boot.zfs.forceImportRoot = false;
boot.zfs.extraPools = [ "cache" ]; # Auto-import additional pools
# XFS drive mounts
fileSystems."/mnt/wd-12t-1" = {
device = "/dev/disk/by-id/ata-HGST_HUH721212ALE604_5PK2N4GB-part1";
fsType = "xfs";
options = [ "defaults" "noatime" ];
};
fileSystems."/mnt/wd-12t-2" = {
device = "/dev/disk/by-id/ata-HGST_HUH721212ALE604_5PJ7Z3LE-part1";
fsType = "xfs";
options = [ "defaults" "noatime" ];
};
# Parity drive for SnapRAID
fileSystems."/mnt/parity" = {
device = "/dev/disk/by-id/ata-ST16000NM000J-2TW103_WRS0F8BE-part1";
fsType = "xfs";
options = [ "defaults" "noatime" ];
};
# MergerFS union mount (needs to be after XFS mounts)
fileSystems."/mnt/storage" = {
device = "/mnt/wd-12t-1:/mnt/wd-12t-2";
fsType = "mergerfs";
options = [
"defaults"
"allow_other"
"use_ino"
"cache.files=partial"
"dropcacheonclose=true"
"category.create=mfs"
];
};
# Network configuration
networking = {
@ -93,6 +128,8 @@
zfs # ZFS utilities
zsh # Shell
home-manager # Enable standalone home-manager command
mergerfs # Union filesystem for combining multiple drives
snapraid # Parity-based backup tool
];
# ZFS services configuration
@ -100,6 +137,7 @@
autoScrub = {
enable = true;
interval = "monthly";
pools = [ "rpool" "cache" ];
};
autoSnapshot = {
enable = true;
@ -115,6 +153,53 @@
};
};
# SnapRAID configuration for parity protection
services.snapraid = {
enable = true;
# Parity file location on 16TB drive
parityFiles = [
"/mnt/parity/snapraid.parity"
];
# Content files for metadata (stored on multiple drives for redundancy)
contentFiles = [
"/var/snapraid.content"
"/mnt/parity/.snapraid.content"
"/mnt/wd-12t-1/.snapraid.content"
"/mnt/wd-12t-2/.snapraid.content"
];
# Data disks to protect
dataDisks = {
d1 = "/mnt/wd-12t-1/";
d2 = "/mnt/wd-12t-2/";
};
# Sync schedule (daily at 3 AM)
sync.interval = "03:00";
# Scrub schedule (weekly verification)
scrub.interval = "weekly";
# Files and directories to exclude from parity
exclude = [
"*.unrecoverable"
"/tmp/"
"/lost+found/"
"*.!sync"
".DS_Store"
"._.DS_Store"
".Spotlight-V100/"
".TemporaryItems/"
".Trashes/"
".fseventsd/"
"Thumbs.db"
"*.tmp"
"*.temp"
];
};
# Enable smartd for disk health monitoring
services.smartd = {
enable = true;

View file

@ -5,25 +5,6 @@
home.packages = [ pkgs.rsync ];
# Rsync exclude patterns for common files and directories
home.file.".rsync-exclude".text = ''
# macOS specific
.DS_Store
.AppleDouble
.LSOverride
Icon?
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# OS generated files
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
'';
# Rsync configuration for common backup scenarios