How to Delete HUGE (100-200GB) Files in Linux

In the realm of Linux terminal operations, a range of Linux commands are at our disposal for the purpose of effectively deleting or removing files.

When it comes to the task of file elimination, we commonly rely on the “rm” command, which swiftly erases files from the system. For enhanced security and assurance, the “shred” command comes into play, ensuring the thorough and secure deletion of a file, leaving no trace behind.

Furthermore, the “wipe” command offers an added layer of protection, securely erasing files beyond any possibility of recovery. In more complex scenarios or for advanced file deletion needs, we can turn to the secure deletion tools designed to meet the highest standards of secure file deletion.

With these powerful options at our disposal, we can confidently and effectively remove files from the Linux terminal environment.

We can use any of the above utilities to deal with relatively small files. What if we want to delete/remove a huge file/directory say about 100-200GB?

This may not be as easy as it seems, in terms of the time taken to remove the file (I/O scheduling) as well as the amount of RAM consumed while carrying out the operation.

In this tutorial, we will explain how to efficiently and reliably delete huge files/directories in Linux.

The main aim here is to use a technique that will not slow down the system while removing a huge file, resulting to reasonable I/O. We can achieve this using the ionice command.

Deleting HUGE (200GB) Files in Linux Using ionice Command

ionice is a useful program that sets or gets the I/O scheduling class and priority for another program. If no arguments or just -p is given, ionice will query the current I/O scheduling class and priority for that process.

If we give a command name such as rm command, it will run this command with the given arguments. To specify the process IDs of running processes for which to get or set the scheduling parameters, run this:

# ionice -p PID

To specify the name or number of the scheduling class to use (0 for none, 1 for real-time, 2 for best-effort, 3 for idle) the command below.

This means that rm will belong to the idle I/O class and only uses I/O when any other process does not need it:

---- Deleting Huge Files in Linux -----
# ionice -c 3 rm /var/logs/syslog
# ionice -c 3 rm -rf /var/log/apache

If there won’t be much idle time on the system, then we may want to use the best-effort scheduling class and set a low priority like this:

# ionice -c 2 -n 6 rm /var/logs/syslog
# ionice -c 2 -n 6 rm -rf /var/log/apache

Note: To delete huge files using a secure method, we may use the shred, wipe and various tools in the secure-deletion toolkit mentioned earlier on, instead of the rm command.

For more info, look through the ionice man page:

# man ionice 

That’s it for now! What other methods do you have in mind for the above purpose? Use the comment section below to share with us.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

8 thoughts on “How to Delete HUGE (100-200GB) Files in Linux”

  1. Why not simply use “nice” and set a low priority? Would that be sufficiently efficient? Linux will know how to handle the priorities so when the cpu is not running high, it will give more cpu time to the rm command. I don’t see any significant difference.

    Reply
    • @Lethargos

      A reasonable way to accomplish the job, we’ll surely test this out. Many thanks for writing back.

      Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.