Completely lost

I am a 48 year old, trying to create a home IT infrastructure to my own liking, and needs.
(background info: i wanted to study a predescessor of AI in 1998, (CKI in Utrecht) unfortunately I listened to de forces that where and went for LAW (stupid), now I am a small entrepeneur in kitchenfitting, so I missed out on about 25-30 years of digital knowledge. for 1.5 year now i ve restarted my interest in IT (whatever that is nowadays) inspired by chatgpt. which got me started with R, python, rust, trying to create apps.That lead to the need for a server (hardware is still easy).
which lead to acting upon my frustration about windows. so i installed about 7 linux distros on my server/laptop (which needed workarounds for nvme raid en cost me a lot of time). And I m settling on Nixos. (I dont understand why this has not become the leading distro under linux, but as i said, i missed out a little)
So I am not even sure what my question is, but I cant seem to grasp the file/folder structure of linux.
that would not be a problem if i had no special needs, but there is some in between space, for my data, and system data. en i am confused, about how to use nixos for rollbacks, and how to backup everything else, without getting more confused about mounting something that is in 1 place to somewhere.
Any suggestions?

I would encourage you to use a different distro before NixOS. Even amongst Linux users NixOS is an extremely specific niche and intentionally goes against many of the most common practices like FHS folder structures. Using it will be difficult due to a lack of documentation surrounding specific situations, and online documentation that would work for most generic Linux distros will not work on NixOS as-is.

Basically, it’s a very difficult distro to use, even for experienced Linux users. Once you use NixOS you essentially have to commit 100% to trying to work things out the Nix way, and often times that isn’t the obvious, or easiest way. It’d be better to start off with a different distro that is well documented and caters to new users. Out of the many distros that exist, I’m familiar with Ubuntu and Linux Mint, both of which are great for new users. There is a plethora of documentation online for both, and they even come with some friendly features to help ease the migration between Windows to Linux.

2 Likes

I am a software engineer with 26 years of experience. My job is to figure out computers. I’ve maintained several Linux distros (Fedora, Gentoo, Ubuntu, Debian). I’ve been running NixOS for two months. And getting to the point I was comfortable with it was hard. I was this close to running back to Debian screaming.

And I didn’t even have special needs! This was just on a laptop that I was already familiar with.

Not knowing about the Linux file system is completely fair. NixOS is not the way to learn about it. My suggestion is to find some old piece of hardware, and getting comfortable maintaining something more like Debian on it. Go nuts exploring the file system. Figure out a backup strategy for that hardware.

NixOS is configured with a full on programming language. I don’t even think the Nix tool error messages are that bad; they’re pretty standard as far as programming language tool error messages go. Do you have programming experience? Are you ready to learn programming skills on your Nix journey? You kinda have to if you wanna get good at it.

I’ll be the third person I think to say some isomorphism of this:

Use a different distro.

Ubuntu is very well-supported (in ways that would matter to a new user) and will scale up with you as you proceed in your journey. Linux Mint is also very good.

This is not your fault. This is a distro that takes all of the existing weirdness of Linux (itself with hangovers from old Unices…) and adds even weirder stuff. It is not a beginner’s OS.


To answer your questions (as far as I can understand them; I apologize if this is wrong!):

In Linux you have block devices, which you can think of as a hard drive or SSD–just a big old bucket of bytes (which may not actually correspond to real hardware, and could instead just be a region of RAM or whatever, but that’s an advanced topic).

For HDDs and SSDs, you have partitions, which are sliced off sections of the device. The first 512 MB might be one such section, the next TB for data, and then perhaps 8 GB for swap (a place to shove excess things from RAM). A disk contains one or more partitions, and then each partition is formatted with a particular filesystem.

Using these as media, we mountfilesystems. You can view these by running mount with no arguments. You’ll see a bunch of things, but basically this is a collection of “ is mounted at as file system type with ”. Different filesystems have different properties–fat runs everywhere, ext4 is the old standby, zfs scales incredibly well and has checkpointing but is resource-intensive, ntfs is what WIndows uses, etc.

A mount point is where you find the root directory for a filesystem. For example, I might have a large spinny disk mounted at /home/crertel to store my home directory (the directory I keep all my documents and music in), and then a smaller disk at /boot to store my linux kernels.

The Filesystem Hierarchy Standard gives a rough “this is where you should be able to find stuff” on a Unix/Linux-style OS. Every distribution screws with that a bit and changes it, but the broad strokes are mostly the same:

  • /home/<your username> for you files
  • /proc for runtime information about the system (run cat /proc/cpuinfo to learn about your processor, for example!)
  • /var/log for logs (though under systemd distros like NixOS we use a different tool, journalctl)
  • /boot for kernels,
  • /etc/ for configuration files
  • …etc…

Of particular note to NixOS, we have /nix/store, which is where all the installed programs live (and live in read-only fashion) and /etc/nixos, which is where all your NixOS config stuff lives.

2 Likes

A different perspective: if you’re sufficiently motivated and really want what NixOS offers, then go for it.

I’ve tried Linux a few times before trying NixOS and I always got frustrated to the point of quitting when I inevitably ended up bricking my system, it’s the first distro that stuck. It’s been years, I’m happy with it, I still don’t understand FHS and I don’t need to.

Why? Because I can do trial-and-error with my config, undo my mistakes and version my whole system configuration. This is priceless for learning.

It was not frustration-free, my previous failures taught me a little bit and I’m an experienced developer. But the satisfaction of not having to solve the same problem twice, or with a different tool, made it worth it.

2 Likes

Since no one answered your question yet: on Linux, everything pretends to be a “file” - everything from physical hardware, to kernel settings, to sensor values, even the contents of the current terminal window (or any process’s in/output). Which means you can “read” from and sometimes “write” values to them, pretending they are files.

This was a design decision made 50+ years ago to make it easier to write tools that could interact with just about anything on the system.

This is kind of dry reading, but the links mentioned in file-hierarchy(7) — Arch manual pages should be a good starting point.
NixOS subverts this slightly by putting things in /run/current-system/sw via chains of symbolic links instead of /usr or /usr/local - but the remainder should apply.

Backups should be done the same as on any other distro - save your important data using something akin to https://en.wikipedia.org/wiki/Backup#3-2-1_Backup_Rule - there’s quite a bit of software out there to manage that.

3 Likes

Additionally, understanding the file system hierarchy (note: NixOS doesn’t comply with this fully, only really for data, which is mostly in /var/lib) isn’t going to do much for you; you need to understand what each service/application stores where separately anyway.

Many applications have backup guides that tell you exactly what to backup, and what you have to do to make sure the service is in a state in which its data is ready to be backed up - if you don’t do this, there’s a chance you’ll attempt to backup stuff mid-write; depending on what is being written, that’ll either lead to data loss or later failure to restore backups entirely.

If a service doesn’t have a guide, you’ll need to figure this out by yourself, usually by making your best guess.

Especially databases, and services that use them for (usually partial) data storage, need special handling.

NixOS rollbacks only affect the OS config and will always leave your data (i.e. in /home) alone.

If you want your data to be somewhere else completely, you can also mount it. I have a /nas directory that I use via ZFS ( ZFS - Official NixOS Wiki ), but you can pretty reliably count on anything under /home sticking around to keep it simple and avoid getting confused.

P.S. instead of discouraging you from trying NixOS, I’ll actually mention that it has a relatively _simple_ root filesystem compared to other distros. There’s no /usr, /sbin, /lib, /lib64, and so on, all your software lives under /nix and those directories can be made as needed from things in the store. In fact, the entire root filesystem can be recreated solely from /nix on NixOS, minus your data.

3 Likes

thank you for the reply.
That is usefull information.
I will read it.

I think I made my post a bit overdramatic, which probably caused the many use another distro replies. ? But I think Nixos is the most intuitive way of looking at creating an os. (maybe for all systems. think before creating, and easy adapt if needed), so I will not be switching any further.

I was actually only referring to the filesystem.
I have a running server setup with an old dell-r720 (which does not support nvme booting) with 256ram an 3pcie nvme (tried raid0, now running zpool) with /root en a sas drive for booting. and am in process of setting up my laptop.

also very usefull info, thank you.

thank you for the heads up.

I got tired of reinstalling windows every few years, so i stopped interfering with it, but with 11 the frustration became to much.
so i hope this will help with not having to redo everything more then once.
I am very much stuck in parent-child hierarchies,
can you elaborate a little on how not having to understand fhs relates to “trial-and-error with my config, undo my mistakes and version my whole system configuration”

Thank you for taking the time for the reply,
the link is very useful.
and just bij looking at the sheer list of directories, i get overwhelmed.
but it does get me thinking that on windows, it is even a bigger mess, but they structured everything in a few parent folders, so it doesnt look like it at first glance. (does this make sense?)

1 Like

Basically, NixOS has a ton of paths inside /nix/store (totally not along FHS) because there the installed packages live, and it is split by the package responsible, then inside maybe by almost-FHS-like internal structure.

FHS and Windows put some stuff into an hierarchy of «type» of a file, with all packages writing to the same place.

What this means is that the notion of version conflict for «merely being installed at once» disappears in Nix. Being in the active environment at once might still be a conflict, but the scope is also reduced a bit there. Thus you can have multiple full system versions fully installed at once, with relatively cheap switching between them.

Oh, and the entire system is a kind of a package, defined via the exact same package language. So you can version this definition.

And sometimes you can even have conflicting environments open in the terminals side by side.

So this is why having a huge unsorted pile of packages in /nix/store helps with undo and with versioning.

NixOS does have FHS-aligned paths, though - and those are the directories where actual data is kept, i.e. things relevant for backups.

You still need to look into them to see what things store data where, and have some discretion about when you backup (so you don’t capture stuff mid-write). But yes, NixOS does significantly simplify the FHS structure by throwing out half of it and replacing it at most with stubs and symlinks.

This also makes things a bit harder for a newbie - generic Linux backup guides and documentation often don’t apply well.

Some parent folders, but also registry entries. Linux doesn’t have a registry, everything that’s in the windows registry is represented in file paths and files instead (except gnome adds dconf, which is why gnome integrates so poorly with everything).

Having an object oriented interface into OS features is very 80/90’s, so that’s the approach Windows took. You can argue about which is more or less messy. Linux’ solution (which it inherits from Unix) strikes me as hackier, albeit more generic.

Since you never end up making any decisions on how core Windows services work, you as a user probably never see most of the mess, either - this is more exposed in Linux land, especially on a distro like NixOS.

2 Likes

ok. Yesterday I spent a full day studying and comparing fhs from linux and nixos.
and how rebuilds, homemanager, and flakes fit into this.
large part of my confusion was because of my limited understanding of how the operating systems work.
I simplified it for myself, and actually nixos seems to make a lot more sense. So I was just wondering, if the system used by nixos is necesarry, because of the use of the linux kernel. has it been a conscious choice. and if so would a kernel that has been build with declarative system state in mind, not be easier for users? (I understand the workload for developers for this).

1 Like

Hard to say; some the basic shape is reasonable in itself (one should track what belongs to what package in any case! and it’s reasonable to permit some structure inside… so basically the current store setup).

Some things are annoying but more due to the lack of user-space-side respect to the idea of «actually your installation directory can be truly readonly». And userspace-side fixes would be pretty simple (which doesn’t always mean «easy to implement starting from the current situation» — the volume of work can be pretty high). And kernel-side fixes might end up conceptually complicated to grasp fully…

Ok, thanks everybody.
just learned to work with git, and now using for my laptop and server configurating actions.
a lot to learn and small steps towards a full configuration.

Good read: How Linux Organizes Files: A Practical Guide for Former Windows Users - LINUX NEST