Storage optimization: Difference between revisions

imported>Cransom
nix-shell silently ignores --add-root, nix-instantiate is the right tool.
imported>Mth
not sure about these changes, review appreciated
Line 3: Line 3:
Here are generic notes on how to not run out of space too often. I assume you already know about <code>nix-collect-garbage</code> and do care about used disk space.
Here are generic notes on how to not run out of space too often. I assume you already know about <code>nix-collect-garbage</code> and do care about used disk space.


== Split <code>/nix</code> to a separate LVM volume ==
== Move the store ==


If your root device is fixed and small-sized, you should move <code>/nix</code> to a separate device. For example, you can run it on LVM. Optimally, you would set this up when installing NixOS, otherwise you might have to go through these steps:
{{ic|/nix}} can reside on another device. This is useful if your root device is very small, and that you have another, larger drive at hand. It is easiest to set up when installing NixOS. To move <code>/nix</code> to another device on an existing NixOS installation:


# Create a new ext4 partition and mount it over <code>/mnt</code>
# Create a new ext4 partition and mount it over <code>/mnt</code>
Line 14: Line 14:


Keep in mind that all commands like <code>mount</code> and <code>bash</code> point to some executable in <code>/nix/store</code>, so never mount an empty disk over <code>/nix</code> or <code>/nix/store</code>, otherwise you will be locked out until reboot!
Keep in mind that all commands like <code>mount</code> and <code>bash</code> point to some executable in <code>/nix/store</code>, so never mount an empty disk over <code>/nix</code> or <code>/nix/store</code>, otherwise you will be locked out until reboot!
That's it! You moved <code>/nix/store</code>!


== Enable periodic Garbage Collection ==
== Enable periodic Garbage Collection ==