How to securely overwrite the free space and inodes of a disk using the sfill command (with examples)
- Linux
- December 25, 2023
The sfill command is a powerful tool that allows users to securely overwrite the free space and inodes of a disk, ensuring that previously deleted data is irrecoverable. It can be particularly useful when disposing of a disk or when transferring it to a new owner, as it helps protect sensitive information from being accessed by unauthorized individuals.
Use case 1: Overwrite free space and inodes of a disk with 38 writes (slow but secure)
Code:
sfill /path/to/mounted_disk_directory
Motivation: This example is recommended when you require the highest level of security. By performing 38 writes, the command ensures that the free space and inodes of the disk are thoroughly overwritten, making it extremely difficult for anyone to recover the previously stored data.
Explanation: The command sfill /path/to/mounted_disk_directory
will securely overwrite both the free space and inodes of the disk located at the specified directory. It uses the default number of writes (38) to ensure a high level of security. The /path/to/mounted_disk_directory
should be replaced with the actual directory path where the disk is mounted.
Example output: The command will run for a significant amount of time, performing the 38 writes to securely overwrite the disk. Once completed, no data should be recoverable from the disk.
Use case 2: Overwrite free space and inodes of a disk with 6 writes (fast but less secure) and show status
Code:
sfill -l -v /path/to/mounted_disk_directory
Motivation: This example provides a compromise between security and speed. By reducing the number of writes to 6, the command executes faster while still providing a reasonable level of data obfuscation.
Explanation: The command sfill -l -v /path/to/mounted_disk_directory
securely overwrites the free space and inodes of the disk located at the specified directory. The -l
flag indicates that only 6 writes will be performed, resulting in a quicker operation. The -v
flag is used to display the progress and status of the command during execution.
Example output: The command will begin overwriting the free space and inodes of the disk, displaying the progress and status as it goes through each write. Once completed, while the level of security is slightly reduced compared to 38 writes, the disk should still be reasonably secure.
Use case 3: Overwrite free space and inodes of a disk with 1 write (very fast but insecure) and show status
Code:
sfill -ll -v /path/to/mounted_disk_directory
Motivation: This example is suitable when speed is a priority, and the level of security is not a significant concern. By performing only 1 write, the command executes very quickly, making it ideal for situations where time is limited.
Explanation: The command sfill -ll -v /path/to/mounted_disk_directory
securely overwrites the free space and inodes of the disk located at the specified directory using only 1 write. The use of the -ll
flag indicates that only a single write will be performed, significantly reducing the time required for the operation. The -v
flag is used to provide real-time progress and status updates.
Example output: The command will quickly overwrite the free space and inodes of the disk, displaying the progress and status as it completes the single write. While the security level is minimal, this approach can be useful in scenarios where time is of the essence and security is not a primary concern.
Use case 4: Overwrite only the free space of a disk
Code:
sfill -I /path/to/mounted_disk_directory
Motivation: This example is useful when you only need to overwrite the free space of a disk, without modifying the existing files or inodes. It can save time and resources when the primary objective is to obfuscate previously deleted data.
Explanation: The command sfill -I /path/to/mounted_disk_directory
specifically targets the free space of the disk located at the specified directory. It securely overwrites the free space while leaving the existing files and inodes intact. The -I
flag instructs the command to only overwrite the free space.
Example output: The command will execute the necessary writes to securely overwrite the free space of the disk. As a result, any previously deleted data within the free space should be obfuscated, while the existing files and inodes remain unchanged.
Use case 5: Overwrite only the free inodes of a disk
Code:
sfill -i /path/to/mounted_disk_directory
Motivation: This example is suitable when you solely want to overwrite the free inodes on a disk. By targeting only the inodes, the command ensures that any metadata associated with previously deleted files is securely obfuscated.
Explanation: The command sfill -i /path/to/mounted_disk_directory
selectively overwrites the free inodes of the disk located at the specified directory. It does not modify the existing files or free space. The -i
flag is used to target only the inodes for secure obliteration.
Example output: The command will perform the necessary writes to overwrite the free inodes of the disk, leaving the existing files and free space unaffected. Any metadata associated with previously deleted files within the inodes should be thoroughly obfuscated.
Conclusion:
The sfill command provides users with a powerful solution for securely overwriting the free space and inodes of a disk. By offering various options for the number of writes and the specific areas to target, users can customize their approach based on the desired level of security and the available resources. Whether speed or maximum security is the priority, sfill ensures that previously deleted data remains irrecoverable, safeguarding sensitive information from unauthorized access.