[Nix-dev] Moving /nix/store to another partition

Eelco Dolstra eelco.dolstra at logicblox.com
Mon Jul 28 12:41:50 CEST 2014


Hi,

On 28/07/14 11:54, Sergey Mironov wrote:

> Hi, List!  Looks like I've made not wise choice of locating /nix/store
> in root (/) partition on my build server. Now all 'no space left on a
> device' are my friends.  Is it possible to relocate /nix/store's
> contents into /home (located on a much larger partition) without
> re-installing the entire system? In other words, I want my /nix/store
> to be a symlink pointing to /home/nix/store.   Is it safe to just boot
> from the CD, move /nix/store to /home and drop the symlink ? 

/nix/store or /nix cannot be symlinks, but they can be bind mounts. So you can
boot from the CD, move /nix to /home, and add an entry like:

  fileSystems."/nix" =
    { device = "/home/nix";
      fsType = "none";
      options = "bind";
    };

to configuration.nix. Also set the neededForBoot option on the /home filesystem
to true, otherwise it won't be mounted in stage 1 of the boot, and the bind
mount will fail.

You can then run nixos-install to rebuild the configuration (which shouldn't
take long since the only change was to fileSystems).

You can probably also do this without the CD by: 1) updating configuration.nix
as above; 2) running "nixos-rebuild boot"; 3) copying /nix to /home/nix; 4)
rebooting.

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list