-
Lniux under control files actually deleted counter
Linux
Islink
the number to control the deleted files. Only when a file does not exist any link, this file will be deleted. In general, each file has two link counters:i_count
andi_link
i_count
The significance of the current number of files the user (or called) is
when a file is referenced a certain process, the corresponding value will increasei_nlink
The significance of the number (the number of hard links) media connections
When creating hard links files, this value will increase
Can be understood as
i_count
a memory reference counter,i_nlink
is a reference to counter the hard drive -
rm
Command principleFor the delete command
rm
, the disk is actually reducing the reference counti_nlink
.Q : If a file is being called a process, but users execute
rm
the file deletion, then what will be the result? When the user performsrm
after deleting the files, and then performls
other file management commands, you can no longer find this file, but call this process to delete the file has continued to perform well, still able to correctly read and write from the file, This is why?A :
rm
Operation only the filesi_nlink
reduced, if no other linksi_nlink
on the 0. However, because the document is still being referenced process, therefore, when the corresponding filei_count
is not 0, so the implementation ofrm
operation, the system does not really delete this file, and only wheni_nlink
, andi_count
are zero when the file will only be true delete. In other words, the process must lift the call to the file, in order to really delete.Q : When the file has not been called, is performed
rm
after the operation, can recover deleted files do?A :
rm
Operation only the filei_nlink
is reduced, or is set to 0, the inode is actually a link removed at this time, and no entity (block block) file is deleted, this time, if the time to stop the machine work, data can be retrieved, if it continues to write data, the new data may be assigned to the block data block is deleted data file is truly recovered. -
Practical problems encountered
Q : Web server disk space is not enough, in addition to all the mountain useless log or show lack of disk space, but
du -sh
found very little disk space usage, this is why? What causes insufficient disk space?A : Just delete command to delete a file
i_nlink
, but other processes are using these log files,apache
ortomat
restart these services Jiuhaola!original: https://www.cnblogs.com/cherishry/p/5886069.html
Linux delete files under the principle of
Guess you like
Origin www.cnblogs.com/tyk3201/p/12154637.html
Recommended
Ranking