How Unrar Handles System Reboot Mid Extraction
When a system unexpectedly reboots during an extraction process,
unrar terminates immediately without executing any cleanup
or state-saving routines. This article explains the exact filesystem
state left behind after such an interruption, how unrar
handles partially extracted data, and the recommended steps to safely
resume or redo the extraction.
Filesystem State After a Reboot
Because unrar processes archives sequentially and writes
data directly to the storage drive, the files in the target directory
will be left in three distinct states:
- Fully Extracted Files: Any files that finished extracting and were closed prior to the reboot remain fully intact and undamaged on the filesystem.
- In-Progress File: The specific file being written at the exact moment power was lost will be incomplete and corrupted. It will either have a smaller file size than intended or exist as a truncated file containing only the bytes flushed to disk before the crash.
- Pending Files: Any files queued after the interrupted file will not exist in the destination directory.
Lack of Native Rollback and Resuming
The unrar utility does not utilize transactional
processing, journaling, or an internal checkpointing mechanism.
Consequently:
- No Automatic Rollback: It will not delete the partially extracted, corrupted file when the system boots back up.
- No Mid-File Resume:
unrarcannot inspect a partially written file and pick up decompression from the exact byte where it stopped. Extraction of that specific file must restart from the beginning.
Handling Re-Extraction
When you execute the extraction command again after the system
restarts, unrar will encounter the files already present on
the drive. Its behavior depends entirely on the flags provided:
- Default Interactive Mode: If run without overwrite
switches,
unrarstops at the first existing file and prompts you to choose an action: Overwrite(Y), Skip(N), Overwrite All(A), or Never overwrite(n). - The Danger of Skipping (
-o-): If you use the skip existing files switch (-o-),unrarwill skip all fully extracted files, but it will also skip the corrupted, partially written file because the file name already exists on disk. This leaves you with damaged data. - Overwriting Everything (
-o+): Using the overwrite switch forcesunrarto re-extract and overwrite every file from scratch, replacing the corrupted file and ensuring total archive integrity. - Freshening (
-f): The freshen switch only extracts files that are older than the ones in the archive. This may not reliably identify a truncated file if the filesystem timestamp matches the archive entry.
Recommended Recovery Procedure
To cleanly recover from an interrupted extraction without leaving damaged files:
- Identify and delete the incomplete file that was actively being written during the crash, or clear the destination directory entirely.
- Re-run the extraction command using the
-o+switch to ensure all data is overwritten cleanly, or selectively extract only the missing and damaged files using target path specifications.