at 18.03-beta 1.3 kB view raw
1<section xmlns="http://docbook.org/ns/docbook" 2 xmlns:xlink="http://www.w3.org/1999/xlink" 3 xmlns:xi="http://www.w3.org/2001/XInclude" 4 version="5.0" 5 xml:id="sec-nix-store-corruption"> 6 7<title>Nix Store Corruption</title> 8 9<para>After a system crash, it’s possible for files in the Nix store 10to become corrupted. (For instance, the Ext4 file system has the 11tendency to replace un-synced files with zero bytes.) NixOS tries 12hard to prevent this from happening: it performs a 13<command>sync</command> before switching to a new configuration, and 14Nix’s database is fully transactional. If corruption still occurs, 15you may be able to fix it automatically.</para> 16 17<para>If the corruption is in a path in the closure of the NixOS 18system configuration, you can fix it by doing 19 20<screen> 21# nixos-rebuild switch --repair 22</screen> 23 24This will cause Nix to check every path in the closure, and if its 25cryptographic hash differs from the hash recorded in Nix’s database, 26the path is rebuilt or redownloaded.</para> 27 28<para>You can also scan the entire Nix store for corrupt paths: 29 30<screen> 31# nix-store --verify --check-contents --repair 32</screen> 33 34Any corrupt paths will be redownloaded if they’re available in a 35binary cache; otherwise, they cannot be repaired.</para> 36 37</section>