SoFunction
Updated on 2025-04-15

Linux system full-scale problem and solution

Linux system full-scale problem and solution

When the Linux system disk is full, there are a variety of processing solutions to free up space.

Here are some effective solutions:

1. Find and delete useless large files

  • Use du and find commands: Check the size of each file or folder in the current directory through du -sh * | sort -rh and sort. Use find / -type f -size +100M to find files larger than 100M in the system.
  • Pay special attention to log files: Log files can take up a lot of disk space, especially in long-running production environments. You can use ls -lSr /var/log | grep ^- | tail to find and delete old log files.

2. Clean up temporary files

  • System temporary files: Delete files under /tmp and /var/tmp directories, which are usually temporary files when the application is running. You can use rm -rf /tmp/ and rm -rf /var/tmp/ (Note: This operation requires caution to ensure there are no important files).
  • Temporary files for the application: Check and delete temporary files generated by specific applications, such as .tmp files, etc.

3. Uninstall infrequently used software packages

  • Use a package manager (such as apt, yum, etc.) to uninstall packages that are no longer needed.
  • For example, in Debian or Ubuntu systems, sudo apt-get autoremove can be used to automatically uninstall packages that are no longer dependent on any installed packages.

4. Compress or move files

  • Compress large files: Compress large files that are not often accessed into .zip, . and other formats to reduce the disk space they occupy.
  • Move files to other disks: If possible, move some infrequently used files or data to other disks or storage devices.

5. Clean up the system cache

  • Use the sync && sysctl -w vm.drop_caches=3 command to clean the cache pages of the Linux kernel and recycle unused memory.
  • But be aware that this may cause temporary system performance to decline.

6. Check and delete unreleased deleted files

  • Sometimes, deleted files are still occupied by certain processes, resulting in disk space not being released.
  • You can use lsof | grep deleted to find these files and consider restarting the corresponding process.

7. Clean Docker logs

  • If Docker is running on the system, Docker's log files may take up a lot of disk space.
  • You can use find /var/lib/docker/containers/ -name "*-" | xargs -r truncate -s 0 to clear these log files, or use docker system prune to delete unused Docker objects.

8. Check the disk mount status

  • If there is a problem with disk mount, it may cause the disk space to appear insufficient.
  • Use commands such as df -h and lsblk to check the disk mount status to ensure that there are no wrong mounted or unmounted disks.

9. Consider expanding disk space

  • If none of the above methods solve the problem, you may need to consider expanding disk space.
  • This can be done by adding new hard drives or using virtual machine management software to increase disk space.

Summarize

To deal with the problem of full Linux system disk, multiple aspects need to be considered comprehensively, including finding and deleting useless files, cleaning temporary files and logs, uninstalling infrequently used software packages, compressing or moving files, cleaning system caches, checking and deleting unfreed deleted files, cleaning Docker logs, checking disk mounts, and considering expanding disk space. Choose the appropriate processing plan according to the specific situation and operate with caution to avoid data loss.

These are just personal experience. I hope you can give you a reference and I hope you can support me more.