Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of deleting rm without releasing space in linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the "linux rm deletion does not release space how to solve" related knowledge, editor through the actual case to show you the process of operation, the method of operation is simple and fast, practical, I hope that this "linux rm deletion does not release space how to solve" article can help you solve the problem.

Solution: 1, use the "lsof | grep deleted" command to get the process that has been deleted but is still occupied by the application; 2, using the kill command, delete the acquired process can release the deleted space, and the syntax is "kill-9 to get the process number that occupies the deleted file".

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What if rm deletion does not free up space in linux?

Because the deleted file is still operated by the process (open, access, etc.) when the deleted file is deleted, rm only completes the release of the file entity on disk, while the corresponding inode of the corresponding file system in similar free list structure is not released due to the operation of the process.

Solution: this problem is also very simple to solve, to find the process of operation, kill on it, but to find the process of operation is precisely the difficulty and key of this problem.

Such problems can also be solved by rebooting the machine and the nmount/mount file system, but I do not advocate this method. Restart the machine with small problems and make a mountain out of a molehill.

Process:

1. Find the process that is using the deleted file

Lsof | grep deleted

You can get a list of files that have been deleted but are still occupied by the application

After using this command, I found that the list of files is very large, and we need to kill the processes that occupy deleted files one by one.

Examples are as follows:

[root@nc-ftp02 data] # lsof-n / data | grep deletedsh 8757 root 1w REG 202Power5 287246420690 12 / data/nohup.out (deleted) sh 8757 root 2w REG 202deleted 5 287246420690 12 / data/nohup.out (deleted) rsync 28485 root 1w REG 202pm 5287246420690 12 / data/nohup.out (deleted) rsync 28485 root 2w REG 202people 5287246420690 12 / data/nohup.out (deleted) ssh 28486 root 2w REG 202J 5 287246420690 12 / data/nohup.out (deleted) ssh 28486 root 6w REG 202J5 287246420690 / data/nohup.out (deleted) [deleted) Nc-ftp02 data] # lsof-n / data | grep deleted | awk'{print $2} '87578728674286742867528675 [root@nc-ftp02 data] # lsof-n / data | grep deleted | awk' {print $2}'| xargs kill-9 [root@nc-ftp02 data] # lsof-n ata | grep deleted [root@nc-ftp02 data] # df-hFilesystem Size Used Avail Use% Mounted on/dev/xvda2 99g 4.2g 90g 5% / tmpfs 3.9G 228K 3.9G 1% / dev/shm/dev/xvda1 380M 66M 294M 19% / Boot/dev/xvda5 386G 22G 345G 6% / data

2. When kill drops the corresponding process space, it is released.

The content of kill-9 PID on "how to remove rm in linux without releasing space" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report