In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
The editor today takes you to understand how to solve the problem of unreleased space after deleting the Linux file. The knowledge points in the article are introduced in great detail. Friends who think it is helpful can browse the content of the article together with the editor, hoping to help more friends who want to solve this problem find the answer to the problem. Let's follow the editor to learn in depth how to solve the problem of unreleased space after deleting the Linux file.
Experimental preparation
There are many ways to simulate this scenario, mainly by implementing the scenario in which the file is occupied. The easiest way is to copy files, and another common way is that students who are good at programming or shell can write programs or scripts to write content into a file constantly. This time, it can be reproduced quickly by copying files.
1.1.Create a slightly larger file / * mainly for this file operation * / [root@liangxu] # ll-htotal 3.0GMurray RWMUR Murray. 1 root root 2.5G May 4 17:43 all_backup.tar.gz/* root directory usage 6.5 G * / [root@liangxu] # df-lhFilesystem Size Used Avail Use% Mounted ondevtmpfs 1.9G 0 1.9G 0 / devtmpfs 1.9G 0 1.9G 0 0 / dev/shmtmpfs 1.9G 12M 1.9G 1% / runtmpfs 1.9G 0 1.9G 0 0 / sys/fs/cgroup/dev/mapper/centos-root 46G 6.5G 39G 15% / / dev/sda1 1014M 150M 865M 15% / boottmpfs 378M 0378M 0% / run/user/0
1.2 use the scp command to occupy the file / * start remote copying to other hosts * / [root@liangxu] # scp all_backup.tar.gz test@192.168.28.226:/home/test/The authenticity of host '192.168.28.226 (192.168.28.226)' can't be established.ECDSA key fingerprint is SHA256:QfJb1DogFmdZ0hkeVRvn2VHke+tkZ2+sNljhBBudooc.ECDSA key fingerprint is MD5:2a:8a:63:80:35:17:f7:e9 2a:ea:13:98:eb:26:30:ba.Are you sure you want to continue connecting (yes/no)? YesWarning: Permanently added '192.168.28.226' (ECDSA) to the list of known hosts.test@192.168.28.226's password:all_backup.tar.gz 0% 2432KB 2. 4MB/s 17:53 ETA ^ Z [1] + Stopped scp all_backup.tar.gz test@192.168.28.226:/home/test / * run in the background * / [root@liangxu] # bg% 1 [1] + scp all_backup.tar.gz test@192.168.28.226:/home/test &
1.3 Delete files
Delete the file at this time, and then check to see if the file has been deleted and whether the space is free.
/ * Delete files * / [root@liangxu]
02
Treatment method
There are many ways to simulate the scene
You can use the lsof (list opened files) command to see which files have been opened and which process the files are occupied by.
The lsof command is not available on minimized installed systems. You can install it through yum first.
Yum install-y lsof
2.1 lsof View Files
View all open files and filter out files with deleted status (deleted)
[root@liangxu] # lsof | grep deletedfirewalld 818 root 6u REG 253 0 4096 36061750 / tmp/ffi0SEit6 (deleted) gmain 818 998 root 6u REG 253 0 4096 36061750 / tmp/ffi0SEit6 (deleted) tuned 1180 root 8u REG 253 0 4096 33554962 / tmp/ffio5Nu8r (deleted) gmain 1180 1602 root 8u REG 253 deleted 0 4096 33554962 / tmp/ffio5Nu8r (deleted) tuned 1180 1603 root 8u REG 253 0 4096 33554962 / tmp/ffio5Nu8r (deleted) tuned 1180 1605 root 8u REG 253 0.4096 33554962 / tmp/ffio5Nu8r (deleted) tuned 1180 1606 root 8u REG 253 0.4096 33554962 / tmp/ffio5Nu8r (deleted) scp 1798 Root 3r REG 253 0 2665433605 104181296 / usr/local/all_backup.tar.gz (deleted)
Found the file we just deleted and opened by that process
2.2 View the process
Through lsof, it is found that the all_backup.tar.gz file is occupied by process 1798. You can see what the process is.
[root@liangxu] # ps-ef | grep 1798root 1798 1729 0 17:47 pts/0 00:00:00 scp all_backup.tar.gz test@192.168.28.226:/home/testroot 1799 1798 2 17:47 pts/0 00:00:03 / usr/bin/ssh-x-oForwardAgent=no-oPermitLocalCommand=no-oClearAllForwardings=yes-l test-- 192.168.28... 226 scp-t / home/testroot 1868 1806 0 17:49 pts/1 00:00:00 grep-color=auto 1798
It is the copy command that we carried out before.
2.3 Free Space
For this kind of query status, you need to end the corresponding program.
/ * kill the corresponding process * / [root@liangxu] # kill-9 1799 1798max * Space has been released * / [root@liangxu] # df-lhFilesystem Size Used Avail Use% Mounted ondevtmpfs 1.9G 0 1.9g 0% / devtmpfs 1.9G 0 1.9G 0% / dev/shmtmpfs 1.9g 12m 1.9G 1% / runtmpfs 1.9G 0 1.9G 0 / sys/fs/cgroup/dev/mapper/centos-root 46G 4.0G 42G 9 / / dev/sda1 1014M 150M 865M 15% / boottmpfs 378M 0378M 0% / run/user/0
Note: if you want to empty the log continuously, you can use the echo "> filename command to empty the file online. There is no need to end the process violently. If this method is invalid, consider ending the process.
This is mainly applicable to the following scenarios:
Delete file space unfreed disk full but file not found
Again, if you can use the echo "" > filename command to empty files online, you don't need to end the process violently, and consider ending the process if this method doesn't work.
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
Thank you for your reading, the above is the whole content of "how to solve the problem of unreleased space after deleting Linux files". Friends who learn to learn to hurry up to operate it. I believe that the editor will certainly bring you better quality articles. Thank you for your support to the website!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.