3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/doc/manual/administration/store-corruption.xml

28 lines
1.3 KiB
XML
Raw Normal View History

<section xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="5.0"
xml:id="sec-nix-store-corruption">
2018-05-02 00:57:09 +01:00
<title>Nix Store Corruption</title>
<para>
2019-09-18 21:13:35 +01:00
After a system crash, its possible for files in the Nix store to become corrupted. (For instance, the Ext4 file system has the tendency to replace un-synced files with zero bytes.) NixOS tries hard to prevent this from happening: it performs a <command>sync</command> before switching to a new configuration, and Nixs database is fully transactional. If corruption still occurs, you may be able to fix it automatically.
2018-05-02 00:57:09 +01:00
</para>
<para>
2019-09-18 21:13:35 +01:00
If the corruption is in a path in the closure of the NixOS system configuration, you can fix it by doing
<screen>
2019-06-17 12:25:50 +01:00
<prompt># </prompt>nixos-rebuild switch --repair
</screen>
2019-09-18 21:13:35 +01:00
This will cause Nix to check every path in the closure, and if its cryptographic hash differs from the hash recorded in Nixs database, the path is rebuilt or redownloaded.
2018-05-02 00:57:09 +01:00
</para>
2018-05-02 00:57:09 +01:00
<para>
You can also scan the entire Nix store for corrupt paths:
<screen>
2019-06-17 12:25:50 +01:00
<prompt># </prompt>nix-store --verify --check-contents --repair
</screen>
2019-09-18 21:13:35 +01:00
Any corrupt paths will be redownloaded if theyre available in a binary cache; otherwise, they cannot be repaired.
2018-05-02 00:57:09 +01:00
</para>
</section>