• 0 Posts
  • 2 Comments
Joined 6 months ago
cake
Cake day: October 16th, 2024

help-circle
  • I suppose some people might still want to upgrade certain packages and not others, but that seems a pretty rare case these days - or maybe I just don’t hang out in the right crowds!

    That would still be possible, actually! You can totally choose what packages to upgrade (depending on the distro). NixOS even lets you have multiple versions of the same package installed at once—another uninherent but easy byproduct of atomic design.

    Atomicity is just a technical part of how it works under the hood. Normally when you install, uninstall or remove something, it directly does those modifications to your system. If your power goes out halfway through, you’re in trouble.

    Most atomic distros do those changes to a separate filesystem image instead. Then when it’s finished, it instantaneously applies the all of the changes you did by mounting the new image. If your power went out halfway through, you’ll just be booting to the old image, untouched and pristine.

    That doesn’t limit what you can or can’t do. You can do all kinds of tinkering and all kinds of partial upgrades to the image (again, depending on the distro). But when it’s all done, you can apply all the changes you did instantly.

    Here’s another example. One way to atomically change a single file is to use mv. Moving within the same filesystem simply renames the file and does not transfer data.

    Imagine you’re adding a ton of lines to a live script, including rm -rf ~/tmpdir. If you directly modified it, there’s a chance that something could execute it while it was only partially written to the disk and run rm -rf ~ instead. Yikes.

    But if you wrote it to a separate file instead, you could apply your huge set of changes in an instant by using mv to replace the original file. That’s atomicity. It’s also actually how sudoedit/visudo works and one of the reasons why it’s recommended over just sudo "$EDITOR".


  • Atomic distros are not inherently immutable, although they often are because it’s an easy byproduct of atomic design.

    Atomicity means transactions are either applied in whole or not at all. That means that your system will never be stuck in a broken half-way state if it crashes during an update.

    In practice, this is often implemented through filesystem images that are mounted for instant changes. These are then often mounted as read-only for immutability, but distros usually have options to use them as read-write as well for tinkering.

    In my opinion, atomicity is the future. The risk of your system breaking during every upgrade is tolerable, but why not eliminate it altogether? Immutability is a different game and is mostly a preference thing.