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