Move Nix Store to new partition: Difference between revisions
imported>Buecking No edit summary |
imported>Wittypal mNo edit summary |
||
| (6 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
The tutorial will teach you how to relocate {{ic|/nix}} to a new | |||
device on non NixOS Hosts. A summary of how this could be done on NixOS is at the bottom. | |||
'''This has not been tested on NixOS''' but there may still be a way: | |||
= On *BSD/Linux Host = | |||
The device that /nix is on has no more space | The device that /nix is on has no more space | ||
<syntaxhighlight lang="console"> | |||
$ du -h | |||
Filesystem Size Used Avail Use% Mounted on | |||
/dev/sda1 182G 180G 2G 99% / | |||
</syntaxhighlight> | |||
Stop nix daemon | Stop nix daemon | ||
<syntaxhighlight lang="console"> | |||
$ sudo systemctl stop nix-daemon.service | |||
</syntaxhighlight> | |||
Move backup /nix; mv /nix to /nix.bak | |||
<syntaxhighlight lang="console"> | |||
$ ls -alF /nix | |||
total 1068 | |||
drwxr-xr-x 4 root root 4096 Jan 22 02:43 ./ | |||
drwxr-xr-x 26 root root 4096 Feb 8 12:17 ../ | |||
drwxrwxr-t 1555 root nixbld 1077248 Feb 8 12:05 store/ | |||
drwxr-xr-x 4 root root 4096 Jan 22 02:43 var/ | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="console"> | |||
$ cd / | |||
$ tar -afp /nix.tgz /nix /nix.bak | |||
$ sudo mv /nix /nix.bak # in case something goes horribly wrong | |||
</syntaxhighlight> | |||
Mount new device. You will need to add this device to `/etc/fstab` | Mount new device. You will need to add this device to `/etc/fstab` | ||
<syntaxhighlight lang="console"> | |||
$ mount /nix | |||
$ du -h | |||
Filesystem Size Used Avail Use% Mounted on | |||
/dev/sdb1 300G 0G 300G 0% /nix | |||
</syntaxhighlight> | |||
Restore /nix from /nix.tgz; verify contents | |||
<syntaxhighlight lang="console"> | |||
$ cd / | |||
$ sudo tar -xf /nix.tgz | |||
$ nix-store --verify --check-contents | |||
</syntaxhighlight> | |||
Start {{ic|nix-daemon}} | |||
<syntaxhighlight lang="console"> | |||
$ sudo systemctl start nix-daemon.service | |||
</syntaxhighlight> | |||
= NixOS = | |||
{{Merge|Storage_optimization#Moving_the_store|There is some overlap between this page and the subsection of Article Storage Optimization|Talk:Move_Nix_Store_to_new_partition}} | |||
Add [https://github.com/cleverca22/nixos-configs/blob/master/rescue_boot.nix rescue-boot.nix] to your imports section. | |||
nixos-rebuild (and pray you have ~300mb free on /boot/) | |||
run the installer from grub at any time. | |||
adjust your configuration.nix so it expects {{ic|/nix}} to be at the new place, and nixos-rebuild boot, so it doesnt break after you move it | |||
Now reboot and move it. | |||
[[Category:Tutorial]] | [[Category:Tutorial]] | ||
[[Category:NixOS]] | [[Category:NixOS]] | ||