[Nix-dev] Broken nix database/store.

Joachim Schiele js at lastlog.de
Fri Jun 10 12:09:33 CEST 2016


On 09.06.2016 19:21, Layus wrote:
> Hi,
> 
> Due to a wrong manipulation when activating dir_index on my root
> partition, I have now plenty of live orphaned paths in my store (about
> 5G) like this one:
> 
> |$ nix-store -q --referrers-closure
> /nix/store/4zhkw0g564g3ljdpnn8j5krrsvcxildn-libXcomposite-0.4.4.tar.bz2
> /nix/store/4zhkw0g564g3ljdpnn8j5krrsvcxildn-libXcomposite-0.4.4.tar.bz2
> $ nix-store --delete
> /nix/store/4zhkw0g564g3ljdpnn8j5krrsvcxildn-libXcomposite-0.4.4.tar.bz2
> finding garbage collector roots... error: cannot delete path
> ‘/nix/store/4zhkw0g564g3ljdpnn8j5krrsvcxildn-libXcomposite-0.4.4.tar.bz2’ since
> it is still alive 0 store paths deleted, 0.00 MiB freed $ nix-store
> --delete --ignore-liveness
> /nix/store/4zhkw0g564g3ljdpnn8j5krrsvcxildn-libXcomposite-0.4.4.tar.bz2
> error: you are not allowed to ignore liveness 0 store paths deleted,
> 0.00 MiB freed $ sudo nix-store --delete
> /nix/store/4zhkw0g564g3ljdpnn8j5krrsvcxildn-libXcomposite-0.4.4.tar.bz2
> finding garbage collector roots... error: cannot delete path
> ‘/nix/store/4zhkw0g564g3ljdpnn8j5krrsvcxildn-libXcomposite-0.4.4.tar.bz2’ since
> it is still alive 0 store paths deleted, 0.00 MiB freed $ sudo nix-store
> --delete --ignore-liveness
> /nix/store/4zhkw0g564g3ljdpnn8j5krrsvcxildn-libXcomposite-0.4.4.tar.bz2
> finding garbage collector roots... deleting
> ‘/nix/store/4zhkw0g564g3ljdpnn8j5krrsvcxildn-libXcomposite-0.4.4.tar.bz2’ deleting
> ‘/nix/store/trash’ deleting unused links... note: currently hard linking
> saves 1754.97 MiB 1 store paths deleted, 0.27 MiB freed |
> 
> Is there some repair command to update liveness of paths ?

what you could do:
1. create a backup of all files
2. remove most stuff in / except /home/, /etc/nixos/, /etc/nix,
/nix/store (among some paths i just didn't think about)

3. boot a rescue nixos live-stick
4. do a nixos-install with the config you already have

this basically makes sure that your store sqlite database gets properly
repopulated.

after you booted into your new system, consider:
  nix-collect-garbage -d

to get rid of unused /nix/store paths




More information about the nix-dev mailing list