# moveonenospc When writing to a file a [number of errors](https://man7.org/linux/man-pages/man2/write.2.html#ERRORS) are possible. The `ENOSPC` error indicates their is no room for the data. That could be true due to the filesystem having actually no available space for data, or because a secondary resource (such as inodes) has been used up, or the filesystem might have a quota feature that is limiting how much storage a particular user may use, or (as on `ext4` there might be a feature which reserves space for privileged processes. Since mergerfs [does not offer](../index.md#non-features) splitting of files across filesystems there are situations where a file is opened or created on a filesystem which is nearly full and eventually receives a `ENOSPC` error despite the pool having capacity. The `moveonenospc` feature allows the user to have some control over this situation. When enabled and a `write` fails with `ENOSPC` or `EDQUOT` mergerfs will: 1. Check that the file's path is absent on every branch other than the source and its aliases, including read-only and no-create branches. If the path already exists (even as a dangling symlink), or a branch cannot be checked, refuse the move: removing the source could make a later open find a different file. Otherwise, use the `moveonenospc` policy to choose a destination from the eligible branches. 2. ["Move"](../faq/technical_behavior_and_limitations.md#how-does-mergerfs-handle-moving-and-copying-of-files) the file from the source branch to the target branch. If another entry appears at the destination during the copy, the move fails without overwriting that entry or removing the source. The copy, its name and any directories created for it are flushed to disk before the source is removed, and the removal is flushed too. On a filesystem that can sync files and directories, a crash therefore leaves either the original or a complete copy; a removal that could not be synced is logged. Before source removal, mergerfs opens the destination separately for every open handle with that handle's access flags. Writes and other changes made through an open handle (truncation, allocation, `ioctl`) and new opens of the file wait while the move is prepared. Reads and `fsync` continue against the original, which the copy matches, until each handle switches. Changes made by path, which is how the kernel sends `chmod`, `chown`, `utimes` and xattr changes even for an open file, do not wait: if one reaches the original after it was copied, the move is refused and the write keeps its error. Once the original name has been removed successfully, every handle switches to the new copy together. Every handle opened through the file's name, including opens made after a rename through mergerfs, is switched together, and an open of the file while a move is in flight waits and gets the moved file. After the move each handle adopts the path the relocation used, so a later move can be triggered by any of them. A handle whose own recorded path no longer resolves to the file on any branch cannot itself trigger a relocation; its write keeps the original error until another handle of the file relocates it. 3. Retry only the unwritten portion of the request, so a partially completed append is not duplicated. If at any point something fails the provisional destination will be cleaned up, provided it still identifies the object created by this move. The original error is returned and every handle remains on the original. In particular, failure to remove the source name does not switch even the writing handle and does not acknowledge the unwritten suffix. If part of the write already reached the file the bytes written are returned instead, as a short write, as with a local filesystem. The exception is data the kernel is flushing from its page cache (`cache.writeback` or dirty `mmap` pages), including writeback on a direct-I/O handle. The kernel cannot act on a short write for those pages, so the error is returned and reaches `fsync`, `msync` or `close`. A file is never relocated when it has more than one link: a copy plus source removal would leave the other names on the original inode, so the names would describe different files afterwards. The move is also refused while the file is open through another name, which the kernel treats as another file: a hardlink whose other name was removed while both were open, a rename made directly on a branch while the file was open, or branches that reach the same file by two paths. Those handles could not be switched and would keep writing to the original. An open through such another name that happens during the last step of a move is not coordinated with it, and can end up on the original, losing its writes. With `moveonenospc`, avoid presenting one file under two names: [follow-symlinks](follow-symlinks.md) and branches that reach the same file by two paths both do that. Entries inside the `rename-exdev` staging namespace (the targets of published replacement symlinks, `.mergerfs_rename_exdev/`) are also never relocated: moving one would re-home the symlink's target and strand the published name. In all of these cases the write keeps its original error. Whether a file can be relocated is decided when it is first opened, and holds until every handle to it has been closed. A file opened while `moveonenospc` is disabled, or opened with a kernel passthrough backing ID (see [passthrough.io](passthrough.md)), is never relocated, and its handles skip the coordination a relocation needs. Enabling `moveonenospc` at runtime therefore applies to files opened afterwards. Source and destination identity checks reject replacements observed before cleanup or source removal. Removal itself is a pathname operation and cannot be atomic with those earlier checks; they do not synchronize with external changes to the branches racing the final unlink syscall. If `moveonenospc` is disabled the underlying error will be returned, or the bytes written if part of the write succeeded. NOTE: This feature has NO effect on policies. It ONLY applies to the literal write function. If the create function returns `ENOSPC` or the [policy returns `ENOSPC`](functions_categories_policies.md#filtering) that error will be returned back to the application making the `create` request. ## Additional Reading * [Functions, Categories, Policies](functions_categories_policies.md) * [Why do I get an "out of space" / "no space left on device" / ENOSPC error even though there appears to be lots of space available?](../faq/why_isnt_it_working.md#why-do-i-get-an-out-of-space-no-space-left-on-device-enospc-error-even-though-there-appears-to-be-lots-of-space-available)