scrub
Securely overwrite data on files or devices
SYNOPSIS
scrub [OPTIONS] FILE_OR_DEVICE [FILE_OR_DEVICE ...]
PARAMETERS
-r, --random
Overwrite data with pseudo-random bytes. This is a robust method for data sanitization.
-p, --pattern
Overwrite with a specific pattern. Accepted patterns include 'dod', 'gutmann', 'zero', 'random', or a hexadecimal string (e.g., '0xAA').
-x, --blocksize
Set the I/O block size to N bytes. This can affect performance, with larger blocks generally being faster.
-s, --skip
Skip the first N bytes of the target. Useful for preserving boot sectors or specific data areas.
-S, --size
Scrub only N bytes from the target, starting after any skipped bytes. This allows for partial device/file scrubbing.
-f, --force
Force scrubbing even on read-only filesystems or by ignoring I/O errors. Use with extreme caution.
-v, --verbose
Enable verbose output, showing progress information during the scrubbing process.
-z, --zero
Overwrite data with zeros. While fast, it is considered less secure than random or pattern-based methods for preventing advanced recovery.
-I, --iterations
Specify the number of passes for random or pattern scrubbing. More passes increase security but also execution time.
-D, --device
Treat target(s) as block devices (e.g., /dev/sda). This is critical when sanitizing entire disks or partitions.
-F, --file
Treat target(s) as regular files (this is the default behavior).
-d, --dry-run
Simulate scrubbing without actually writing any data. Useful for testing commands and verifying parameters.
-q, --quiet
Suppress all output except errors. Useful for scripting or background operations.
-L, --loop
Continuously loop scrubbing the target. This will repeatedly overwrite the data until manually stopped.
--help
Display help message and exit.
--version
Output version information and exit.
DESCRIPTION
scrub is a command-line utility used for securely erasing data from files or block devices. Unlike a standard rm command, which only unlinks a file's inode but leaves its data blocks on the disk, scrub overwrites the actual data several times with specific patterns. This process makes it extremely difficult, if not impossible, to recover the original information using data recovery techniques. It supports various data sanitization methods, including writing pseudo-random data, fixed patterns, or patterns conforming to standards like DoD 5220.22-M or the Gutmann method. This tool is crucial for ensuring data privacy and security when decommissioning hardware, disposing of old disks, or before reusing storage devices that previously held sensitive information. By systematically overwriting data sectors, scrub helps prevent unauthorized access to residual data, mitigating the risk of data breaches.
CAVEATS
Metadata Incompleteness:
scrub primarily focuses on file content. It does not typically erase file names, directory structures, or other metadata stored in the filesystem, which might still contain sensitive information. For complete sanitization, the filesystem itself may need to be recreated or the entire device scrubbed.
SSD Limitations:
Due to wear leveling, TRIM commands, and over-provisioning in Solid State Drives (SSDs), software-based secure erase tools like scrub may not reliably overwrite all data sectors. For true SSD sanitization, hardware-level secure erase commands (e.g., via hdparm) are generally recommended.
Journaling Filesystems:
On journaling filesystems (e.g., ext3/4, XFS, Btrfs), data remnants might persist in the filesystem journal or other cached areas, even after scrubbing the primary file.
Data Recovery Potential:
While highly effective against most data recovery methods, no software tool can guarantee 100% data unrecoverability against highly sophisticated forensic techniques or specialized hardware attacks.
SCRUBBING METHODS AND PATTERNS
scrub supports various patterns for overwriting data. Common patterns include random (writing pseudo-random data), zero (writing all zeros), and specific algorithmic patterns like dod (Department of Defense 5220.22-M standard) or gutmann (a 35-pass method designed for older magnetic media, often considered overkill for modern drives but still supported). The choice of pattern affects both the security level and the time taken to complete the operation.
USAGE CONSIDERATIONS
When scrubbing entire disks or partitions, ensure you target the correct device (e.g., /dev/sda, /dev/sdb1) to avoid unintended data loss. Using the --dry-run option is highly recommended to verify your command before executing a destructive operation. For files, remember that scrub only affects the file content, not its name or directory entry. Always back up any necessary data before running scrub, as the operation is irreversible.
HISTORY
The scrub utility emerged from the need for a robust and reliable method to perform data sanitization on Linux systems. Its development focused on implementing various government and industry-standard data erasure techniques, such as the Department of Defense (DoD) 5220.22-M standard and the Gutmann method, to ensure data could not be recovered after disposal. It's often distributed as part of the scrub-utils package and has been an essential tool for system administrators and users concerned with data privacy and regulatory compliance when decommissioning hardware or reusing storage media.


