202409221431
Status: #idea
Tags: #tech #unraid #nas #nixos

migrating from unraid to nixos

Purpose

My current application of unRAID is a little janky in that I'm not using the built-in docker container manager or the CA store. Instead, I'm using the compose-manager plugin in order to install Komodo, and manage my stacks within that. It just doesn't make any sense to run so many layers that don't add any functionality for my use-case. Ideally, I'd like to have a minimal backend to free up resources for the systems doing the heavy lifting.

Additionally, I hardly use any of the benefits unRAID offers, particularly the VM manager or even parity, though I may consider that down the road (but probably not because it's a waste of raw storage).

Justification

The foundation for my new NAS will be based on nixOS. My reasoning is that, by nature, nixOS is, first and foremost, reproducible. The idea here is that the entire configuration will reside on github, as I'm currently doing with my compose files. This, in addition to my automated appdata backup using kopia, means that if my server decides to implode, reconfiguration should only take a matter of minutes. A simplistic evaluation of pros/cons compared to unRAID follows:

Pros

Cons

Implementation

I'm not entirely sure how I'm going to accomplish this. But, to start, I would use a nixOS VM so that I can build this system properly and over time without any disruption to current services. With the reproducible nature of nixOS, I could simply use the configuration I build in the VM as the base for the new NAS and it should only require changes to a line or two before it can be deployed. Allegedly. This is going to go to shit super quick.

I have a few things in mind: (this is what passes for a plan)

mount paths

data: /data
appdata: /appdata
cache:
cache_data: /cache/data
cache_appdata: /cache/appdata

Other things to consider

Gonna have to setup a VM environment so that I can migrate HAOS from the existing server. Could probably run proxmox on top to save myself some headache. I'll have to consider some other solutions for resource limiting to replicate the function of CPU pinning ... no idea if docker or VMs natively support core/thread restrictions, or if I can just put some of my services in jails.

What's important to consider is the shit that I didn't think of, which is certainly a lot.

Execution

So I've done the basics so far.

fileSystems."/data" = {
    fsType = "fuse.mergerfs";
    device = "/mnt/disks/*";
    options = ["cache.files=partial" "dropcacheonclose=true" "category.create=mfs"];
};

Notes

Firewall: nixOS has an enabled-by-default firewall that must be bypassed in order to allow access to containers from other devices on the network. This can either be done by allowing access to particular ports (80/443 for traefik) or just disabling it entirely. I don't need a firewall at this level but if I only have to expose a pair of ports then I may as well just leave it on for peace of mind.

Atomic Moves: There's a very real possibility that my existing file structure breaks atomic moves. Maybe. I'll have to look at how my unRAID shares were configured and see if I'm applying it the same way. I think, in effect, I'll want to change /cache/data to be /data/usenet. I don't know if I can mount a physical drive into a mergerFS pool... that seems irresponsible, so that's what I'm going to try and do.

Appdata: Once this is ready for production I'll have to remember to change all the paths in the appdata folder to match the new directory structure (which I'll have to figure out sooner than later).

Compose Files: Earlier I changed instances of crate.dev to whiskeyjack.org so that I could spin up my new NAS without interfering with existing services. This isn't really necessary, and I'll have to change everything back before production.

Disks: I don't think it matters which disk I put where since I'm not using any sort of parity. When I actually do the swap I really should just use two array drives to start and see if there are any file collisions for duplicate directories.

Cosmos-server: Not sure if I want an all-in-one manager, but it's definitely worth looking into to simplify deployment. I don't think it allows for building from github repo, so this might be a non-starter.

Results

I was hopeful that I could have a single master repository that contained my nixos-config for any of my devices, but also the configurations for the nixos-based NAS (including all my stacks). This hasn't proven to be particularly viable for a number of reasons.

I tried running nix pkgs directly instead of having everything in docker containers because I figured the fewer layers there were, the fewer headaches and performance impacts there might be. This has been a resounding failure.

Conclusion

I'm not even sure it's practical to move away from unRAID at this point. I would lose a lot of the management tools that, while not essential, could be useful to provide a heads-up effortlessly. I could build a dashboard to replicate this functionality, but at a certain point, why?

For the time being I'm going to treat this as future ambition that I'd like to work towards, but leave as a very low priority. I'd like to continue researching the options that nixOS might offer, but it's not realistic to even consider implementing it until unRAID presents some issues that make it no longer viable.

UPDATE

I'm probably still gonna do it and abandon the duplicate services for now. I have to figure out directory permissions as sab/sonarr aren't enjoying the /data path. I think once I have a separately filesystem mounted wide open it should be fine.

References

Repo Name Address Purpose
nix-config https://github.com/cratedev/nix-config nixOS config for laptop, desktop, and NAS
unraid https://github.com/cratedev/unraid docker-compose files for unRAID
nix-nas https://github.com/cratedev/nix-nas docker-compose files for nixOS NAS
cosmos-server https://github.com/azukaar/Cosmos-Server home-server manager