Can two files on two separate filesystems share the same inode number? [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
17
down vote
favorite
This question already has an answer here:
Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?
2 answers
If I run a command like this one:
find / -inum 12582925
Is there a chance that this will list two files on separate mounted filesystems (from separate partitions) that happen to have been assigned the same number? Is the inode number unique on a single filesystem, or across all mounted filesystems?
filesystems inode
marked as duplicate by Jeff Schaller, schily, Thomas, Isaac, G-Man Aug 26 at 18:48
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
17
down vote
favorite
This question already has an answer here:
Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?
2 answers
If I run a command like this one:
find / -inum 12582925
Is there a chance that this will list two files on separate mounted filesystems (from separate partitions) that happen to have been assigned the same number? Is the inode number unique on a single filesystem, or across all mounted filesystems?
filesystems inode
marked as duplicate by Jeff Schaller, schily, Thomas, Isaac, G-Man Aug 26 at 18:48
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
17
down vote
favorite
up vote
17
down vote
favorite
This question already has an answer here:
Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?
2 answers
If I run a command like this one:
find / -inum 12582925
Is there a chance that this will list two files on separate mounted filesystems (from separate partitions) that happen to have been assigned the same number? Is the inode number unique on a single filesystem, or across all mounted filesystems?
filesystems inode
This question already has an answer here:
Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?
2 answers
If I run a command like this one:
find / -inum 12582925
Is there a chance that this will list two files on separate mounted filesystems (from separate partitions) that happen to have been assigned the same number? Is the inode number unique on a single filesystem, or across all mounted filesystems?
This question already has an answer here:
Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?
2 answers
filesystems inode
filesystems inode
asked Aug 23 at 12:41
Flimm
1,30541827
1,30541827
marked as duplicate by Jeff Schaller, schily, Thomas, Isaac, G-Man Aug 26 at 18:48
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Jeff Schaller, schily, Thomas, Isaac, G-Man Aug 26 at 18:48
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
39
down vote
accepted
An inode number is only unique on a single file system. One example youâÂÂll run into quickly is the root inode on ext2/3/4 file systems, which is 2:
$ ls -id / /home
2 / 2 /home
If you run (assuming GNU find
)
find / -printf "%i %pn" | sort -n | less
on a system with multiple file systems youâÂÂll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).
When youâÂÂre looking for a file by inode number, you can use find
âÂÂs -xdev
option to limit its search to the file system containing the start path, if you have a single start path:
find / -xdev -inum 12582925
will only find files with inode number 12582925 on the root file system. (-xdev
also works with multiple start paths, but then its usefulness is reduced in this particular case.)
It's the combination of inode number and device number (st_dev
and st_ino
in the stat
structure, %D %i
in GNU find
's -printf
) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).
Some find
implementations also have a -samefile
predicate that will find files with the same device and inode number. Most [
/test
implementations also have a -ef
operator to check that two files paths refer to the same file (after symlink resolution though).
add a comment |Â
up vote
4
down vote
Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major âÂÂthe general class of deviceâÂÂàand dev_minor âÂÂthe specific instanceâÂÂ).
The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).
As stated on inode(7):
Device where inode resides
Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).
Inode number
Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers
may be used by different filesystems, which is the reason that hard links may not cross filesystem boundaries).
If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
â RonJohn
Aug 24 at 19:07
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
39
down vote
accepted
An inode number is only unique on a single file system. One example youâÂÂll run into quickly is the root inode on ext2/3/4 file systems, which is 2:
$ ls -id / /home
2 / 2 /home
If you run (assuming GNU find
)
find / -printf "%i %pn" | sort -n | less
on a system with multiple file systems youâÂÂll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).
When youâÂÂre looking for a file by inode number, you can use find
âÂÂs -xdev
option to limit its search to the file system containing the start path, if you have a single start path:
find / -xdev -inum 12582925
will only find files with inode number 12582925 on the root file system. (-xdev
also works with multiple start paths, but then its usefulness is reduced in this particular case.)
It's the combination of inode number and device number (st_dev
and st_ino
in the stat
structure, %D %i
in GNU find
's -printf
) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).
Some find
implementations also have a -samefile
predicate that will find files with the same device and inode number. Most [
/test
implementations also have a -ef
operator to check that two files paths refer to the same file (after symlink resolution though).
add a comment |Â
up vote
39
down vote
accepted
An inode number is only unique on a single file system. One example youâÂÂll run into quickly is the root inode on ext2/3/4 file systems, which is 2:
$ ls -id / /home
2 / 2 /home
If you run (assuming GNU find
)
find / -printf "%i %pn" | sort -n | less
on a system with multiple file systems youâÂÂll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).
When youâÂÂre looking for a file by inode number, you can use find
âÂÂs -xdev
option to limit its search to the file system containing the start path, if you have a single start path:
find / -xdev -inum 12582925
will only find files with inode number 12582925 on the root file system. (-xdev
also works with multiple start paths, but then its usefulness is reduced in this particular case.)
It's the combination of inode number and device number (st_dev
and st_ino
in the stat
structure, %D %i
in GNU find
's -printf
) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).
Some find
implementations also have a -samefile
predicate that will find files with the same device and inode number. Most [
/test
implementations also have a -ef
operator to check that two files paths refer to the same file (after symlink resolution though).
add a comment |Â
up vote
39
down vote
accepted
up vote
39
down vote
accepted
An inode number is only unique on a single file system. One example youâÂÂll run into quickly is the root inode on ext2/3/4 file systems, which is 2:
$ ls -id / /home
2 / 2 /home
If you run (assuming GNU find
)
find / -printf "%i %pn" | sort -n | less
on a system with multiple file systems youâÂÂll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).
When youâÂÂre looking for a file by inode number, you can use find
âÂÂs -xdev
option to limit its search to the file system containing the start path, if you have a single start path:
find / -xdev -inum 12582925
will only find files with inode number 12582925 on the root file system. (-xdev
also works with multiple start paths, but then its usefulness is reduced in this particular case.)
It's the combination of inode number and device number (st_dev
and st_ino
in the stat
structure, %D %i
in GNU find
's -printf
) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).
Some find
implementations also have a -samefile
predicate that will find files with the same device and inode number. Most [
/test
implementations also have a -ef
operator to check that two files paths refer to the same file (after symlink resolution though).
An inode number is only unique on a single file system. One example youâÂÂll run into quickly is the root inode on ext2/3/4 file systems, which is 2:
$ ls -id / /home
2 / 2 /home
If you run (assuming GNU find
)
find / -printf "%i %pn" | sort -n | less
on a system with multiple file systems youâÂÂll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).
When youâÂÂre looking for a file by inode number, you can use find
âÂÂs -xdev
option to limit its search to the file system containing the start path, if you have a single start path:
find / -xdev -inum 12582925
will only find files with inode number 12582925 on the root file system. (-xdev
also works with multiple start paths, but then its usefulness is reduced in this particular case.)
It's the combination of inode number and device number (st_dev
and st_ino
in the stat
structure, %D %i
in GNU find
's -printf
) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).
Some find
implementations also have a -samefile
predicate that will find files with the same device and inode number. Most [
/test
implementations also have a -ef
operator to check that two files paths refer to the same file (after symlink resolution though).
edited Aug 23 at 14:51
Stéphane Chazelas
285k53525864
285k53525864
answered Aug 23 at 12:47
Stephen Kitt
146k22320386
146k22320386
add a comment |Â
add a comment |Â
up vote
4
down vote
Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major âÂÂthe general class of deviceâÂÂàand dev_minor âÂÂthe specific instanceâÂÂ).
The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).
As stated on inode(7):
Device where inode resides
Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).
Inode number
Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers
may be used by different filesystems, which is the reason that hard links may not cross filesystem boundaries).
If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
â RonJohn
Aug 24 at 19:07
add a comment |Â
up vote
4
down vote
Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major âÂÂthe general class of deviceâÂÂàand dev_minor âÂÂthe specific instanceâÂÂ).
The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).
As stated on inode(7):
Device where inode resides
Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).
Inode number
Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers
may be used by different filesystems, which is the reason that hard links may not cross filesystem boundaries).
If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
â RonJohn
Aug 24 at 19:07
add a comment |Â
up vote
4
down vote
up vote
4
down vote
Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major âÂÂthe general class of deviceâÂÂàand dev_minor âÂÂthe specific instanceâÂÂ).
The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).
As stated on inode(7):
Device where inode resides
Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).
Inode number
Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers
may be used by different filesystems, which is the reason that hard links may not cross filesystem boundaries).
Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major âÂÂthe general class of deviceâÂÂàand dev_minor âÂÂthe specific instanceâÂÂ).
The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).
As stated on inode(7):
Device where inode resides
Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).
Inode number
Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers
may be used by different filesystems, which is the reason that hard links may not cross filesystem boundaries).
answered Aug 23 at 22:07
Ãngel
1,358512
1,358512
If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
â RonJohn
Aug 24 at 19:07
add a comment |Â
If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
â RonJohn
Aug 24 at 19:07
If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
â RonJohn
Aug 24 at 19:07
If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
â RonJohn
Aug 24 at 19:07
add a comment |Â