4.16. Removing Data Securely Using scrub
The scrub utility sets patterns on special files or disk devices to make retrieving data more difficult. Using scrub is faster than writing random data on a disk. This process provides high availability, reliability, and data protection.
To start using the
scrub
command, install the scrub package:
~]# yum install scrub
~]# yum install scrub
The scrub utility operates in one of the following basic modes:
-
Character or Block Device
- The special file corresponding to a whole disk is scrubbed and all data on it, is destroyed. This is the most effective method.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow scrub [OPTIONS] special file
scrub [OPTIONS] special file
-
File
- A regular file is scrubbed and only the data in the file is destroyed.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow scrub [OPTIONS] file
scrub [OPTIONS] file
-
Directory
- With the
-X
option, a directory is created and filled with files until the file system is full. Then, the files are scrubbed as in file mode.Copy to Clipboard Copied! Toggle word wrap Toggle overflow scrub -X [OPTIONS] directory
scrub -X [OPTIONS] directory
Example 4.7. Scrubbing a Raw Device
To scrub a raw device /dev/sdf1 with default National Nuclear Security Administration (NNSA) patterns, enter the following command:
~]# scrub /dev/sdf1 scrub: using NNSA NAP-14.1-C patterns scrub: please verify that device size below is correct! scrub: scrubbing /dev/sdf1 1995650048 bytes (~1GB) scrub: random |................................................| scrub: random |................................................| scrub: 0x00 |................................................| scrub: verify |................................................|
~]# scrub /dev/sdf1
scrub: using NNSA NAP-14.1-C patterns
scrub: please verify that device size below is correct!
scrub: scrubbing /dev/sdf1 1995650048 bytes (~1GB)
scrub: random |................................................|
scrub: random |................................................|
scrub: 0x00 |................................................|
scrub: verify |................................................|
Example 4.8. Scrubbing a File
- Create a 1MB file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]$ base64 /dev/urandom | head -c $[ 1024*1024 ] > file.txt
~]$ base64 /dev/urandom | head -c $[ 1024*1024 ] > file.txt
- Show the file size:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]$ ls -lh total 1.0M -rw-rw-r--. 1 username username 1.0M Sep 8 15:23 file.txt
~]$ ls -lh total 1.0M -rw-rw-r--. 1 username username 1.0M Sep 8 15:23 file.txt
- Show the contents of the file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]$ head -1 file.txt JnNpaTEveB/IYsbM9lhuJdw+0jKhwCIBUsxLXLAyB8uItotUlNHKKUeS/7bCRKDogEP+yJm8VQkL
~]$ head -1 file.txt JnNpaTEveB/IYsbM9lhuJdw+0jKhwCIBUsxLXLAyB8uItotUlNHKKUeS/7bCRKDogEP+yJm8VQkL
- Scrub the file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]$ scrub file.txt scrub: using NNSA NAP-14.1-C patterns scrub: scrubbing file.txt 1048576 bytes (~1024KB) scrub: random |................................................| scrub: random |................................................| scrub: 0x00 |................................................| scrub: verify |................................................|
~]$ scrub file.txt scrub: using NNSA NAP-14.1-C patterns scrub: scrubbing file.txt 1048576 bytes (~1024KB) scrub: random |................................................| scrub: random |................................................| scrub: 0x00 |................................................| scrub: verify |................................................|
- Verify that the file contents have been scrubbed:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]$ cat file.txt SCRUBBED!
~]$ cat file.txt SCRUBBED!
- Verify that the file size remains the same:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ~]$ ls -lh total 1.0M -rw-rw-r--. 1 username username 1.0M Sep 8 15:24 file.txt
~]$ ls -lh total 1.0M -rw-rw-r--. 1 username username 1.0M Sep 8 15:24 file.txt
For more information on
scrub
modes, options, methods, and caveats, see the scrub(1) man page.