Does this sound familiar? Your Linux file system is full, so you delete a large number of big files. However, when you check disk usage with df, the disk still shows up as being completely full. If this has happened to you, you’re not alone. Most systems administrators have experienced this at least once. Understanding what’s going on and fixing it can be difficult and frustrating.
Don’t worry, we’re here to help. In today’s article, we’ll discuss some common reasons your disk might show up as completely full even after deleting many large files. After that, we’ll go into several ways that you can rectify this problem.
What’s going on?
So, what causes this issue? How can it be resolved? There are actually a few reasons why the Linux file system will report no free space even after deleting some files. Mostly, this relates to the fact that “deleted” is not quite as final as it may sound. When you delete files in Linux, you are telling the OS that you no longer need the files. Actually deleting them may not happen right away. Here are some possible reasons:
- Cached files: As we mentioned, when you delete a file, it doesn’t get immediately erased. The data is still located on the disk until another program overwrites it, or the OS believes it no longer needs it. Due to the OS caching files in memory, these files can still be considered “active” if a copy is stored in cache memory, preventing permanent deletion. Therefore, one way to force a more immediate deletion of these files is to flush the file system cache. Two commands you can try for this are the “sync” and “echo 3 > /proc/sys/vm/drop_caches” commands. By flushing the cache, there is a good chance you will free up the disk space successfully.
- Deleted files are still in use: We just discussed that the OS may believe a file is “active” if a copy of it exists in cache memory. Another way this can happen, is if an actively running program has the files open for its use. When this happens, the files won’t actually be deleted until the program exits or the program closes the files. If you know what program might be accessing the files, you can stop or restart the program. If you’re not sure which program might be holding the files open, you can resolve this by rebooting your computer.
- Mount points and other filesystems: If you’re got several drives or disk arrays mounted on your computer, it’s possible the files you deleted are not actually located on the disk that’s full. The df command shows disk usage for all mounted filesystems. You’ll want to double check where that the disk or array that’s full is storing its files. With the “mount” command with no options, you will see a list of what folders / mount points are active for different drives, logical volumes, and raid arrays. You can then look unneeded files located in directories where your full drive is actually storing data.
As you can see, there are a few reasons that your filesystem may still show up as full even after you’ve deleted a large number of files. The main reasons are the linux filesystem cache, programs that still have files open, or simply deleting files from the wrong disk, array, or partition. To free up this disk space, the easiest method is just to reboot the computer, but you can also try flushing the file system cache or restarting programs that have kept open the files you’ve tried to delete. I hope you’ve found this explanation helpful and informative.
Do You Love Servers?
We do! If you’re struggling with disk space issues on your Linux system, IOFLOOD can help. Our dedicated servers offer a range of storage solutions to fit your needs. Whether you need a lot of space for backups, high-speed storage for databases, or a combination of both, our team can help you find the perfect solution.
To learn more about our dedicated servers and how we can help you optimize your storage usage, contact us at sales[at]ioflood.com or visit our website at https://ioflood.com. Our team is always ready to answer your questions and help you find the best server for your needs.