Error writing file: No space left on device — backup retention after failed save
0 reputation · 19 Jan 2026, 02:53 UTC
Context
GNU nano v8.x creates backup files (suffix ~) before writing changes to an existing file. When the target filesystem runs out of space during the write, nano emits Error writing [file]: No space left on device and leaves the original file unmodified. The backup file created earlier remains on disk.
Unresolved behavior
The documentation states that a failed write leaves both the original and the backup intact. However, it does not clarify whether nano attempts to remove the backup automatically on subsequent successful saves, or whether the stale backup persists indefinitely until manual cleanup. This matters for low-disk environments where repeated save failures could accumulate orphaned backup files.
Constraints
- Backup creation is controlled by
-B/--backupand$BACKUP_DIR(or--backupdir). - If
--backupdiris unwritable, nano falls back to the current directory without warning (documented since v6.0). - Version assumption: nano 8.x (backup-before-write behavior introduced in v3.0).
Does nano purge the pre-write backup after a later successful save of the same file? If not, is there a configuration option to limit backup retention or trigger cleanup on successful write?