Storage optimization: Difference between revisions
imported>OctavioElMagnifico Added detail over the method for changing the store location in nixos. After binding into nix/ the new partition you need to restart the daemon in order to be able to rebuild. Also, for nixos to boot you need to add "neeededForBoot" in the new /nix filesy |
imported>OctavioElMagnifico m More detail in rsync command and more numbers in action list for nixos migration of store. |
||
| Line 102: | Line 102: | ||
# Create a new ext4 partition and mount it over <code>/mnt</code> | # Create a new ext4 partition and mount it over <code>/mnt</code> | ||
# <code>rsync - | # <code>rsync -aAxv</code> everything from <code>/nix</code> to <code>/mnt</code> | ||
# bind <code>/mnt</code> to <code>/nix</code> (e.g. using <code>mount</code>) | # bind <code>/mnt</code> to <code>/nix</code> (e.g. using <code>mount</code>). | ||
# reboot to be sure <code>/nix/store</code> is properly mounted | # Restart nix daemon with <code>systemctl restart nix-daemon.service </code> <code>systemctl restart nix-daemon.socket </code>. | ||
# bind mount <code>/</code> to <code>/old_root</code>, and remove <code>/old_root/nix</code> | # Rerun <code>nixos-rebuild switch</code> with something like <syntaxhighlight lang="bash">fileSystems."/nix" = { device = "/dev/disk/by-label/nix"; neededForBoot = true; options = [ "noatime" ]; };</syntaxhighlight> | ||
# reboot to be sure <code>/nix/store</code> is properly mounted. | |||
# Once you are sure everything works, you cand delete the old store doing a bind mount <code>/</code> to <code>/old_root</code>, and remove <code>/old_root/nix</code>. | |||
Keep in mind that all commands like <code>mount</code> and <code>bash</code> point to some executable in <code>/nix/store</code>, so never mount an empty disk over <code>/nix</code> or <code>/nix/store</code>, otherwise you will be locked out until reboot! | Keep in mind that all commands like <code>mount</code> and <code>bash</code> point to some executable in <code>/nix/store</code>, so never mount an empty disk over <code>/nix</code> or <code>/nix/store</code>, otherwise you will be locked out until reboot! | ||