Discussion:
[Nix-dev] Moving /nix/store to another partition
Sergey Mironov
2014-07-28 09:54:28 UTC
Permalink
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 ? Is there
a well-known algorithm of solving this administration task? Store
symlink management is the main thing I am worrying about.

Regards,
Sergey

PS

Currently, mount | grep /dev/sda1 outputs the following:

/dev/sda1 on / type ext4 (rw,relatime,data=ordered)
/dev/sda1 on /nix/store type ext4 (ro,relatime,data=ordered)
Luca Bruno
2014-07-28 09:59:14 UTC
Permalink
Post by Sergey Mironov
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 ? Is there
a well-known algorithm of solving this administration task? Store
symlink management is the main thing I am worrying about.
Relocating means rebuilding everything from scratch.
The other possibility is to bind mount /home/nix/store to /nix/store.
The problem is that the nix store is needed in initrd. So the bind mount
is not easy, you may end up with the system not booting.
Sergey Mironov
2014-07-28 10:35:22 UTC
Permalink
Sorry, forgot to CC to all.


---------- Forwarded message ----------
From: Sergey Mironov <***@gmail.com>
Date: 2014-07-28 14:34 GMT+04:00
Subject: Re: [Nix-dev] Moving /nix/store to another partition
Post by Luca Bruno
Relocating means rebuilding everything from scratch.
The other possibility is to bind mount /home/nix/store to /nix/store.
The problem is that the nix store is needed in initrd. So the bind mount
is not easy, you may end up with the system not booting.
Interestingly. I didn't think about initrd. In theory, I may try to
customize the initrd script to do bind mount (I hope I have HDD driver
compiled in kernel). What do you think, will it be sufficient? Should
I do the bind mount once again during stage2 ?

Regards,
Sergey
Luca Bruno
2014-07-28 10:40:17 UTC
Permalink
Post by Sergey Mironov
Interestingly. I didn't think about initrd. In theory, I may try to
customize the initrd script to do bind mount (I hope I have HDD driver
compiled in kernel). What do you think, will it be sufficient? Should
I do the bind mount once again during stage2 ?
Sorry, forget what I said. /nix/store should not be needed in stage1, as
it uses busybox.
I do something similar in fact :D I've installed nixos in a subdirectory
of my existing partition, therefore I bind mount /nixos to /. So you can
perfectly do the bind mount of /nix/store.
Here's the pull request: https://github.com/NixOS/nixpkgs/pull/3143

The current problem is that stage1 does not know the order of mount.
That is, you must mount / first, then bind mount /nix/store. That PR is
trying to address this ordering problem.
Probably that exact PR inverts the order and that's not what you want.
However you can modify it somehow to your needs.

I hope Eelco will +1 on setting an explicit order between mounts in the
initrd instead of sorting them out magically.
Eelco Dolstra
2014-07-28 10:41:50 UTC
Permalink
Hi,
Post by Sergey Mironov
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/
Sergey Mironov
2014-07-28 12:37:12 UTC
Permalink
Thanks! I'll try to relocate it this way.

Regards,
Sergey
Post by Eelco Dolstra
Hi,
Post by Sergey Mironov
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
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/
_______________________________________________
nix-dev mailing list
http://lists.science.uu.nl/mailman/listinfo/nix-dev
Continue reading on narkive:
Loading...