Storage optimization: Difference between revisions

imported>Mth
No edit summary
imported>Mth
No edit summary
Line 32: Line 32:
/run/booted-system -> /nix/store/8jkrl9jyq7hqxb6xpwcaghpdm26gq98j-nixos-system-iron-16.0916.09pre.custom
/run/booted-system -> /nix/store/8jkrl9jyq7hqxb6xpwcaghpdm26gq98j-nixos-system-iron-16.0916.09pre.custom
/run/current-system -> /nix/store/wmndyzzrbc9fyjw844jmvzwgwgcinq7s-nixos-system-iron-16.0916.09pre.custom</syntaxhighlight>
/run/current-system -> /nix/store/wmndyzzrbc9fyjw844jmvzwgwgcinq7s-nixos-system-iron-16.0916.09pre.custom</syntaxhighlight>
=== Don't forget to run <code>nix-collect-garbage -d</code> as root ===


Run <code>nix-collect-garbage -d</code> with <code>sudo</code> or <code>su</code>, or logged in as root, otherwise you are clearing only your old user profiles, not system-wide profiles.
=== Run as root ===
<code>nix-collect-garbage -d</code> operates only for the current user. To clear system profiles, with run it with root privileges.


=== Look for <code>result</code> symlinks ===
=== Look for <code>result</code> symlinks ===
Line 55: Line 55:
Especially look for system derivations. Those are created in many cases, for example, when running <code>nixos-rebuild  build-vm</code>
Especially look for system derivations. Those are created in many cases, for example, when running <code>nixos-rebuild  build-vm</code>


=== Don't forget to reboot ===
=== Reboot ===


As you see, the reference in <code>/run/booted-system</code> is a GC root, so it won't be cleared until reboot. If you don't want to reboot, just <code>rm /run/booted-system</code> that link and rerun <code>sudo nix-collect-garbage</code>.
As you see, the reference in <code>/run/booted-system</code> is a GC root, so it won't be cleared until reboot. If you don't want to reboot, just <code>rm /run/booted-system</code> that link and rerun <code>sudo nix-collect-garbage</code>.