Use when migrating Nix impermanence persistence from one path shape to another, especially directory-to-file or directory-to-children changes that cause mount conflicts during activation.
Use this skill for one-time migrations where persisted paths changed shape and activation now fails with errors like:
A file already exists at ...target is busyThis is most common when changing:
Impermanence does not automatically migrate an existing mounted path into a new persistence layout. The usual fix is:
Inspect the persisted path and its children:
findmnt -R <target-path>
systemctl list-units --all '<escaped-unit-prefix>*' --no-pager
Look for a pattern where:
If the new layout created nested mounts under the old parent, stop those first. If a stop fails because the path is busy, use a lazy unmount for the specific child mountpoint.
Typical commands:
sudo systemctl stop <child-mount-1> <child-mount-2> ...
sudo umount -l <busy-child-path>
Do not start by removing files blindly. Clear the mount stack first.
Once children are down, stop the old parent mount. If systemd still reports it busy, use a lazy unmount.
sudo systemctl stop <old-parent-mount-unit>
sudo umount -l <target-path>
Delete only the live mountpoint-side files or directories that are preventing the new units from taking ownership.
Examples:
/home/user/.code/auth.json/home/user/.config/app/state.jsonDo not delete the backing store under /persist/... unless the user explicitly wants data removed.
After detaching mounts, remove the blocking targets:
rm -f <blocking-file> ...
rm -rf <blocking-dir> ...
Only remove paths that the new persistence layout is about to recreate.
Run the appropriate activation command again:
sudo nixos-rebuild switch
Then verify:
findmnt -R <target-path>
systemctl list-units --all '<escaped-unit-prefix>*' --no-pager
Success looks like:
A file already exists at ...sudo -n true first if you need to know whether non-interactive sudo works./persist/... as part of the migration unless the user explicitly asks to discard persisted data.Directory-to-files migration example:
~/.code persisted as one directory mount~/.code/debug_logs, ~/.code/sessions, and several ~/.code/*.json file mountsTypical recovery:
~/.code~/.code parent mount~/.code/*.json files on the home sidenixos-rebuild switchfindmnt -R/persist was preserved