Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a question for my class that I will pass the class if I get this right. here it is...
Does Linux recycle the inode numbers of deleted files and subdirectories?
Thanks!!
To understand how links work requires some basic knowledge of how Linux handles files. Each file is assigned unique properties (i.e.; permissions, creation date, file type) when created. The two properties critical to understanding links are inode number and file name. An inode number is a unique number assigned to a file by the operating system at the time the file is created. The inode number corresponds to the location of the file contents (the actual data that makes up the file) on the mounted volume (the partition of the disk that is mounted to the volume the file is created in). The file name is a link to the inode number. The file name points back to the inode number from its (the file name's) location in the directory hierarchy. What this means is that when a file is created two things occur: 1) An inode number is assinged to the file data stored on the disk, and 2) The file name is created in the directory structure and assigned to the inode number.
The inode number (the file contents) can have any number of file names hard linked to it. The ls -l command will report the number of hard linked file names to the coressponding inode number in second field of output (the field after permissions). The ls command will not tell you what other file names are hard linked to the inode number. Also note that this number reports the number of hard links for files only. If the number is in the row of a directory, the this is the number of directories immediately under the indicated directory. This number will always be 2 or more. Remember that . and .. are counted in this number (execute ls -a in any directory, count the directory files, then pop up one level, ls -l and see that the number calculated equals the number in the second field).
When a file name is deleted from the directory tree, the file name's connection to the inode number is severed. If the file name is the last "link" to the inode number, thereby reducing the number of inode (file content) "links" to file names to 0, then the inode is detatched from the actual data and returned to the pool of free inode numbers. The data remains on the disk, but unaccessable by traditional means now that it no longer has a corresponding inode number. The disk space is free to be overwritten. This process is called unlinking.
A hard link creates an indistinguishable link between two file names. A hard link allows two (or more) file names to point to the same inode number. When a hard link is created, the link file is assigned the same inode number as the target in its new directory (or the same directory location if the link name is different from the target). The original file contents remain unchanged, but the new file name is attatched to the inode number corresponding to the file contents. Any change made to either file name is reflected in file data. Essentially, a hard link creates another file name and attatches it to the inode number of the data you want to add the link to. If you delete either file name, the other will remain (basically, you are unlinking the file name from the inode number and removing the file name from the directory tree). Hard links cannot be used to link directories (unless the -d,-F option is used by super user). They cannot be used to link across different file systems. Hard links are restricted to the current mounted disk volume boundary.
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.
I'm closing this thread, but I leave you with this: If there are a finite number of inodes what do you think would happen once enough files had existed on a system to use every valid inode? Would the system refuse to create new files? Or would the system recycle inode values of deleted files?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.